/* ===========================================================================
   Kolibri — static demo build.
   A faithful reconstruction of the product's own design system: the token set,
   the Emerald card surface, the field/button/badge/table primitives. Ported by
   hand from the application's generated tokens so the demo re-skins the same
   way the product does — change a token here, every screen follows.

   No build step and no external requests: the typeface is self-hosted and every
   graphic is inline SVG, so the folder renders identically offline.
   =========================================================================== */

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/public-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ─────────────────────────────── design tokens ─────────────────────────────
   Lifted verbatim from the product. Chart colours are a fixed five-slot family
   assigned by entity and never cycled; --primary is for actions only and must
   never fill a data mark. */
:root {
  --background: #f5f5f6;
  --foreground: #333537;
  --card: #ffffff;
  --card-foreground: #333537;
  --popover: #ffffff;
  --primary: #047061;
  --primary-foreground: #ffffff;
  --primary-hover: #03574b;
  --primary-active: #043f36;
  --feature: #16a28e;
  --feature-deep: #047061;
  --secondary: #eaebed;
  --muted: #eaebed;
  --muted-foreground: #5e6064;
  --accent: #eaebed;
  --border: #d7d9dc;
  --input: #d7d9dc;
  --ring: #047061;
  --success: #28c76f;
  --warning: #ff9f43;
  --destructive: #ea5455;
  --info: #00cfe8;
  --chart-1: #129b88;
  --chart-2: #8a74d2;
  --chart-3: #b88f1b;
  --chart-4: #0a9edc;
  --chart-5: #e666b4;
  --radius: 10px;
  --radius-card: 16px;
  --shadow-card: 0 2px 8px -2px rgba(51, 53, 55, .12), 0 1px 2px rgba(51, 53, 55, .06);
  --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .28);
  --sidebar-w: 260px;
}

.dark {
  --background: #1f2022;
  --foreground: #f5f5f6;
  --card: #333537;
  --card-foreground: #f5f5f6;
  --popover: #333537;
  --primary: #40bda7;
  --primary-foreground: #1f2022;
  --primary-hover: #7bd3c1;
  --primary-active: #ace8da;
  --feature: #40bda7;
  --feature-deep: #047061;
  --secondary: #484a4e;
  --muted: #484a4e;
  --muted-foreground: #bec0c4;
  --accent: #484a4e;
  --border: #484a4e;
  --input: #484a4e;
  --ring: #40bda7;
  --chart-3: #b98e0b;
  --chart-4: #109fdd;
  --chart-5: #e25baf;
  --shadow-card: 0 2px 10px -2px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 18px 44px -12px rgba(0, 0, 0, .6);
}

/* Tinted overlays recur everywhere; naming them keeps the mixes consistent. */
:root {
  --tint-4: color-mix(in srgb, var(--foreground) 4%, transparent);
  --tint-5: color-mix(in srgb, var(--foreground) 5%, transparent);
  --tint-6: color-mix(in srgb, var(--foreground) 6%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.tnum { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────────────────────────────── primitives ───────────────────────────── */

/* The Emerald signature: floating, borderless, separated by shadow not a line. */
.card {
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.card.flush { padding: 0; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.inset { padding: 20px 20px 0; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-head .sub { margin-top: 2px; font-size: 13px; color: var(--muted-foreground); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { margin-top: 4px; font-size: 13.5px; color: var(--muted-foreground); }

.fld {
  height: 38px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: var(--card);
  padding-inline: 12px;
  font-size: 13.5px;
  color: var(--foreground);
  transition: border-color 120ms, box-shadow 120ms;
}
.fld::placeholder { color: var(--muted-foreground); }
.fld:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 30%, transparent);
}
select.fld { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding-inline: 14px;
  border: 0; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { border: 1px solid var(--border); color: var(--foreground); background: transparent; }
.btn-outline:hover:not(:disabled) { background: var(--tint-6); }
.btn-ghost { color: var(--muted-foreground); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--tint-6); color: var(--foreground); }
.btn-sm { height: 32px; padding-inline: 11px; font-size: 12.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 9999px; padding: 1px 8px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: color-mix(in srgb, var(--tone) 72%, var(--foreground));
}
.badge.neutral { --tone: var(--muted-foreground); }
.badge.primary { --tone: var(--primary); }
.badge.success { --tone: var(--success); }
.badge.warning { --tone: var(--warning); }
.badge.error   { --tone: var(--destructive); }
.badge.info    { --tone: var(--info); }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 9999px;
  background: var(--feature-deep); color: #fff;
  font-size: 12px; font-weight: 600;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }

/* ─────────────────────────────────── tables ─────────────────────────────── */
.tw { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl thead tr { background: var(--tint-4); }
table.tbl th {
  padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground);
  white-space: nowrap;
}
table.tbl th:first-child, table.tbl td:first-child { padding-left: 20px; }
table.tbl th:last-child,  table.tbl td:last-child  { padding-right: 20px; }
table.tbl td { padding: 12px; border-top: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr { transition: background-color 120ms; }
table.tbl tbody tr:hover { background: var(--tint-4); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim { color: var(--muted-foreground); }
.strong { font-weight: 600; }

/* Sortable headers get an affordance and a live direction marker. */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--foreground); }
th.sortable::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: 10px; }
th.sortable[data-dir="asc"]::after  { content: "↑"; opacity: 1; color: var(--primary); }
th.sortable[data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--primary); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 24px; text-align: center; }
.empty .t { font-size: 15px; font-weight: 600; }
.empty .h { max-width: 34rem; font-size: 13px; color: var(--muted-foreground); }
.empty .ico { color: var(--muted-foreground); margin-bottom: 4px; }

/* ───────────────────────────────── stat tiles ───────────────────────────── */
.stat { display: flex; flex-direction: column; }
.stat .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat .chip {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent-c) 14%, transparent);
  color: var(--accent-c);
}
.stat .v { margin-top: 12px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--muted-foreground); }
.stat .h { margin-top: 4px; font-size: 12px; color: var(--muted-foreground); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--destructive); }
.delta.flat { color: var(--muted-foreground); }

/* ────────────────────────────────── layout ──────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; z-index: 30; align-self: flex-start;
  flex: none; width: var(--sidebar-w); height: 100vh;
  background: var(--card);
  transition: width 200ms ease;
}
.sidebar-inner { position: relative; height: 100%; }
.sidebar-scroll { display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: 64px; flex: none; padding-inline: 16px; }
.sidebar-brand .word { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: 8px 12px; }
.nav-group + .nav-group { margin-top: 24px; }
.nav-group .glabel {
  padding: 0 12px 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground);
}
.nav-group .grule { height: 1px; margin: 8px 12px; background: var(--border); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  height: 40px; padding-inline: 11px; margin-bottom: 4px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500; color: var(--muted-foreground);
  transition: background-color 120ms, color 120ms;
}
.nav-item:hover { background: var(--tint-5); color: var(--foreground); }
.nav-item[aria-current="page"] { background: var(--primary); color: var(--primary-foreground); }
.nav-item .ico { display: grid; place-items: center; width: 18px; height: 18px; flex: none; }
.nav-item .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .tip {
  position: absolute; left: 100%; margin-left: 8px; z-index: 40;
  display: none; white-space: nowrap;
  border-radius: 8px; background: var(--card); color: var(--foreground);
  padding: 4px 8px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow-pop);
}

.collapse-btn {
  position: absolute; right: -12px; top: 78px; z-index: 40;
  display: grid; place-items: center; width: 24px; height: 24px;
  border: 0; border-radius: 9999px;
  background: var(--card); color: var(--muted-foreground);
  box-shadow: 0 2px 8px -1px rgba(0, 0, 0, .25);
  cursor: pointer;
}
.collapse-btn:hover { color: var(--foreground); }
.collapse-btn svg { transition: transform 200ms ease; transform: rotate(180deg); }

/* Collapsed rail: labels, group headings and the brand word fall away. */
.shell.rail { --sidebar-w: 76px; }
.shell.rail .sidebar-brand .word,
.shell.rail .nav-item .txt,
.shell.rail .nav-group .glabel { display: none; }
.shell.rail .nav-item { justify-content: center; padding-inline: 0; }
.shell.rail .nav-item:hover .tip { display: block; }
.shell.rail .collapse-btn svg { transform: none; }
.shell.rail .sidebar-brand { justify-content: center; padding-inline: 0; }

.main-col { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.topbar-wrap { position: sticky; top: 0; z-index: 20; padding: 16px 16px 0; }
.topbar { display: flex; align-items: center; gap: 8px; height: 64px; padding-inline: 16px; }
.search-wrap { position: relative; flex: 1; max-width: 28rem; }
.search-wrap .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.search-wrap input {
  height: 36px; width: 100%; border: 0; border-radius: var(--radius);
  background: var(--tint-4); padding: 0 12px 0 36px; font-size: 13.5px; color: var(--foreground);
}
.search-wrap input::placeholder { color: var(--muted-foreground); }
.search-wrap input:focus { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 40%, transparent); }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icobtn {
  position: relative; display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted-foreground); cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.icobtn:hover { background: var(--tint-6); color: var(--foreground); }
.icobtn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 9999px; background: var(--destructive); }

.pop-wrap { position: relative; }
.pop {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
  overflow: hidden; border-radius: 16px;
  background: var(--popover); box-shadow: var(--shadow-pop);
}
.pop[hidden] { display: none; }
.pop-item {
  display: flex; width: 100%; align-items: center; gap: 12px;
  border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; text-align: left; font-size: 13.5px; color: var(--foreground);
  transition: background-color 120ms;
}
.pop-item:hover { background: var(--tint-5); }
.pop-item.danger { color: var(--destructive); }
.pop-rule { height: 1px; margin-inline: 8px; background: var(--border); }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; }
.pop-head p { font-weight: 600; }

.content { flex: 1; display: flex; flex-direction: column; gap: 24px; padding: 16px; }

/* ───────────────────────────────── utilities ────────────────────────────── */
.grid { display: grid; gap: 24px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.tight { gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stackv { display: flex; flex-direction: column; gap: 4px; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.muted { color: var(--muted-foreground); }
.f12 { font-size: 12px; } .f13 { font-size: 13px; } .f15 { font-size: 15px; }
.b6 { font-weight: 600; } .b7 { font-weight: 700; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min0 { min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 20px; }
.filters .fld { width: auto; min-width: 190px; }
.filters .fld[type="search"] { min-width: 240px; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--tint-4); }
.tab {
  border: 0; background: transparent; cursor: pointer;
  border-radius: 9px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  color: var(--muted-foreground); transition: background-color 120ms, color 120ms;
}
.tab:hover { color: var(--foreground); }
.tab[aria-selected="true"] { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.note {
  border-radius: 12px; padding: 14px 16px; font-size: 12.5px; line-height: 1.6;
  background: color-mix(in srgb, var(--tone, var(--info)) 10%, transparent);
  color: color-mix(in srgb, var(--tone, var(--info)) 68%, var(--foreground));
}
.note.warn { --tone: var(--warning); }
.note.ok { --tone: var(--success); }
.note.brand { --tone: var(--primary); }

.meter { height: 12px; border-radius: 9999px; background: var(--tint-6); overflow: hidden; display: flex; }
.meter span { display: block; height: 100%; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 100px; align-items: center; gap: 12px; }
.bar-track { height: 12px; border-radius: 9999px; background: var(--tint-6); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 9999px; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; }

.demo-banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 12px; padding: 10px 14px; font-size: 12.5px; font-weight: 500;
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: color-mix(in srgb, var(--warning) 72%, var(--foreground));
}

/* Chart hover readouts sit above the plot without shifting it. */
.chart { position: relative; }
.chart .tip {
  position: absolute; z-index: 10; pointer-events: none;
  transform: translate(-50%, -100%);
  border-radius: 10px; padding: 6px 10px; font-size: 12px; line-height: 1.35;
  background: var(--card); color: var(--foreground); box-shadow: 0 8px 24px -8px rgba(0,0,0,.35);
  white-space: nowrap;
}
.chart .tip[hidden] { display: none; }
.chart .tip b { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 12.5px; }
.legend .k { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ──────────────────────────────── responsive ────────────────────────────── */
.mobile-only { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); }
.backdrop[hidden] { display: none; }

@media (min-width: 1024px) {
  .topbar-wrap { padding: 24px 24px 0; }
  .content { padding: 24px; gap: 24px; }
}

@media (max-width: 1023px) {
  .mobile-only { display: grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; height: 100vh; width: 260px; z-index: 50;
    transform: translateX(-100%); transition: transform 200ms ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: none; }
  .collapse-btn { display: none; }
  .shell.rail { --sidebar-w: 260px; }
  .shell.rail .sidebar-brand .word,
  .shell.rail .nav-item .txt,
  .shell.rail .nav-group .glabel { display: revert; }
  .shell.rail .nav-item { justify-content: flex-start; padding-inline: 11px; }
  .shell.rail .sidebar-brand { justify-content: flex-start; padding-inline: 16px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
}

@media (max-width: 680px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 12px; gap: 16px; }
  .topbar-wrap { padding: 12px 12px 0; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .search-wrap { display: none; }
}
