@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink-950: #0F141C;
  --ink-900: #151B26;
  --ink-800: #1D2531;
  --ink-700: #28323F;
  --ink-600: #3A4655;
  --ink-400: #7C8A9A;
  --ink-200: #C7CFD8;
  --paper-50: #FBF9F3;
  --paper-100: #F3EFE4;
  --paper-200: #E9E2D2;
  --teal: #1F6F63;
  --teal-dark: #164F46;
  --brass: #B08A2E;
  --rose: #B3454A;

  --bg: var(--paper-100);
  --surface: var(--paper-50);
  --border: var(--paper-200);
  --text: var(--ink-900);
  --text-muted: var(--ink-400);
}

html.dark {
  --bg: var(--ink-950);
  --surface: var(--ink-900);
  --border: var(--ink-700);
  --text: var(--paper-100);
  --text-muted: var(--ink-400);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; margin: 0; }
.figures { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- Layout ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 20px 24px; font-size: 20px; font-weight: 600; border-bottom: 1px solid var(--border); }
.sidebar-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px;
  text-decoration: none; font-size: 14px; font-weight: 500; color: var(--text-muted);
}
.nav a:hover { background: var(--border); }
.nav a.active { background: rgba(31,111,99,0.12); color: var(--teal); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.sidebar-footer .user-row { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 8px; font-size: 12px; color: var(--text-muted); }
.main { margin-left: 240px; flex: 1; padding: 32px; max-width: 1100px; }
.topbar { display: none; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; z-index: 40; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
}

/* ---- Components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 4px; }
.stat-value { font-size: 24px; font-weight: 600; margin: 0; }
.positive { color: var(--teal); }
.negative { color: var(--rose); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 9px 16px;
  font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid transparent; text-decoration: none;
}
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px;
  background: var(--surface); color: var(--text); margin-bottom: 2px;
}
.input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: rgba(0,0,0,0.02); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--border); }
.dot-sm { width: 8px; height: 8px; border-radius: 50%; }

.empty-state { text-align: center; padding: 60px 20px; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-muted); }
.error-banner { border: 1px solid rgba(179,69,74,0.3); background: rgba(179,69,74,0.06); color: var(--rose); padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.loading { text-align: center; padding: 60px 0; color: var(--text-muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,28,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 10px; padding: 24px; width: 100%; max-width: 420px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.hidden { display: none !important; }
