/* ==========================================================================
   Collanduni — ui.css
   Panels, north-star block, stats, charts, tables, badges, meters, tabs
   ========================================================================== */

/* ==========================================================================
   Panel — the one container primitive. Quiet chrome: hairline, no heavy shadow.
   ========================================================================== */

.panel {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  min-width: 0;
}

.panel--flush { padding: 0; overflow: hidden; }
.panel--pad-sm { padding: var(--s-4); }

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--hairline);
}
.panel__head h2 { font-size: var(--text-md); }

/* Layout helpers */
.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--2-1, .grid--1-2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .grid--2, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   North-star block — ONE number at 3x scale, secondaries subordinate.
   The single strongest hierarchy move on the overview page.
   ========================================================================== */

.northstar {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--s-6);
  align-items: center;
  padding: var(--s-6);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 150% at 0% 0%, var(--accent-wash) 0%, transparent 58%),
    var(--surface-2);
}

.northstar__lead { display: grid; gap: var(--s-3); min-width: 0; }

.northstar__value {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.northstar__value .num {
  font-size: var(--text-hero);
  font-weight: 600;
  line-height: 1.1;          /* mega numeral — never below 1.05 */
  letter-spacing: -0.045em;  /* mono commas run wide at this size */
  color: var(--fg);
}

.northstar__spark { width: 100%; height: 54px; overflow: hidden; }

/* Secondary metrics: hairline-separated rows, NOT cards. Keeps them subordinate. */
.substats { display: grid; gap: 0; align-self: stretch; }
.substats__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--hairline);
}
.substats__row:last-child { border-bottom: 0; padding-bottom: 0; }
.substats__row:first-child { padding-top: 0; }
.substats__label { font-size: var(--text-sm); color: var(--fg-soft); }
.substats__value { display: flex; align-items: baseline; gap: var(--s-3); }
.substats__value .num { font-size: var(--text-md); font-weight: 500; }

@media (max-width: 900px) {
  .northstar { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); padding: var(--s-5); }
}

/* ==========================================================================
   Stat tile — used for the secondary KPI row
   ========================================================================== */

.stat {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease);
}
.stat:hover { border-color: var(--fg-faint); }

.stat__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }

.stat__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.stat__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.stat__spark { width: 72px; height: 26px; flex: none; overflow: hidden; }

/* Delta pill — direction encoded by colour AND arrow (not colour alone) */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  line-height: 1.5;
}
.delta svg { width: 11px; height: 11px; }
.delta--up   { background: var(--ok-wash);   color: var(--ok); }
.delta--down { background: var(--err-wash);  color: var(--err); }
.delta--flat { background: var(--surface-3); color: var(--fg-mute); }

/* ==========================================================================
   Badges & status pills — colour carries state, never decoration
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--fg-soft);
}
.badge--ok   { background: var(--ok-wash);   color: var(--ok); }
.badge--warn { background: var(--warn-wash); color: var(--warn); }
.badge--err  { background: var(--err-wash);  color: var(--err); }
.badge--info { background: var(--accent-wash); color: var(--accent); }

.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge--live .dot { animation: pulse-dot 1.9s var(--ease) infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.82); }
}

/* ==========================================================================
   Charts (hand-built SVG — no chart library, no external requests)
   ========================================================================== */

.chart { width: 100%; display: block; overflow: visible; }
.chart__wrap { position: relative; }

/* .chart-area's fill is set per-chart in charts.js (unique gradient id).
   Do not set `fill` here — a CSS rule outranks the presentation attribute. */
.chart-line   { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line--muted { stroke: var(--fg-faint); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart-grid   { stroke: var(--hairline); stroke-width: 1; }
.chart-axis   { fill: var(--fg-mute); font-family: var(--font-mono); font-size: 10px; }

/* Animated draw-in for line paths */
.chart-line--draw {
  stroke-dasharray: var(--len, 2000);
  stroke-dashoffset: var(--len, 2000);
  animation: draw 1.1s var(--ease) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.chart-area--fade { opacity: 0; animation: fade-in 0.7s var(--ease) 0.35s forwards; }
@keyframes fade-in { to { opacity: 1; } }

/* Hover crosshair + marker */
.chart-cross { stroke: var(--fg-faint); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-dot { fill: var(--accent); stroke: var(--surface-2); stroke-width: 3; opacity: 0; }
.chart__wrap:hover .chart-cross,
.chart__wrap:hover .chart-dot { opacity: 1; }

.chart-tip {
  position: absolute;
  top: 0; left: 0;
  transform: translate(-50%, -120%);
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  z-index: 5;
}
.chart__wrap:hover .chart-tip { opacity: 1; }
.chart-tip b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Bars */
.chart-bar { fill: var(--accent); rx: 3; transition: fill var(--dur-fast) var(--ease); }
.chart-bar--quiet { fill: var(--surface-3); }
.chart-bar:hover { fill: var(--accent-soft); }

/* Ring / donut */
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 14; }
.ring-seg {
  fill: none;
  stroke-width: 14;
  stroke-linecap: butt;
  transition: stroke-width var(--dur-fast) var(--ease);
}
.ring-seg:hover { stroke-width: 17; }
.ring-center { text-anchor: middle; }

/* Legend */
.legend { display: grid; gap: var(--s-3); }
.legend__row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--text-sm);
}
.legend__swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend__name { color: var(--fg-soft); }
.legend__val { margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm); }

/* Horizontal ranked bars — acquisition channels, top pages */
.rank { display: grid; gap: var(--s-4); }
.rank__row { display: grid; gap: var(--s-2); }
.rank__meta { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); font-size: var(--text-sm); }
.rank__meta .num { color: var(--fg-soft); font-size: var(--text-sm); }
.rank__track { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.rank__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  width: 0;
  animation: grow-bar 0.9s var(--ease) forwards;
}
@keyframes grow-bar { to { width: var(--w, 0%); } }

/* Bullet meter — usage vs limit */
.meter { display: grid; gap: var(--s-2); }
.meter__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); font-size: var(--text-sm); }
.meter__track { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter__fill { height: 100%; border-radius: inherit; background: var(--accent); }
.meter__fill--warn { background: var(--warn); }
.meter__fill--err  { background: var(--err); }

/* Funnel */
.funnel { display: grid; gap: var(--s-2); }
.funnel__step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--accent-wash) var(--w, 100%), transparent var(--w, 100%));
  border: 1px solid var(--hairline);
}
.funnel__name { font-size: var(--text-sm); font-weight: 500; }
.funnel__nums { display: flex; align-items: baseline; gap: var(--s-4); }
.funnel__drop { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--err); }

/* Cohort heatmap */
.cohort { width: 100%; border-collapse: separate; border-spacing: 3px; }
.cohort th {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  text-align: center;
  padding-bottom: var(--s-2);
}
.cohort th:first-child { text-align: left; }
.cohort td {
  text-align: center;
  padding: var(--s-2) var(--s-1);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  color: var(--fg);
  background: rgba(31, 182, 255, var(--i, 0.06));
  transition: transform var(--dur-fast) var(--ease);
}
[data-theme="light"] .cohort td { background: rgba(15, 143, 214, var(--i, 0.06)); }
.cohort td:hover { transform: scale(1.06); }
.cohort td:first-child {
  text-align: left;
  background: transparent;
  color: var(--fg-soft);
  font-family: var(--font-body);
  white-space: nowrap;
  padding-left: 0;
}
.cohort td.is-empty { background: var(--hairline-soft); color: var(--fg-faint); }

/* ==========================================================================
   Data table — the primary interface, per 2026 dashboard practice
   ========================================================================== */

.tablewrap { overflow-x: auto; }

.table { font-size: var(--text-sm); }

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--fg); }
.table th.sortable .arrow { opacity: 0; margin-left: 4px; transition: opacity var(--dur-fast) var(--ease); }
.table th[aria-sort] { color: var(--fg); }
.table th[aria-sort] .arrow { opacity: 1; }
.table th[aria-sort="descending"] .arrow { transform: rotate(180deg); }
.table th .arrow { display: inline-block; width: 9px; height: 9px; vertical-align: -1px; }

.table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-3); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-selected="true"] { background: var(--accent-wash); }

.table .num { font-size: var(--text-sm); }
.table .col-right { text-align: right; }
.table .col-tight { width: 1%; }

/* Person cell */
.person { display: flex; align-items: center; gap: var(--s-3); }
.person__meta { display: grid; min-width: 0; }
.person__name { font-weight: 600; color: var(--fg); }
.person__sub { font-size: var(--text-xs); color: var(--fg-mute); }

/* Bulk-action bar, revealed when rows are selected */
.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--accent-wash);
  border-bottom: 1px solid var(--accent-line);
  font-size: var(--text-sm);
}
.bulkbar[hidden] { display: none; }
.bulkbar__count { font-weight: 600; color: var(--accent); }

/* Toolbar above a table */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.toolbar__search { position: relative; flex: 1; min-width: 180px; }
.toolbar__search svg {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--fg-mute);
  pointer-events: none;
}
.toolbar__search .input { padding-left: 34px; }

/* Filter chips */
.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 30px;
  padding: 0 var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--fg-soft);
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--fg-faint); color: var(--fg); }
.chip[aria-pressed="true"] {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--hairline);
  font-size: var(--text-xs);
  color: var(--fg-mute);
  flex-wrap: wrap;
}
.pager__nav { display: flex; align-items: center; gap: var(--s-1); }
.pager__btn {
  min-width: 28px;
  height: 28px;
  padding: 0 var(--s-2);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-soft);
  transition: background var(--dur-fast) var(--ease);
}
.pager__btn:hover { background: var(--surface-3); color: var(--fg); }
.pager__btn[aria-current="true"] { background: var(--accent); color: var(--on-accent); }

/* ==========================================================================
   Activity feed
   ========================================================================== */

.feed { display: grid; }
.feed__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.feed__item:last-child { border-bottom: 0; padding-bottom: 0; }
.feed__item:first-child { padding-top: 0; }

.feed__icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  background: var(--surface-3);
  color: var(--fg-mute);
  flex: none;
}
.feed__icon svg { width: 14px; height: 14px; }
.feed__icon--ok   { background: var(--ok-wash);   color: var(--ok); }
.feed__icon--warn { background: var(--warn-wash); color: var(--warn); }
.feed__icon--err  { background: var(--err-wash);  color: var(--err); }
.feed__icon--info { background: var(--accent-wash); color: var(--accent); }

.feed__body { display: grid; gap: 2px; min-width: 0; }
.feed__text { font-size: var(--text-sm); color: var(--fg-soft); }
.feed__text b { color: var(--fg); font-weight: 600; }
.feed__time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--fg-faint); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
}
.tab {
  position: relative;
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-mute);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); font-weight: 600; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--s-3); right: var(--s-3);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-pill);
}

/* Vertical tabs (settings) */
.vtabs { display: grid; gap: 2px; align-content: start; }
.vtab {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-soft);
  text-align: left;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.vtab svg { width: 16px; height: 16px; flex: none; }
.vtab:hover { background: var(--surface-3); color: var(--fg); }
.vtab[aria-selected="true"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }

/* ==========================================================================
   Misc
   ========================================================================== */

.divider { height: 1px; background: var(--hairline); border: 0; }

.empty {
  display: grid;
  gap: var(--s-3);
  justify-items: center;
  text-align: center;
  padding: var(--s-7) var(--s-5);
}
.empty__art {
  width: 46px; height: 46px;
  display: grid; place-content: center;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--fg-faint);
}
.empty__art svg { width: 22px; height: 22px; }
.empty p { font-size: var(--text-sm); color: var(--fg-mute); max-width: 34ch; }

.statusline {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  flex-wrap: wrap;
  font-size: var(--text-sm);
}
.statusline__item { display: flex; align-items: center; gap: var(--s-2); color: var(--fg-soft); }
.statusline__item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.copyrow {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-soft);
  overflow: hidden;
}
[data-theme="light"] .copyrow { background: var(--surface-3); }
.copyrow code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.danger-zone { border-color: var(--err-wash); }
.danger-zone .panel__head { border-bottom-color: var(--err-wash); }

/* ==========================================================================
   Scroll reveal — opacity + transform only (compositor-friendly)
   ========================================================================== */

[data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  transition-delay: var(--delay, 0ms);
}
[data-reveal][data-revealed="true"] { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; }
}

/* ==========================================================================
   Auth page (login.html) — the one full-bleed layout in the kit
   ========================================================================== */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.auth__form {
  display: grid;
  align-content: center;
  justify-items: stretch;
  gap: var(--s-5);
  padding: var(--s-7) clamp(var(--s-5), 6vw, 5rem);
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.auth__aside {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--hairline);
  display: grid;
  align-content: end;
  gap: var(--s-5);
  padding: var(--s-7) clamp(var(--s-5), 4vw, 3.5rem);
  isolation: isolate;
}
/* Only the backdrop image, never the avatar that also lives in this panel. */
.auth__bg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: -2;
}
.auth__aside::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(200deg, rgba(10, 13, 18, 0.55) 0%, rgba(10, 13, 18, 0.94) 72%);
}
.auth__quote {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.4;              /* display face at size — keep airy */
  letter-spacing: -0.02em;
  color: #F2F6FC;
  max-width: 30ch;
}
.auth__proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.auth__proof .num { font-size: var(--text-lg); font-weight: 500; color: #FFF; }
.auth__proof .label { color: rgba(255, 255, 255, 0.55); }

.divider-text {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--text-xs);
  color: var(--fg-faint);
}
.divider-text::before, .divider-text::after { content: ""; height: 1px; background: var(--hairline); }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { display: none; }
}

/* Hot heatmap cells: the cyan wash is bright enough that light text drops
   below 4.5:1, so flip to the on-accent ink instead. */
.cohort td.is-hot { color: var(--on-accent); font-weight: 500; }
[data-theme="light"] .cohort td.is-hot { color: #FFFFFF; }
