@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@600;700&display=swap');

:root {
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border:    #e1e8f0;
  --text:      #1a2233;
  --muted:     #64748b;
  --blue:      #2563eb;
  --blue-soft: #dbeafe;
  --green:     #16a34a;
  --green-soft:#dcfce7;
  --orange:    #d97706;
  --orange-soft:#fef3c7;
  --red:       #dc2626;
  --red-soft:  #fee2e2;
  --purple:    #7c3aed;
  --cyan:      #0891b2;
  --shadow:    0 1px 3px rgba(0,0,0,.07), 0 6px 20px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --radius:    14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

body { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }

/* ── Layout ────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  background: #1e2d45;
  border-right: 1px solid rgba(0,0,0,.12);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand {
  padding: 12px 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 4px;
}

.brand h2 {
  color: #ffffff;
  font-size: 15px;
  letter-spacing: .3px;
}

.brand small {
  color: rgba(255,255,255,.45);
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav button {
  background: transparent;
  color: rgba(255,255,255,.6);
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav button:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}

.nav button.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.side-footer {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11.5px;
  color: rgba(255,255,255,.35);
}

/* ── Main ──────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.topbar .title h2 {
  font-size: 16px;
  color: var(--text);
}

.topbar .title small {
  display: block;
  color: var(--muted);
  margin-top: 1px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── Buttons ───────────────────────────────── */
.btn {
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 13.5px;
  transition: background .14s, box-shadow .14s;
}

.btn:hover {
  background: var(--surface-3);
  box-shadow: var(--shadow);
}

.btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn.primary:hover {
  background: #1d4ed8;
}

.btn.green {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn.orange {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

.btn.red {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ── Content area ──────────────────────────── */
.content {
  padding: 24px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.panel { display: none; }
.panel.active { display: block; }

/* ── Grid / Cards ──────────────────────────── */
.grid { display: grid; gap: 16px; }

.grid.cards {
  grid-template-columns: repeat(4, minmax(0,1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

.muted { color: var(--muted); }

/* ── Flex helpers ──────────────────────────── */
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

.between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ── Tables ────────────────────────────────── */
.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  position: sticky;
  top: 0;
  background: var(--surface);
}

tr:hover td { background: var(--surface-2); }

/* ── Badges ────────────────────────────────── */
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge.blue   { background: var(--blue-soft);   color: #1d4ed8; }
.badge.green  { background: var(--green-soft);  color: #15803d; }
.badge.orange { background: var(--orange-soft); color: #b45309; }
.badge.red    { background: var(--red-soft);    color: #b91c1c; }
.badge.gray   { background: var(--surface-3);   color: var(--muted); }

/* ── Section title ─────────────────────────── */
.section-title { margin-bottom: 14px; }

/* ── Search ────────────────────────────────── */
.search {
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.search:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ── Forms ─────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.field input,
.field textarea,
.field select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color .14s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.field input[readonly],
.field input[readonly]:focus {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  box-shadow: none;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

/* ── Misc ──────────────────────────────────── */
.empty {
  text-align: center;
  padding: 36px;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--orange-soft);
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 13px;
}

.pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Toasts ────────────────────────────────── */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 50;
}

.small { font-size: 12px; }

/* ── Responsive ────────────────────────────── */
@media (max-width: 1100px) {
  .grid.cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 840px) {
  .app { grid-template-columns: 64px 1fr; }
  .brand h2, .brand small, .nav button span, .side-footer span { display: none; }
  .nav button { text-align: center; padding: 12px 8px; justify-content: center; }
  .grid.cards { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-end; }
}
