/* ==========================================================================
   NetrAI — shared application shell
   --------------------------------------------------------------------------
   One layout, three products. Kubera, Fusion and Cadre all sit on this file
   and then override a set of custom properties to become themselves.

   The layout is fixed on purpose, because it is the thing that makes them
   read as one family:

       ┌──────────────────────────────────────────────────────────┐
       │  NetrAI ◇ Product        [ search ]           user  ▾    │  topbar
       ├────────────┬─────────────────────────────────────────────┤
       │  nav       │  view stage                                 │
       │  items     │                                             │
       │            │  ┌───────────────────────────────────────┐  │
       │            │  │  ask bar                              │  │
       │  status    │  └───────────────────────────────────────┘  │
       └────────────┴─────────────────────────────────────────────┘

   EVERYTHING INSIDE IS SIZED IN `em`. The root font-size on `.app` is the
   single scale control, which is what lets the same markup sit inside a
   1180px page frame and also fill a 1920x1080 video frame without a separate
   layout — bump one value and the whole interface scales as one piece.

   Themes override the variables in the THEME CONTRACT block below. A theme
   should not need to touch any rule in this file.
   ========================================================================== */

/* --------------------------------------------------------------------------
   THEME CONTRACT — every product defines these
   -------------------------------------------------------------------------- */
:root {
  --bg:          #08080C;   /* page behind the app */
  --surface:     #0E0E14;   /* app body */
  --panel:       rgba(255, 255, 255, 0.035);
  --panel-2:     rgba(255, 255, 255, 0.055);
  --line:        rgba(255, 255, 255, 0.07);
  --line-2:      rgba(255, 255, 255, 0.13);

  --ink:         #F1F3F9;
  --mist:        #9198BC;
  --dim:         #6E7597;

  --accent:      #4FD8E8;   /* primary action / active state */
  --accent-2:    #8B7CFF;   /* secondary, gradients */
  --accent-soft: rgba(79, 216, 232, 0.16);
  --accent-ink:  #06070C;   /* text on an accent fill */

  --pos:         #3FD68C;   /* up / good */
  --neg:         #FF6B81;   /* down / bad */

  --font:        "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-head:   var(--font);
  --font-num:    var(--font);

  --radius:      0.85em;
  --radius-lg:   1.2em;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; }
ul { list-style: none; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;

  /* The one scale control. See the note at the top of this file. */
  font-size: clamp(9px, 1.05vw, 19px);
  background: var(--surface);
}

/* A slow ambient wash so the app is never flatly lit. Themes retint it by
   changing --accent / --accent-2; nothing here needs to be overridden. */
.app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background:
    radial-gradient(60% 50% at 12% 0%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 62%),
    radial-gradient(55% 45% at 92% 8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(70% 60% at 50% 110%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 65%);
}
.app > * { position: relative; z-index: 1; }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar {
  position: relative;
  z-index: 50;
  flex: none;
  display: flex;
  align-items: center;
  gap: 1.4em;
  height: 3.6em;
  padding: 0 1.4em;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 0.6em; flex: none; }
.brand img { height: 1.7em; width: auto; mix-blend-mode: screen; }

/* The divider and product name sit next to the NetrAI mark so the product
   always reads as "NetrAI's <thing>", never as an unrelated app. */
.brand-sep { width: 1px; height: 1.4em; background: var(--line-2); margin: 0 0.3em; }
.product {
  display: flex; align-items: center; gap: 0.5em;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.05em;
  letter-spacing: -0.01em;
}
.product-glyph { width: 1.1em; height: 1.1em; color: var(--accent); }

.topbar-search {
  flex: 1;
  max-width: 26em;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.55em;
  height: 2.3em;
  padding: 0 0.9em;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.9em;
}
.topbar-search svg { width: 1em; height: 1em; flex: none; }

.topbar-right { display: flex; align-items: center; gap: 1em; margin-left: auto; }
.topbar-chip {
  display: flex; align-items: center; gap: 0.4em;
  font-size: 0.82em; color: var(--mist);
}
.user { display: flex; align-items: center; gap: 0.6em; }
.user-avatar {
  flex: none;
  width: 2.1em; height: 2.1em; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  font-weight: 700; font-size: 0.8em;
}
/* Name/role shrink with the topbar (narrower window, or a wider bell +
   chevron eating into the same space) but never wrap — they truncate with
   an ellipsis instead, so a long name never pushes the row taller. */
.user-meta { line-height: 1.25; min-width: 0; max-width: 11em; }
.user-name, .user-role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-name { font-size: 0.86em; font-weight: 600; }
.user-role { font-size: 0.72em; color: var(--dim); }

/* --------------------------------------------------------------------------
   Body: sidebar + stage
   -------------------------------------------------------------------------- */
.body { flex: 1; min-height: 0; display: flex; gap: 1em; padding: 1em; }

.side {
  flex: none;
  width: 13.5em;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  padding: 1em 0.8em;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
}

.side-label {
  font-size: 0.66em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 0.7em;
  margin-bottom: 0.55em;
}

.nav { display: flex; flex-direction: column; gap: 0.2em; }
.nav button {
  display: flex; align-items: center; gap: 0.75em;
  width: 100%;
  padding: 0.68em 0.75em;
  border-radius: 0.6em;
  border: 1px solid transparent;
  font-size: 0.92em;
  font-weight: 500;
  color: var(--mist);
  text-align: left;
  transition: color 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}
.nav button svg { width: 1.15em; height: 1.15em; flex: none; }
.nav button:hover { color: var(--ink); background: var(--panel-2); }
.nav button[aria-current="true"] {
  color: var(--ink);
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--accent-2) 22%, transparent), var(--accent-soft));
  border-color: var(--line-2);
}
.nav button[aria-current="true"] svg { color: var(--accent); }
.nav-badge {
  margin-left: auto;
  font-size: 0.72em;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}

.side-foot { margin-top: auto; }
.status {
  display: flex; align-items: center; gap: 0.55em;
  padding: 0.65em 0.75em;
  border-radius: 0.6em;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  font-size: 0.78em;
  color: var(--mist);
}
.status-dot {
  width: 0.5em; height: 0.5em; border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0.5em var(--pos);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --------------------------------------------------------------------------
   Sidebar collapse
   --------------------------------------------------------------------------
   Icon-only mode. The width, gap and font-size all live on `.side` so the
   whole rail resizes as one animation rather than each child racing to its
   own end state. */
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5em; padding: 0 0.7em;
}
.side.is-collapsed .side-head { padding: 0 0.1em; justify-content: center; }
.side-collapse-btn {
  flex: none;
  width: 1.8em; height: 1.8em;
  display: grid; place-items: center;
  border-radius: 0.5em;
  color: var(--dim);
  transition: color 0.2s ease, background 0.2s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.side-collapse-btn:hover { color: var(--ink); background: var(--panel-2); }
.side-collapse-btn svg { width: 1em; height: 1em; }
.side.is-collapsed .side-collapse-btn { transform: rotate(180deg); }

.side {
  transition: width 0.32s cubic-bezier(0.22, 1, 0.36, 1), padding 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.side.is-collapsed { width: 4.4em; padding-left: 0.5em; padding-right: 0.5em; }
.side.is-collapsed .side-label,
.side.is-collapsed .nav button span,
.side.is-collapsed .nav-badge,
.side.is-collapsed .status span { display: none; }
.side.is-collapsed .nav button { justify-content: center; padding: 0.68em; }
.side.is-collapsed .status { justify-content: center; padding: 0.65em; }

/* --------------------------------------------------------------------------
   Score ring — the one headline number a product is judged on, drawn as a
   stroked ring rather than a bar so it reads as a single verdict, not a
   metric among metrics. Generalised from Kubera's purity ring: same arc
   math, but the fill is one continuous sweep rather than a segmented split,
   because most products only have one number to show here.
   -------------------------------------------------------------------------- */
.summary {
  display: flex; align-items: center; gap: 1.5em;
  padding: 1.1em 1.4em;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  flex: none;
}
.summary-body { display: flex; flex-direction: column; gap: 0.6em; min-width: 0; }
.summary-status {
  display: inline-flex; align-items: center; gap: 0.4em;
  align-self: flex-start;
  padding: 0.3em 0.7em;
  border-radius: 999px;
  font-size: 0.78em; font-weight: 600;
  background: color-mix(in srgb, var(--pos) 16%, transparent);
  color: var(--pos);
}
.summary-status.warn { background: color-mix(in srgb, #F5B544 16%, transparent); color: #F5B544; }
.summary-status.bad  { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.summary-text { font-size: 0.92em; line-height: 1.55; color: var(--mist); max-width: 56ch; }
.summary-text b { color: var(--ink); font-weight: 600; }

.score-ring { position: relative; width: 7em; height: 7em; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.score-ring circle {
  fill: none; stroke-width: 9; stroke-linecap: round;
}
.score-ring circle.track { stroke: var(--line-2); }
.score-ring circle.fill {
  stroke: var(--accent);
  transition: stroke-dashoffset 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-ring-center {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
}
.score-ring-center b {
  font-family: var(--font-num); font-size: 1.6em; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1;
}
.score-ring-center span {
  display: block; margin-top: 0.25em;
  font-size: 0.6em; color: var(--dim);
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Insight cards — three across, each a small verdict rather than a table:
   an icon, a chip, and a short list of things worth a sentence.
   -------------------------------------------------------------------------- */
.insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.9em; flex: none; }
.insight {
  display: flex; flex-direction: column; gap: 0.9em;
  padding: 1.1em 1.2em;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--insight-wash, var(--accent-soft)) 0%, transparent 55%),
    var(--panel);
}
.insight-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; }
.insight-title { display: flex; align-items: center; gap: 0.6em; min-width: 0; }
.insight-title h4 {
  font-family: var(--font-head); font-size: 0.98em; font-weight: 600;
  letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.insight-icon {
  width: 1.9em; height: 1.9em; flex: none;
  border-radius: 0.55em;
  display: grid; place-items: center;
  background: var(--insight-icon-bg, var(--accent-soft));
  color: var(--insight-icon-ink, var(--accent));
}
.insight-icon svg { width: 1em; height: 1em; }
.insight-chip {
  flex: none;
  font-size: 0.7em; font-weight: 600;
  padding: 0.32em 0.65em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--mist);
}
.insight-rows { display: flex; flex-direction: column; gap: 0.5em; }
.insight-row {
  display: flex; align-items: flex-start; gap: 0.6em;
  padding: 0.6em 0.7em;
  border-radius: 0.6em;
  background: rgba(255, 255, 255, 0.03);
}
.insight-row svg { width: 1.05em; height: 1.05em; flex: none; margin-top: 0.15em; color: var(--insight-icon-ink, var(--accent)); }
.insight-row-body { min-width: 0; }
.insight-row-title { font-size: 0.85em; font-weight: 600; line-height: 1.35; }
.insight-row-sub { font-size: 0.78em; color: var(--dim); margin-top: 0.15em; line-height: 1.35; }

@media (max-width: 1100px) {
  .insights { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Topbar dropdowns — the notification bell and the profile menu share one
   mechanism: a trigger button, an absolutely-positioned panel, opened by
   app.js toggling `.is-open` and closed on outside click or Escape.
   -------------------------------------------------------------------------- */
.dd { position: relative; flex: none; }
.bell-btn, .user {
  position: relative;
  width: 2.3em; height: 2.3em;
  display: grid; place-items: center;
  border-radius: 0.6em;
  color: var(--mist);
  transition: color 0.2s ease, background 0.2s ease;
}
.bell-btn:hover { color: var(--ink); background: var(--panel-2); }
.bell-btn svg { width: 1.15em; height: 1.15em; }
.dd-chev { flex: none; width: 0.9em; height: 0.9em; color: var(--dim); }
.bell-dot {
  position: absolute; top: 0.4em; right: 0.45em;
  width: 0.55em; height: 0.55em; border-radius: 50%;
  background: var(--neg);
  box-shadow: 0 0 0 2px var(--surface);
}

.user {
  width: auto; height: auto;
  display: flex; align-items: center; gap: 0.6em;
  padding: 0.25em 0.5em 0.25em 0.25em;
  border-radius: 0.7em;
}
.user:hover { background: var(--panel-2); }

.dd-panel {
  position: absolute; top: calc(100% + 0.7em); right: 0;
  width: 19em; max-width: 82vw;
  padding: 0.6em;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: 0 1.4em 3.2em -1em rgba(0, 0, 0, 0.6);
  z-index: 60;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-0.4em) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.18s;
}
.dd.is-open .dd-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: none; }

.dd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5em 0.6em 0.7em;
  font-size: 0.85em; font-weight: 600;
}
.dd-head span:last-child { font-size: 0.85em; font-weight: 400; color: var(--dim); }

.dd-list { display: flex; flex-direction: column; gap: 0.3em; }
.dd-item {
  display: flex; align-items: flex-start; gap: 0.65em;
  padding: 0.55em 0.6em;
  border-radius: 0.6em;
}
.dd-item-icon {
  width: 1.9em; height: 1.9em; flex: none;
  border-radius: 0.5em;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.dd-item-icon svg { width: 1em; height: 1em; }
.dd-item-icon.ok   { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.dd-item-icon.warn { background: color-mix(in srgb, #F5B544 16%, transparent); color: #F5B544; }
.dd-item-icon.bad  { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.dd-item-body { min-width: 0; }
.dd-item-title { font-size: 0.85em; font-weight: 600; line-height: 1.35; }
.dd-item-sub { font-size: 0.76em; color: var(--dim); margin-top: 0.1em; }
.dd-item-time { margin-left: auto; flex: none; font-size: 0.72em; color: var(--dim); padding-top: 0.15em; }

.dd-foot {
  margin-top: 0.3em; padding-top: 0.6em;
  border-top: 1px solid var(--line);
}
.dd-menu-item {
  display: flex; align-items: center; gap: 0.65em;
  width: 100%; padding: 0.55em 0.6em;
  border-radius: 0.55em;
  font-size: 0.85em; color: var(--mist);
  transition: color 0.2s ease, background 0.2s ease;
}
.dd-menu-item:hover { color: var(--ink); background: var(--panel-2); }
.dd-menu-item svg { width: 1.05em; height: 1.05em; flex: none; }
.dd-menu-item.neg { color: color-mix(in srgb, var(--neg) 85%, var(--mist)); }
.dd-menu-item.neg:hover { color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, transparent); }

/* Profile panel's own header: bigger avatar, name + role, then a strip of
   mini stats pulled from whatever the product considers its headline
   numbers — the same information the KPI tiles carry, restated compactly. */
.dd-profile-head { display: flex; align-items: center; gap: 0.8em; padding: 0.3em 0.5em 0.8em; }
.dd-profile-avatar {
  width: 2.6em; height: 2.6em; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: var(--accent-ink); font-weight: 700; font-size: 0.9em;
}
.dd-profile-name { font-size: 0.92em; font-weight: 600; }
.dd-profile-role { font-size: 0.78em; color: var(--dim); margin-top: 0.1em; }

.dd-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4em; padding: 0 0.1em 0.6em; }
.dd-stat {
  display: flex; align-items: center; gap: 0.5em;
  padding: 0.55em 0.6em;
  border-radius: 0.6em;
  background: rgba(255, 255, 255, 0.04);
}
.dd-stat-icon {
  width: 1.6em; height: 1.6em; flex: none; border-radius: 0.4em;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.dd-stat-icon svg { width: 0.85em; height: 0.85em; }
.dd-stat-val { font-family: var(--font-num); font-size: 0.88em; font-weight: 700; line-height: 1.2; }
.dd-stat-label { font-size: 0.68em; color: var(--dim); }

/* --------------------------------------------------------------------------
   Chart tooltip — one floating element, positioned by app.js next to
   whatever `[data-tip]` element the pointer is over.
   -------------------------------------------------------------------------- */
.na-tip {
  position: fixed;
  z-index: 200;
  padding: 0.5em 0.7em;
  border-radius: 0.55em;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-2);
  box-shadow: 0 0.8em 2em -0.6em rgba(0, 0, 0, 0.6);
  font-size: 0.78em;
  color: var(--ink);
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -0.4em);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.na-tip.is-visible { opacity: 1; transform: translate(-50%, -0.7em); }
.na-tip b { color: var(--accent); font-weight: 600; }

[data-tip] { cursor: default; }

/* --------------------------------------------------------------------------
   Stage + views
   -------------------------------------------------------------------------- */
.stage { flex: 1; min-width: 0; position: relative; z-index: 1; }

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.6em);
  transition: opacity 0.3s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.3s;
}
.view.is-active { opacity: 1; visibility: visible; transform: none; }

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.15em 1.25em;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1em; margin-bottom: 1em; flex: none;
}
.card h3 {
  font-family: var(--font-head);
  font-size: 1.05em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-sub { font-size: 0.8em; color: var(--dim); margin-top: 0.2em; }

.grid { display: grid; gap: 0.9em; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* KPI tiles ---------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85em; }
.kpi {
  display: flex; flex-direction: column; gap: 0.35em;
  padding: 1em;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}
.kpi-icon {
  width: 2em; height: 2em; border-radius: 0.55em;
  display: grid; place-items: center;
  margin-bottom: 0.3em;
}
.kpi-icon svg { width: 1.05em; height: 1.05em; }
.kpi-val {
  font-family: var(--font-num);
  font-size: 1.7em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.kpi-label { font-size: 0.82em; color: var(--mist); }
.kpi-delta { font-size: 0.75em; color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }

/* Bars, rows, tables ------------------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 0.5em; flex: 1; min-height: 0; padding-top: 0.5em; }
.bars > span {
  flex: 1;
  border-radius: 0.25em 0.25em 0 0;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent-2) 70%, transparent));
  height: 0;
  transition: height 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.rows { display: flex; flex-direction: column; }
.row {
  display: grid;
  align-items: center;
  gap: 0.8em;
  padding: 0.7em 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88em;
}
.row:last-child { border-bottom: 0; }
.row-head { color: var(--dim); font-size: 0.78em; letter-spacing: 0.05em; text-transform: uppercase; }
.row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; }

.meter { height: 0.34em; border-radius: 999px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.meter i {
  display: block; height: 100%; border-radius: inherit; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.pill {
  display: inline-flex; align-items: center; gap: 0.35em;
  padding: 0.22em 0.6em;
  border-radius: 999px;
  font-size: 0.74em;
  font-weight: 600;
  border: 1px solid var(--line-2);
  color: var(--mist);
  white-space: nowrap;
}
.pill.ok  { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.pill.bad { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); }
.pill.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Line chart --------------------------------------------------------------- */
.spark { width: 100%; height: 100%; overflow: visible; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: url(#sparkFill); stroke: none; opacity: 0.55; }

/* --------------------------------------------------------------------------
   The ask bar
   --------------------------------------------------------------------------
   This is the part every product shares and the part the promo films are
   built around: a plain-language question in, a written answer with data out.
   -------------------------------------------------------------------------- */
.ask { display: flex; flex-direction: column; height: 100%; gap: 0.8em; }

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;   /* messages hug the composer, like a real chat */
  gap: 0.7em;
  padding-right: 0.3em;
}

.msg {
  max-width: 78%;
  padding: 0.75em 0.95em;
  border-radius: 0.9em;
  font-size: 0.92em;
  line-height: 1.5;
  animation: msgIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(0.5em); } }
.msg b { color: var(--ink); font-weight: 600; }
.msg-you {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid var(--line-2);
  border-bottom-right-radius: 0.25em;
}
.msg-ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-bottom-left-radius: 0.25em;
  color: var(--mist);
  max-width: 88%;
}

.msg-chart { display: flex; align-items: flex-end; gap: 0.3em; height: 3.6em; margin-top: 0.7em; }
.msg-chart span {
  flex: 1; height: 0;
  border-radius: 0.2em 0.2em 0 0;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent-2) 65%, transparent));
  transition: height 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.typing { display: inline-flex; gap: 0.25em; }
.typing i {
  width: 0.36em; height: 0.36em; border-radius: 50%;
  background: var(--mist);
  animation: bounce 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-0.3em); opacity: 1; }
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4em; flex: none; }
.chip {
  padding: 0.42em 0.8em;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82em;
  color: var(--mist);
  transition: color 0.22s ease, border-color 0.22s ease;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }

.composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.5em 0.5em 1em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.composer input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font-size: 0.95em;
}
.composer input::placeholder { color: var(--dim); }
.send {
  width: 2.2em; height: 2.2em; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.2s ease;
}
.send:hover { transform: scale(1.07); }
.send svg { width: 1em; height: 1em; }

/* --------------------------------------------------------------------------
   Scrollbars — thin and unobtrusive, so a recording never shows a fat bar
   -------------------------------------------------------------------------- */
.view::-webkit-scrollbar, .thread::-webkit-scrollbar { width: 0.35em; }
.view::-webkit-scrollbar-thumb, .thread::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 999px;
}
.view, .thread { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* --------------------------------------------------------------------------
   Skeleton loading state
   ---------------------------------------------------------------------------
   Every view gets a skeleton built from its OWN rendered DOM (see
   buildSkeletonOverlay in js/app.js) rather than a hand-drawn generic one —
   it walks the real markup right after it's rendered and swaps each piece of
   content for a shimmer block the same size, so the skeleton is automatically
   the right shape for every card, table and chart in every product, with no
   per-view maintenance. Chart bars are the one exception: measured before
   they've animated in they'd be flat, so the walker sizes those from the
   final data-h/data-w percentage instead — the skeleton bars already have
   roughly the shape the real chart is about to take.

   Shown once per view, the first time it's opened; a view that has already
   been visited switches back to instantly, same as before this existed.
   -------------------------------------------------------------------------- */
.view > :not(.view-skeleton) { transition: opacity 0.35s ease; }
.view.is-loading > :not(.view-skeleton) { opacity: 0; }

.view-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 2;
}
.view.is-loading .view-skeleton { opacity: 1; pointer-events: auto; }

.skel {
  flex: none;
  border-radius: 0.35em;
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 250% 100%;
  animation: skel-shimmer 1.6s ease-in-out infinite;
}
.skel-round { border-radius: 50%; }
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--panel-2); }
}

/* --------------------------------------------------------------------------
   Mobile — under 820px this stops being a three-column dashboard scaled
   down and becomes a genuinely different layout: the sidebar leaves the
   document flow and reappears as a full-height off-canvas drawer (app.js
   toggles `.is-mobile-open` on `.side` and `.is-visible` on the backdrop),
   the topbar sheds everything but the essentials behind a menu button, and
   every multi-column grid collapses toward one column.
   -------------------------------------------------------------------------- */
@media (max-width: 820px) {
  .app { font-size: clamp(14px, 3.8vw, 17px); }

  /* Topbar: menu button, product glyph + name, then just the icons that
     matter. Search and the location/context chip are desktop niceties —
     the NetrAI wordmark image goes too, so the product name has room. */
  .menu-btn {
    flex: none;
    width: 2.3em; height: 2.3em;
    display: grid; place-items: center;
    margin-right: 0.1em;
    border-radius: 0.6em;
    color: var(--mist);
  }
  .menu-btn:hover { color: var(--ink); background: var(--panel-2); }
  .menu-btn svg { width: 1.2em; height: 1.2em; }
  .topbar { padding: 0 0.8em; gap: 0.6em; }
  .brand img, .brand-sep, .topbar-search, .topbar-chip { display: none; }
  .topbar-right { gap: 0.6em; }
  /* Avatar + chevron stay (the trigger still needs to be tappable); name
     and role move into the open profile panel instead of the topbar row. */
  .user-meta { display: none; }

  /* Sidebar becomes a drawer over a dimmed backdrop. */
  .body { padding: 0.7em; gap: 0; }
  .side-backdrop {
    position: fixed; inset: 0;
    /* Strong enough that a dark theme still reads as "something is now
       modal" at a glance, not just a faint tint. */
    background: rgba(0, 0, 0, 0.72);
    z-index: 210;
    opacity: 0; visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
  }
  .side-backdrop.is-visible { opacity: 1; visibility: visible; }

  .side {
    /* Beside the stage on desktop, `--panel`'s ~4% tint is enough because
       the same solid `--surface` sits behind both. Floating over the stage
       as a mobile overlay, it needs to actually be opaque on its own. */
    background: var(--surface);
    position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 220;
    width: 16.5em; max-width: 82vw;
    border-radius: 0;
    border-width: 0 1px 0 0;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 1.4em 0 3.2em -1em rgba(0, 0, 0, 0.6);
  }
  .side.is-mobile-open { transform: translateX(0); }
  /* Icon-collapse is a desktop affordance; app.js drops `.is-collapsed`
     whenever the viewport crosses into mobile width, so this rule is a
     belt-and-braces guard against a stale class rather than a state that
     is meant to occur here. */
  .side.is-collapsed { width: 16.5em; padding-left: 0.8em; padding-right: 0.8em; }
  .side.is-collapsed .side-label,
  .side.is-collapsed .nav button span,
  .side.is-collapsed .nav-badge,
  .side.is-collapsed .status span { display: inline; }
  .side.is-collapsed .nav button { justify-content: flex-start; padding: 0.68em 0.75em; }
  .side.is-collapsed .status { justify-content: flex-start; padding: 0.65em 0.75em; }

  /* Score-ring summary: side-by-side does not fit next to a paragraph on a
     360px screen, so it stacks and centers instead. */
  .summary { flex-direction: column; text-align: center; gap: 1em; padding: 1.2em; }
  .summary-body { align-items: center; }
  .summary-text { max-width: 32ch; }

  /* Every multi-column grid becomes one column; KPI tiles go two-across
     instead of four, since four short numbers still read fine in a pair. */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }

  /* Cards and grids pinned to a fixed em height for the desktop/recording
     frame get their natural height back and let the view scroll instead. */
  .card[style*="height"], .grid[style*="height"] { height: auto !important; }

  /* Dense tabular rows: don't wrap or crush the columns illegibly — keep
     each row at its natural width and let the card scroll horizontally. */
  .rows { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .row { min-width: max-content; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
