/* =========================================================================
   KAFIS design system
   Tokens first, then base elements, then components. The public site (site.css)
   and the application share everything in this file.
   ========================================================================= */

@font-face { font-family: "Hanken Grotesk"; src: url("../fonts/hanken-grotesk.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* Kano Green: identity, navigation, primary actions */
  --green-950: #062a1c; --green-900: #0a3b27; --green-800: #0d4c32; --green-700: #0f6b3c; --green-600: #17854c;
  --green-500: #2a9d5f; --green-300: #8fcfa8; --green-200: #bfe3cc; --green-100: #dff1e5; --green-50: #f0f8f2;
  /* Kano Red: accent only (selected state, alerts, the location point) */
  --red-700: #a40e26; --red-600: #c8102e; --red-200: #f3b9c2; --red-100: #fbe1e5; --red-50: #fdf1f3;
  /* Neutrals, tinted slightly green so they sit with the brand */
  --ink: #18211c; --ink-2: #39453f; --muted: #66726b; --faint: #8b958f;
  --line: #dde2dd; --line-2: #eaeeea; --bg: #f4f6f3; --surface: #ffffff; --surface-2: #f9faf8;
  /* Status */
  --amber-700: #8a5300; --amber-100: #fdeecb; --amber-50: #fff8e8;
  --blue-700: #1a5594; --blue-100: #dbe9f7; --blue-50: #eef5fc;

  --primary: var(--green-700); --primary-hover: var(--green-800); --on-primary: #fff;
  --accent: var(--red-600);
  --focus: 0 0 0 3px rgba(15, 107, 60, .28);

  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;

  --r-sm: 3px; --r: 6px; --r-lg: 8px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  --shadow-1: 0 1px 2px rgba(16, 32, 24, .06);
  --shadow-2: 0 4px 14px rgba(16, 32, 24, .10);
  --shadow-3: 0 16px 40px rgba(16, 32, 24, .18);
  --sidebar-w: 248px; --sidebar-w-min: 64px; --topbar-h: 58px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Data visualisation: one green ramp plus the red accent and two neutrals */
  --viz-1: #0f6b3c; --viz-2: #2a9d5f; --viz-3: #8fcfa8; --viz-4: #c8102e; --viz-5: #b7892f; --viz-6: #5b6b7a; --viz-7: #cfd8d2;
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #e8eee9; --ink-2: #c5d0c8; --muted: #97a59c; --faint: #738279;
  --line: #26342c; --line-2: #1e2a23; --bg: #0c1511; --surface: #121d17; --surface-2: #16231c;
  --green-50: #12261b; --green-100: #173323; --green-200: #1f4a31;
  --red-50: #2a1418; --red-100: #3a181e; --amber-50: #2a2212; --amber-100: #3a2f16; --blue-50: #13212f; --blue-100: #1a2f45;
  --primary: #2a9d5f; --primary-hover: #35b06d; --amber-700: #e8b65a; --blue-700: #8ebdf0; --red-700: #f08a9a; --green-700: #5fc98a; --green-800: #7ad69e;
  --viz-1: #3fb573; --viz-2: #6fd09a; --viz-3: #2c6b48; --viz-7: #2b3a31;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 14px rgba(0, 0, 0, .45); --shadow-3: 0 16px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: var(--fs-md); font-weight: 650; line-height: 1.3; }
h3 { font-size: var(--fs-base); font-weight: 650; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.icon { flex: none; vertical-align: -3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r); z-index: 1000; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: var(--fs-base); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn-primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); border-color: var(--green-800); color: #fff; }
[data-theme="dark"] .btn-primary { background: #1c8a51; border-color: #1c8a51; } [data-theme="dark"] .btn-primary:hover { background: #22a05e; border-color: #22a05e; }
.btn-danger { background: var(--surface); border-color: var(--red-200); color: var(--red-700); }
.btn-danger:hover { background: var(--red-50); border-color: var(--red-600); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--line-2); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-md); }
.btn-icon { width: 36px; padding: 0; } .btn-icon.btn-sm { width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--red-600); }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 92px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2366726b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.select[multiple] { height: auto; min-height: 120px; padding: 6px; background-image: none; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-600); box-shadow: var(--focus); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red-600); }
.error { font-size: var(--fs-xs); color: var(--red-700); font-weight: 600; }
.input-sm, .select.input-sm { height: 32px; font-size: var(--fs-sm); }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: var(--fs-base); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--green-700); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.form-section { padding: var(--s-6); border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s-8); }
.form-section:last-of-type { border-bottom: 0; }
.form-section > header p { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 14px var(--s-5); border-bottom: 1px solid var(--line-2); min-height: 54px; flex-wrap: wrap; }
.panel-head h2 small, .panel-head .sub { display: block; font-weight: 400; font-size: var(--fs-sm); color: var(--muted); margin-top: 1px; }
.panel-body { padding: var(--s-5); }
.panel-foot { padding: 10px var(--s-5); border-top: 1px solid var(--line-2); font-size: var(--fs-sm); color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--s-5); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); } .g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.spacer { flex: 1; }

/* Stat band: one surface divided by rules, instead of a wall of separate cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stat { padding: var(--s-4) var(--s-5); border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); margin: 0 -1px -1px 0; min-width: 0; }
.stat-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.625rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--fs-base); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-note { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.stat-accent { box-shadow: inset 3px 0 0 var(--green-700); }

.meter { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--green-600); border-radius: 3px; }
.meter.red > span { background: var(--red-600); } .meter.amber > span { background: #c98a14; }
.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-list li { list-style: none; } .bar-list { margin: 0; padding: 0; }
.bar-row { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); margin-bottom: 4px; }
.bar-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: var(--fs-xs); font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-verified, .badge-active, .badge-completed, .badge-yes { background: var(--green-100); color: var(--green-800); }
.badge-pending, .badge-enrolled, .badge-planned, .badge-processing { background: var(--amber-100); color: var(--amber-700); }
.badge-rejected, .badge-failed, .badge-removed { background: var(--red-100); color: var(--red-700); }
.badge-suspended, .badge-no { background: var(--line-2); color: var(--ink-2); }
.badge-info { background: var(--blue-100); color: var(--blue-700); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px var(--s-4); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px var(--s-4); border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: var(--s-5); } .table th:last-child, .table td:last-child { padding-right: var(--s-5); }
.table .right { text-align: right; }
.table-dense td { padding-top: 7px; padding-bottom: 7px; }
.cell-main { font-weight: 600; color: var(--ink); display: block; } a.cell-main:hover { color: var(--primary); }
.cell-sub { font-size: var(--fs-sm); color: var(--muted); display: block; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green-100); color: var(--green-800); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: var(--fs-sm); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.5rem; border-radius: var(--r-lg); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.empty { padding: var(--s-12) var(--s-5); text-align: center; color: var(--muted); }
.empty .icon { color: var(--faint); margin-bottom: 10px; } .empty h3 { color: var(--ink); margin-bottom: 4px; font-size: var(--fs-md); } .empty .btn { margin-top: var(--s-4); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px var(--s-5); border-bottom: 1px solid var(--line-2); }
.filters .input, .filters .select { width: auto; min-width: 140px; height: 34px; font-size: var(--fs-sm); }
.filters .search { flex: 1 1 220px; position: relative; } .filters .search .input { width: 100%; padding-left: 32px; } .filters .search .icon { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.segments { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.segments a { padding: 6px 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); border-right: 1px solid var(--line); display: flex; gap: 6px; align-items: center; }
.segments a:last-child { border-right: 0; } .segments a:hover { background: var(--surface-2); text-decoration: none; }
.segments a.active { background: var(--green-50); color: var(--green-800); box-shadow: inset 0 -2px 0 var(--green-700); }
.segments .count { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

.pagination { display: flex; gap: 4px; align-items: center; } .pagination a, .pagination span { min-width: 30px; height: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.pagination a:hover { background: var(--line-2); text-decoration: none; } .pagination .current { background: var(--green-700); color: #fff; } .pagination .disabled { color: var(--faint); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 13px 12px 11px; font-weight: 600; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--ink); text-decoration: none; } .tab[aria-selected="true"], .tab.active { color: var(--green-700); border-bottom-color: var(--red-600); }
.tab .count { background: var(--line-2); border-radius: 9px; padding: 0 7px; font-size: var(--fs-xs); color: var(--ink-2); }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s-4) var(--s-5); }
.dl dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; } .dl dd { margin-top: 2px; font-weight: 500; overflow-wrap: anywhere; }
.dl dd.empty-value { color: var(--muted); font-weight: 400; font-style: italic; }

/* ---------- Alerts and toasts ---------- */
.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-base); align-items: flex-start; }
.alert .icon { margin-top: 1px; } .alert-success { background: var(--green-50); border-color: var(--green-200); color: var(--green-800); } .alert-error { background: var(--red-50); border-color: var(--red-200); color: var(--red-700); }
.alert-warning { background: var(--amber-50); border-color: var(--amber-100); color: var(--amber-700); } .alert-info { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }
.alert ul { margin: 4px 0 0; padding-left: 18px; } .alert strong { font-weight: 650; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 900; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: var(--r); box-shadow: var(--shadow-2); font-size: var(--fs-base); display: flex; gap: 10px; align-items: flex-start; animation: rise .25s var(--ease); }
.toast.error { background: var(--red-700); color: #fff; } [data-theme="dark"] .toast { background: #e8eee9; color: #121d17; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.code-once { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-md); background: var(--surface); border: 1px dashed var(--amber-700); padding: 4px 10px; border-radius: var(--r-sm); user-select: all; }

/* ---------- Dialog ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-3); background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.modal::backdrop { background: rgba(8, 20, 14, .55); }
.modal-head { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; } .modal-body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.modal-foot { padding: 12px var(--s-5); border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 6px; z-index: 300; }
.menu a, .menu button { display: flex; width: 100%; gap: 9px; align-items: center; padding: 8px 10px; border-radius: var(--r); border: 0; background: none; color: var(--ink); font-size: var(--fs-base); text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--line-2); text-decoration: none; } .menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 6px 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; } .menu-head b { display: block; }
.menu-wide { width: min(360px, calc(100vw - 24px)); } .menu-empty { padding: 18px 12px; color: var(--muted); text-align: center; font-size: var(--fs-sm); }

/* =========================================================================
   Application shell
   ========================================================================= */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s var(--ease); }
.shell.collapsed { grid-template-columns: var(--sidebar-w-min) minmax(0, 1fr); }

.sidebar { background: var(--green-950); color: #cfe0d6; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 400; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); color: #fff; flex: none; }
.brand:hover { text-decoration: none; } .brand-name { font-weight: 700; font-size: 1.0625rem; letter-spacing: .04em; line-height: 1.1; } .brand-sub { display: block; font-size: .6875rem; font-weight: 400; letter-spacing: 0; color: #9db8a8; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent; }
.nav-label { font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #7f9b8b; padding: 14px 10px 6px; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r); color: #cfe0d6; font-weight: 500; white-space: nowrap; position: relative; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .11); color: #fff; font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: var(--red-600); }
.nav a .icon { color: #9db8a8; } .nav a.active .icon, .nav a:hover .icon { color: #fff; }
.sidebar-foot { padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: var(--fs-xs); color: #7f9b8b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell.collapsed .brand-text, .shell.collapsed .nav-label, .shell.collapsed .nav a span, .shell.collapsed .sidebar-foot { display: none; }
.shell.collapsed .nav a { justify-content: center; padding: 0; } .shell.collapsed .brand { justify-content: center; padding: 0; } .shell.collapsed .nav-group + .nav-group { border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 8px; padding-top: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-5); position: sticky; top: 0; z-index: 350; }
.gsearch { flex: 1; max-width: 460px; position: relative; }
.gsearch .input { padding-left: 34px; height: 36px; background: var(--bg); border-color: transparent; } .gsearch .input:focus { background: var(--surface); }
.gsearch > .icon { position: absolute; left: 11px; top: 9px; color: var(--muted); pointer-events: none; }
.gsearch kbd { position: absolute; right: 9px; top: 8px; font: inherit; font-size: var(--fs-xs); color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 5px; background: var(--surface); }
.gresults { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 6px; max-height: 70vh; overflow: auto; z-index: 360; }
.gresults h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; margin: 0; }
.gresults a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: var(--r); color: var(--ink); } .gresults a:hover, .gresults a.focus { background: var(--green-50); text-decoration: none; } .gresults a span:last-child { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red-600); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.userchip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 20px; border: 0; background: none; cursor: pointer; } .userchip:hover { background: var(--line-2); }
.userchip .who { text-align: left; line-height: 1.2; } .userchip .who b { display: block; font-size: var(--fs-sm); } .userchip .who span { font-size: var(--fs-xs); color: var(--muted); }

.content { padding: var(--s-6); max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; gap: var(--s-5); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; } .crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--primary); } .crumbs .icon { opacity: .6; }
.page-head p { color: var(--muted); margin-top: 2px; max-width: 70ch; }
.footer-note { padding: var(--s-4) var(--s-6); font-size: var(--fs-xs); color: var(--muted); display: flex; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }

.bottom-nav { display: none; }
.scrim { display: none; }

/* ---------- Charts ---------- */
.chart { position: relative; height: 260px; } .chart-sm { height: 200px; } .chart-lg { height: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--ink-2); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------- Maps ---------- */
.map { width: 100%; height: 420px; background: var(--bg); border-radius: var(--r-lg); z-index: 0; }
.map-frame { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.leaflet-container { font-family: var(--font); font-size: var(--fs-sm); background: #e9eee9; }
[data-theme="dark"] .leaflet-container { background: #0f1814; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: var(--shadow-1) !important; border-radius: var(--r) !important; overflow: hidden; }
.leaflet-bar a { color: var(--ink) !important; background: var(--surface) !important; border-bottom-color: var(--line-2) !important; }
.leaflet-tooltip.k-tip { background: var(--ink); color: #fff; border: 0; border-radius: var(--r); padding: 6px 9px; box-shadow: var(--shadow-2); font-size: var(--fs-sm); } .leaflet-tooltip.k-tip::before { display: none; }
[data-theme="dark"] .leaflet-tooltip.k-tip { background: #e8eee9; color: #121d17; }
.leaflet-tooltip.k-label { background: none; border: 0; box-shadow: none; font-weight: 650; font-size: 11px; color: var(--green-950); text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; padding: 0; } .leaflet-tooltip.k-label::before { display: none; }
.k-cluster { background: rgba(15, 107, 60, .9); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: var(--shadow-1); }
.map-legend { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; box-shadow: var(--shadow-1); font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.6; }
.map-legend b { display: block; margin-bottom: 3px; color: var(--ink); } .map-legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .12); }
.kano-svg path { fill: var(--green-100); stroke: var(--surface); stroke-width: 1; transition: fill .15s; } .kano-svg path:hover { fill: var(--green-300); }

/* GIS workspace: the map owns the page */
.gis { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); background: var(--surface); }
.gis-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.gis-side section { padding: 14px var(--s-4); border-bottom: 1px solid var(--line-2); } .gis-side h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.gis-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.gis-map { position: relative; min-width: 0; } .gis-map .map { height: 100%; border-radius: 0; }
.gis-status { position: absolute; left: 12px; bottom: 12px; z-index: 500; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; font-size: var(--fs-xs); box-shadow: var(--shadow-1); color: var(--ink-2); max-width: calc(100% - 24px); }
.gis-info { position: absolute; right: 12px; top: 12px; z-index: 500; width: min(320px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); max-height: calc(100% - 24px); overflow: auto; }
.gis-info header { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; } .gis-info .body { padding: 12px 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: var(--fs-sm); } .kv dt { color: var(--muted); } .kv dd { font-weight: 600; text-align: right; }
.layer-toggle { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; font-size: var(--fs-base); cursor: pointer; } .layer-toggle input { accent-color: var(--green-700); width: 16px; height: 16px; }
.result-list { list-style: none; margin: 8px 0 0; padding: 0; } .result-list button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 7px 8px; border: 0; background: none; border-radius: var(--r); cursor: pointer; text-align: left; font-size: var(--fs-sm); } .result-list button:hover { background: var(--green-50); } .result-list .tag { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.area-readout { display: flex; gap: var(--s-5); padding: 12px var(--s-5); background: var(--green-50); border-bottom: 1px solid var(--green-200); align-items: baseline; flex-wrap: wrap; } .area-readout b { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; color: var(--green-800); }

/* Executive command centre */
.cc-head { background: var(--green-950); color: #fff; border-radius: var(--r-lg); padding: var(--s-5) var(--s-6); display: flex; justify-content: space-between; gap: var(--s-5); align-items: center; flex-wrap: wrap; }
.cc-head p { color: #a9c3b4; margin-top: 2px; } .cc-head .live { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: #cfe0d6; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #5fd08e; box-shadow: 0 0 0 0 rgba(95, 208, 142, .6); animation: pulse 2s infinite; } @keyframes pulse { to { box-shadow: 0 0 0 9px rgba(95, 208, 142, 0); } }
.funnel { display: flex; flex-direction: column; gap: 12px; } .funnel-step { display: grid; grid-template-columns: 150px 1fr 90px; gap: 12px; align-items: center; font-size: var(--fs-sm); } .funnel-step .meter { height: 18px; border-radius: var(--r-sm); } .funnel-step .meter > span { border-radius: var(--r-sm); } .funnel-step b { text-align: right; font-variant-numeric: tabular-nums; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); }
.auth-art { background: var(--green-950); color: #fff; padding: var(--s-12); display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px); background-size: 44px 44px; }
.auth-art h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.75rem, 3vw, 2.5rem); line-height: 1.15; letter-spacing: -.01em; max-width: 16ch; }
.auth-art p { color: #a9c3b4; max-width: 44ch; margin-top: var(--s-4); font-size: var(--fs-md); }
.auth-art .kano-svg { position: absolute; right: -6%; bottom: -8%; width: 62%; opacity: .9; } .auth-art .kano-svg path { fill: rgba(255, 255, 255, .06); stroke: rgba(255, 255, 255, .22); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: var(--s-8); } .auth-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: var(--s-4); }

/* Print */
.print-sheet { max-width: 800px; margin: 24px auto; background: #fff; color: #18211c; padding: 40px; border: 1px solid var(--line); }
@media print { .no-print, .sidebar, .topbar, .bottom-nav, .toasts { display: none !important; } body { background: #fff; } .print-sheet { border: 0; margin: 0; padding: 0; max-width: none; } .shell { display: block; } .content { padding: 0; } }

/* =========================================================================
   Responsive: tablet and phone get their own navigation, not a squeezed desktop
   ========================================================================= */
@media (max-width: 1180px) { .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: minmax(0, 1fr); } .form-section { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); } }
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .22s var(--ease); box-shadow: var(--shadow-3); }
  .shell.collapsed .brand-text, .shell.collapsed .nav-label, .shell.collapsed .nav a span, .shell.collapsed .sidebar-foot { display: revert; } .shell.collapsed .nav a { justify-content: flex-start; padding: 0 10px; } .shell.collapsed .brand { justify-content: flex-start; padding: 0 14px; }
  .shell.nav-open .sidebar { transform: none; } .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 20, 14, .5); z-index: 390; }
  .nav a { height: 44px; }
  .topbar { padding: 0 var(--s-3); } .gsearch kbd, .userchip .who, .hide-sm { display: none; }
  .content { padding: var(--s-4) var(--s-3) 84px; gap: var(--s-4); }
  .bottom-nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; height: 60px; background: var(--surface); border-top: 1px solid var(--line); z-index: 380; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); border: 0; background: none; } .bottom-nav a.active { color: var(--green-700); } .bottom-nav a:hover { text-decoration: none; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
  .form-section { padding: var(--s-4); } .form-actions { position: sticky; bottom: 60px; z-index: 50; padding: 10px var(--s-4); } .form-actions .btn { flex: 1; height: 44px; }
  .input, .select { height: 44px; font-size: 1rem; } .textarea { font-size: 1rem; } .filters .input, .filters .select { height: 40px; flex: 1 1 140px; }
  .btn { height: 40px; } .btn-sm { height: 34px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat { padding: var(--s-3) var(--s-4); } .stat-value { font-size: 1.375rem; }
  .page-head { align-items: flex-start; } .page-head .btn-group { width: 100%; } .page-head .btn-group .btn { flex: 1; }
  /* Tables become record lists */
  .table-stack thead { display: none; } .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px var(--s-4); border-bottom: 1px solid var(--line-2); } .table-stack td { padding: 2px 0 !important; border: 0; text-align: left !important; }
  .table-stack td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 108px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .table-stack td.cell-actions { padding-top: 8px !important; }
  .gis { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 60px); position: relative; }
  .gis-side { position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; max-height: 62%; border-right: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-3); transform: translateY(calc(100% - 52px)); transition: transform .25s var(--ease); }
  .gis-side.open { transform: none; } .gis-handle { display: flex !important; } .gis-info { left: 12px; right: 12px; width: auto; top: 12px; max-height: 45%; } .gis-status { bottom: 62px; }
  .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { padding: var(--s-6); min-height: 220px; } .auth-art .kano-svg { width: 46%; right: -4%; bottom: -20%; } .auth-art p { display: none; }
  .funnel-step { grid-template-columns: 110px 1fr 70px; }
  .footer-note { padding-bottom: 76px; }
}
.gis-handle { display: none; height: 52px; align-items: center; justify-content: space-between; padding: 0 var(--s-4); font-weight: 650; border: 0; background: none; width: 100%; cursor: pointer; flex: none; }
.gis-handle::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); }
