/* ---------- Design tokens ---------- */
:root {
  /* Soft light content surface */
  --bg: oklch(97.5% 0.004 250);
  --surface: #ffffff;
  --surface-2: oklch(96.5% 0.006 250);
  --surface-3: oklch(94% 0.008 250);
  --border: oklch(92% 0.008 250);
  --border-strong: oklch(86% 0.012 250);
  --text: oklch(22% 0.02 250);
  --text-2: oklch(42% 0.02 250);
  --text-3: oklch(58% 0.015 250);
  --text-4: oklch(72% 0.012 250);

  /* Dark sidebar tokens (always dark, regardless of theme) */
  --sb-bg: oklch(22% 0.018 260);
  --sb-bg-2: oklch(26% 0.02 260);
  --sb-border: oklch(30% 0.02 260);
  --sb-text: oklch(82% 0.01 250);
  --sb-text-2: oklch(65% 0.014 250);
  --sb-text-3: oklch(50% 0.014 250);
  --sb-active-bg: linear-gradient(135deg, oklch(48% 0.18 264), oklch(52% 0.16 285));
  --sb-hover-bg: oklch(28% 0.022 260);

  /* Accents — CK Associates deep navy + leaf green */
  --primary: oklch(42% 0.18 268);
  --primary-hover: oklch(36% 0.19 268);
  --primary-soft: oklch(95% 0.04 268);
  --primary-soft-2: oklch(90% 0.06 268);
  --primary-grad: linear-gradient(135deg, oklch(45% 0.19 264) 0%, oklch(55% 0.17 290) 100%);
  --primary-grad-hover: linear-gradient(135deg, oklch(40% 0.2 264) 0%, oklch(50% 0.18 290) 100%);
  --primary-text: #fff;
  --brand-green: oklch(68% 0.18 142);
  --brand-green-soft: oklch(95% 0.06 142);

  --success: oklch(58% 0.15 155);
  --success-soft: oklch(95% 0.05 155);
  --warning: oklch(72% 0.15 70);
  --warning-soft: oklch(96% 0.06 80);
  --danger: oklch(58% 0.2 22);
  --danger-soft: oklch(95% 0.05 22);
  --info: oklch(62% 0.13 230);
  --info-soft: oklch(95% 0.04 230);
  --violet: oklch(58% 0.19 300);
  --violet-soft: oklch(95% 0.05 300);

  /* Radii — slightly larger for premium feel */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Soft elevated shadows */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .03);
  --shadow-md: 0 4px 12px -2px rgba(17, 24, 39, .06), 0 2px 6px rgba(17, 24, 39, .04);
  --shadow-lg: 0 24px 48px -16px rgba(17, 24, 39, .14), 0 8px 16px -8px rgba(17, 24, 39, .06);
  --shadow-card: 0 1px 3px rgba(17, 24, 39, .04), 0 4px 16px -8px rgba(17, 24, 39, .08);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: oklch(16% 0.012 250);
  --surface: oklch(20% 0.014 250);
  --surface-2: oklch(23% 0.014 250);
  --surface-3: oklch(26% 0.014 250);
  --border: oklch(28% 0.014 250);
  --border-strong: oklch(34% 0.018 250);
  --text: oklch(96% 0.005 240);
  --text-2: oklch(82% 0.01 240);
  --text-3: oklch(65% 0.012 240);
  --text-4: oklch(50% 0.012 240);
  --primary-soft: oklch(28% 0.06 264);
  --primary-soft-2: oklch(34% 0.09 264);
  --success-soft: oklch(28% 0.06 155);
  --warning-soft: oklch(30% 0.07 70);
  --danger-soft: oklch(30% 0.08 22);
  --info-soft: oklch(28% 0.06 230);
  --violet-soft: oklch(28% 0.06 300);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px -4px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 48px -16px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; }
.serif { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.app[data-collapsed="true"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
  color: var(--sb-text);
}
.sidebar ::-webkit-scrollbar-thumb { background: oklch(34% 0.02 260); border-color: var(--sb-bg); }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sb-border);
  min-height: var(--topbar-h);
}
.sidebar-brand .brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, oklch(58% 0.18 264), oklch(62% 0.16 285));
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 12px -4px oklch(45% 0.19 264 / 0.6);
}
.topbar-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  height: 44px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.topbar { position: relative; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--text);
  color: var(--surface);
  border-radius: 7px;
  display: grid; place-items: center;
  font-weight: 700;
  font-family: 'Fraunces', serif;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; color: var(--sb-text); }
.brand-sub { font-size: 11px; color: var(--sb-text-3); white-space: nowrap; }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 1px;
}
.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sb-text-3);
  padding: 16px 12px 8px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--sb-text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  user-select: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sb-hover-bg); color: var(--sb-text); }
.nav-item.active {
  background: var(--sb-active-bg);
  color: #fff;
  box-shadow: 0 4px 12px -4px oklch(45% 0.19 264 / 0.5);
}
.nav-item .nav-count {
  margin-left: auto;
  background: var(--sb-bg-2);
  color: var(--sb-text-2);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.nav-item.active .nav-count { background: rgba(255,255,255,.22); color: #fff; }
.nav-item:hover .nav-count { background: var(--sb-border); color: var(--sb-text); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-children { display: flex; flex-direction: column; gap: 1px; padding-left: 28px; margin-top: 2px; }
.nav-children .nav-item { padding: 6px 10px; font-size: 13px; font-weight: 450; }
.app[data-collapsed="true"] .brand-name,
.app[data-collapsed="true"] .brand-sub,
.app[data-collapsed="true"] .nav-item span:not(.nav-count),
.app[data-collapsed="true"] .nav-section-label,
.app[data-collapsed="true"] .nav-children { display: none; }
.app[data-collapsed="true"] .nav-item { justify-content: center; }

.sidebar-foot {
  border-top: 1px solid var(--sb-border);
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
  color: var(--sb-text);
}
.sidebar-foot .muted, .sidebar-foot .sub { color: var(--sb-text-3); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(64% 0.16 264), oklch(62% 0.14 300));
  color: white;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 9;
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.crumb { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.crumb b { color: var(--text); font-weight: 600; }
.crumb svg { color: var(--text-4); }
.topbar-search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  height: 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.topbar-search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 13px;
}
.topbar-search kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-3);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  display: grid; place-items: center;
  color: var(--text-2);
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* ---------- Page ---------- */
.page { padding: 24px 28px 64px; flex: 1; overflow-y: auto; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--primary-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px -4px oklch(45% 0.19 264 / 0.45), inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-primary:hover {
  background: var(--primary-grad-hover);
  box-shadow: 0 6px 16px -4px oklch(45% 0.19 264 / 0.55), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; gap: 4px; border-radius: 6px; }
.btn-lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn .ico { width: 15px; height: 15px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1080px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.kpi-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
}
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; font-family: 'Fraunces', serif; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  white-space: nowrap;
}
.tbl th:first-child { padding-left: 18px; }
.tbl th:last-child { padding-right: 18px; }
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl td:first-child { padding-left: 18px; }
.tbl td:last-child { padding-right: 18px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.row-hover:hover { background: var(--surface-2); cursor: pointer; }
.tbl tr.urgent { background: color-mix(in oklch, var(--danger-soft), transparent 50%); }
.tbl tr.urgent:hover { background: var(--danger-soft); }

.tbl-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tbl-search {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  min-width: 220px;
  flex: 1;
  max-width: 320px;
}
.tbl-search input { border: 0; background: transparent; outline: 0; flex: 1; font-size: 13px; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-3);
}
.page-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-grid; place-items: center;
  margin: 0 2px;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.badge .bd { width: 6px; height: 6px; border-radius: 50%; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.success .bd { background: var(--success); }
.badge.warning { background: var(--warning-soft); color: oklch(50% 0.14 70); }
.badge.warning .bd { background: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.danger .bd { background: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.info .bd { background: var(--info); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }
.badge.neutral .bd { background: var(--text-3); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.violet .bd { background: var(--violet); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.primary .bd { background: var(--primary); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 7px;
  background: transparent; border-top: 0; border-left: 0; border-right: 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .pill {
  background: var(--surface-3);
  font-size: 11px; padding: 0 6px; border-radius: 999px;
  color: var(--text-3); font-weight: 600;
}
.tab.active .pill { background: var(--primary-soft); color: var(--primary); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 13px;
  outline: 0;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 70px; font-family: inherit; }
.helper { font-size: 11.5px; color: var(--text-3); }

.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input, .radio input { accent-color: var(--primary); }
.toggle {
  width: 36px; height: 20px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background .15s;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: left .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 18px; }

.upload {
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.upload:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.upload .upload-title { color: var(--text); font-weight: 500; margin-top: 6px; font-size: 13px; }
.upload .upload-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}

/* ---------- Modal / drawer ---------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 50;
  backdrop-filter: blur(2px);
  animation: scrim-in .15s ease;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  width: min(720px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 96vw);
  background: var(--surface);
  z-index: 51;
  box-shadow: -20px 0 60px -20px rgba(15,23,42,.25);
  display: flex; flex-direction: column;
  animation: drawer-in .22s cubic-bezier(.2,.8,.2,1);
  border-left: 1px solid var(--border);
}
@keyframes drawer-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Misc ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.cell-name {
  display: flex; align-items: center; gap: 10px;
}
.cell-name b { font-weight: 500; color: var(--text); }
.cell-name .sub { font-size: 11.5px; color: var(--text-3); display: block; }

.placeholder-img {
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in oklch, var(--text-4), transparent 80%) 8px 9px),
    var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Notif menu */
.menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  min-width: 280px;
  overflow: hidden;
}
.menu-item {
  padding: 10px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item:last-child { border-bottom: 0; }

/* Editor (rich text mock) */
.editor {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.editor-toolbar {
  display: flex; gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.editor-toolbar button {
  width: 28px; height: 28px;
  border: 0; border-radius: 5px;
  background: transparent;
  display: grid; place-items: center;
  color: var(--text-2);
  font-size: 12px;
}
.editor-toolbar button:hover { background: var(--surface-3); color: var(--text); }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 0 4px; }
.editor-body {
  padding: 14px 16px;
  min-height: 220px;
  font-size: 13.5px;
  line-height: 1.6;
  outline: 0;
}
.editor-body h2 { font-size: 18px; margin: 8px 0; font-weight: 600; }
.editor-body p { margin: 4px 0 10px; }

/* progress */
.progress {
  height: 6px; background: var(--surface-3); border-radius: 999px;
  overflow: hidden;
}
.progress > div {
  height: 100%; background: var(--primary);
  border-radius: 999px;
}

/* Login */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-shell::before {
  content: '';
  position: absolute;
  inset: -100px;
  background:
    radial-gradient(60% 50% at 30% 20%, color-mix(in oklch, var(--primary-soft), transparent 40%), transparent 70%),
    radial-gradient(50% 40% at 80% 80%, color-mix(in oklch, var(--violet-soft), transparent 40%), transparent 70%);
  pointer-events: none;
}
.login-card {
  width: min(440px, 100%);
  position: relative;
  z-index: 1;
}

/* Misc utility */
.hover-actions { opacity: 0; transition: opacity .12s; }
.tbl tr:hover .hover-actions { opacity: 1; }

.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 0 12px;
}
.section-title-row h2 {
  font-size: 15px; font-weight: 600; margin: 0;
  letter-spacing: -0.005em;
}

/* Sparkline */
.sparkline { display: block; }

/* Stat group */
.stat-group { display: flex; gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: 11.5px; color: var(--text-3); }
.stat .value { font-size: 18px; font-weight: 600; font-family: 'Fraunces', serif; }

/* ============================================================
   MOBILE-FIRST RESPONSIVE LAYOUT
   Breakpoints: ≤480px phone | ≤768px large phone | ≤1024px tablet
   ============================================================ */

/* ---- CSS tokens ---- */
:root {
  --bottom-nav-h: 60px;
}

/* ---- App grid: sidebar exits flow on tablet/mobile ---- */
@media (max-width: 1024px) {
  .app,
  .app[data-collapsed="true"] {
    grid-template-columns: 1fr;
  }
}

/* ---- Sidebar: off-canvas overlay ---- */
.sidebar {
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px -8px rgba(15, 23, 42, 0.35);
  }
}

/* ---- Sidebar overlay backdrop ---- */
.sidebar-overlay {
  display: none;
}
@media (max-width: 1024px) {
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
    animation: scrim-in 0.15s ease;
  }
  @keyframes scrim-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* ---- Topbar: mobile ---- */
.topbar-user-name {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
@media (max-width: 768px) {
  .topbar {
    height: 56px;
    padding: 0 14px;
    gap: 10px;
  }
  .topbar-search { display: none; }
  .crumb { display: none; }
  .topbar-user-name { display: none; }
}

/* ---- Mobile brand in topbar (hidden on desktop) ---- */
.topbar-mobile-brand {
  display: none;
}
@media (max-width: 1024px) {
  .topbar-mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
  }
}

/* ---- Touch targets ---- */
@media (max-width: 768px) {
  .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  .btn {
    height: 40px;
    padding: 0 14px;
    font-size: 13.5px;
  }
  .btn-sm {
    height: 34px;
    padding: 0 11px;
  }
}

/* ---- Page padding: clear fixed bottom nav ---- */
@media (max-width: 768px) {
  .page {
    padding: 16px 16px calc(var(--bottom-nav-h) + 40px);
  }
  /* ensure bottom nav is always on top of all page content */
  .bottom-nav {
    z-index: 200;
  }
}
@media (max-width: 480px) {
  .page {
    padding: 12px 12px calc(var(--bottom-nav-h) + 36px);
  }
}

/* ---- PageHeader: stack on mobile ---- */
@media (max-width: 768px) {
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-title { font-size: 18px; }
  .page-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 480px) {
  .page-title { font-size: 16px; }
}

/* ---- KPI cards: tighten on small phones, disable hover transform ---- */
@media (max-width: 768px) {
  .kpi:hover { transform: none; box-shadow: none; }
}
@media (max-width: 480px) {
  .kpi-grid { gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 22px; }
}

/* ---- Dashboard responsive grids ---- */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 1024px) {
  .dash-charts-row { grid-template-columns: 1fr; }
}

.dash-tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 1024px) {
  .dash-tables-row { grid-template-columns: 1fr; }
}

.dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 1024px) {
  .dash-bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dash-desktop-only { display: none; }
}

.policy-mix-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
}
@media (max-width: 480px) {
  .policy-mix-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

/* ---- Tables: smooth scroll on mobile ---- */
@media (max-width: 768px) {
  .tbl-wrap {
    -webkit-overflow-scrolling: touch;
  }
  .tbl th, .tbl td {
    padding: 10px 10px;
    white-space: nowrap;
  }
}

/* ---- Form grid collapse ---- */
@media (max-width: 480px) {
  .field-row,
  .field-row-3 {
    grid-template-columns: 1fr;
  }
}

/* ---- Modal: bottom sheet on small phones ---- */
@media (max-width: 480px) {
  .modal-wrap {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--r-xl);
    border-top-right-radius: var(--r-xl);
    animation: modal-sheet-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes modal-sheet-in {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}

/* ---- Toast container ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (max-width: 768px) {
  .toast-container {
    bottom: calc(var(--bottom-nav-h) + 12px);
    right: 12px;
    left: 12px;
  }
}

/* ---- Pull-to-refresh hint (cosmetic) ---- */
.pull-refresh-hint {
  display: none;
}
@media (max-width: 768px) {
  .pull-refresh-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 4px;
    color: var(--text-4);
    font-size: 11px;
    letter-spacing: 0.02em;
  }
}

/* ---- Bottom navigation bar ---- */
.bottom-nav {
  display: none;
}
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 20px -8px rgba(15, 23, 42, 0.10);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: color 0.12s, background 0.12s;
    padding: 6px 4px;
    position: relative;
    font-family: inherit;
  }
  .bottom-nav-item:hover {
    color: var(--text);
    background: var(--surface-2);
  }
  .bottom-nav-item.active {
    color: var(--primary);
  }
  .bottom-nav-indicator {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
  }
  .bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
  }
}

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */

.install-banner {
  display: none;
}
@media (max-width: 768px) {
  .install-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 8px);
    left: 10px;
    right: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    box-shadow: var(--shadow-lg);
    z-index: 190;
    animation: banner-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes banner-up {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .install-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .install-banner-text {
    flex: 1;
    min-width: 0;
  }
  .install-banner-title {
    font-size: 13px;
    font-weight: 600;
  }
  .install-banner-sub {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 1px;
  }
  .install-banner-close {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }
}

/* ============================================================
   LOGIN PAGE RESPONSIVE
   ============================================================ */

.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 520px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo img {
  display: block;
  margin: 0 auto;
  max-height: 240px;
  width: 100%;
  max-width: 460px;
  height: auto;
  object-fit: contain;
}

.login-header {
  text-align: center;
  margin-bottom: 4px;
}

.login-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  font-family: 'Fraunces', serif;
  letter-spacing: -0.015em;
}

.login-header div {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 6px;
}

.login-btn {
  justify-content: center;
  margin-top: 4px;
}

.login-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 4px;
}

.login-copyright {
  text-align: center;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* ---- Login: mobile responsive ---- */
@media (max-width: 480px) {
  .login-card {
    padding: 0;
  }
  .login-form {
    padding: 24px;
    gap: 12px;
  }
  .login-logo {
    margin-bottom: 16px;
  }
  .login-logo img {
    max-height: 160px;
  }
  .login-header h1 {
    font-size: 18px;
  }
  .login-header div {
    font-size: 12px;
  }
  .login-footer {
    font-size: 10px;
  }
  .login-copyright {
    margin-top: 12px;
    font-size: 10px;
    padding: 0 16px;
  }
}

/* ============================================================
   FORM PAGE (Mobile full-page forms)
   ============================================================ */

.form-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  margin: -12px -12px 16px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.form-page-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.form-page-steps {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
}

.form-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.form-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.form-page-content {
  min-height: 200px;
  margin-bottom: 16px;
}

.form-page-footer {
  display: flex;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
  z-index: 10;
  margin: 0 -12px -12px;
  padding: 14px 16px;
}

.form-page-footer .btn {
  flex: 1;
}

.form-page-footer .btn:first-child {
  flex: 0.8;
}
