/* ==========================================================================
   Kavurma - subscription health
   Style: framed sheet (seed 1138200459). Tinted green-grey chrome, white work
   sheet inset 8px, no shadows. Data hue: roast amber. Everything downstream
   reads the tokens below.
   ========================================================================== */

:root {
  /* surfaces - the frame is one low-chroma step of the roastery's green */
  --ground: #f1f4ef;
  --surface: #ffffff;
  --raised: #f6f8f4;
  --active: #e7ebe4;
  --border: #e4e7e0;
  --rule: #eef0ea;
  --control: #c9cec5;

  /* ink */
  --text: #171a16;
  --muted: #5b6159;
  --faint: #6b7168;

  /* one data hue, plus honest status colours */
  --accent: #8a5a12;
  --accent-soft: #f2e8d6;
  --primary: #1b1e1a;
  --primary-ink: #ffffff;
  --positive: #246c46;
  --negative: #b42318;
  --pill-positive-bg: #e3f2e8;
  --pill-positive-ink: #10452a;
  --pill-negative-bg: #fbe9e7;
  --pill-negative-ink: #7a1a14;
  --pill-neutral-bg: #edf0ea;
  --pill-neutral-ink: #3a3f38;

  /* charts */
  --chart-1: var(--accent);
  --chart-2: #2f6b5b;
  --chart-3: #a86f0c;
  --chart-muted: #c9cec5;
  --chart-mark: var(--text);
  --chart-span: 0.06;
  --grid: #e9ebe5;
  --axis-ink: #646a61;
  --ink: var(--text);

  /* type */
  --font: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; /* taste-skill-ignore: IDs and keys only */
  --fs-title: 22px;
  --fs-section: 16px;
  --fs-kpi: 24px;
  --fs-body: 14px;
  --fs-small: 12px;

  /* frame */
  --sidebar-width: 228px;
  --topbar-height: 48px;
  --sheet-inset: 8px;
  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --pad: 24px;
  --gap: 20px;
  --card-pad: 20px;
  --control-height: 32px;
  --row-height: 48px;
  --nav-row: 34px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms;
  --t-hover: 150ms;
  --t-ui: 200ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body)/20px var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--text); }
.num, .kpi-value, .risk-rank, .plan-count, .roast-figure, .channel-value { 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;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 8px 12px; border-radius: 6px;
  background: var(--primary); color: var(--primary-ink);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

/* ---------- shell: tinted L-frame, white sheet ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px 14px;
  overflow: auto;
  background: var(--ground);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 26px; height: 26px; flex: none;
  color: var(--accent);
}
.brand-name {
  display: block;
  font-size: 17px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.brand-scope {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 12px;
  line-height: 15px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.group-label {
  margin: 4px 8px 6px;
  color: var(--faint);
  font-size: var(--fs-small);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--nav-row);
  padding: 0 8px;
  border-radius: 6px;
  color: var(--muted);
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}
.nav-item svg { width: 16px; height: 16px; flex: none; stroke-width: 1.5; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.sidebar-foot { margin-top: auto; padding-top: 24px; }
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--raised);
}
.user strong { display: block; font-size: 13px; line-height: 16px; font-weight: 500; }
.user span { display: block; color: var(--faint); font-size: 12px; line-height: 15px; }

.avatar {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #6b4610;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.avatar.lg { width: 32px; height: 32px; font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-height);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px 0 24px;
  background: var(--ground);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}
.crumbs .sep { color: var(--control); }
.crumbs .current { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 548px;
  margin-left: auto;
  margin-right: auto;
}
.search svg {
  position: absolute;
  left: 10px;
  width: 14px; height: 14px;
  color: var(--faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 32px;
  padding: 0 34px 0 30px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button,
.field-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search kbd {
  position: absolute;
  right: 8px;
  display: grid;
  place-items: center;
  min-width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--faint);
  font-family: var(--font-mono); /* taste-skill-ignore: IBM Plex Mono is the dealt face for keys */
  font-size: 11px;
  line-height: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mobile-brand {
  display: none;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.mobile-brand svg { width: 20px; height: 20px; color: var(--accent); }
.menu-toggle {
  display: none;
  place-items: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.menu-toggle svg { width: 18px; height: 18px; }
.sidebar-close {
  display: none;
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.sidebar-close svg { width: 18px; height: 18px; margin: auto; }

.sheet {
  flex: 1;
  min-width: 0;
  margin: 0 var(--sheet-inset) var(--sheet-inset) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  background: var(--surface);
  padding: var(--pad);
}
.view[hidden] { display: none; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: #2c302a; }
.btn svg { width: 14px; height: 14px; flex: none; }
.btn.icon-only { width: var(--control-height); padding: 0; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.row-action {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-underline-offset: 3px;
}
.row-action:hover { text-decoration: underline; }
.segmented {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  padding: 2px;
  border-radius: 6px;
  background: var(--raised);
}
.segmented button {
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; }
.select {
  height: var(--control-height);
  padding: 0 28px 0 10px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235b6159' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px;
}

/* ---------- title block ---------- */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}
.title-row h1 {
  font-size: var(--fs-title);
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.finding {
  margin-top: 5px;
  max-width: 62ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}
.finding strong { color: var(--text); font-weight: 500; }
.title-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}
.stamp { color: var(--faint); font-size: var(--fs-small); line-height: 16px; }

/* ---------- KPI strip ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.kpi { padding: 13px 20px 14px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); font-size: 13px; line-height: 18px; }
.kpi-value {
  margin-top: 3px;
  font-size: var(--fs-kpi);
  line-height: 30px;
  font-weight: 400;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.kpi.lead .kpi-value { font-size: 32px; line-height: 34px; font-weight: 500; }
.kpi-value small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}
.kpi-delta {
  margin-top: 2px;
  min-height: 16px;
  color: var(--faint);
  font-size: var(--fs-small);
  line-height: 16px;
}
.kpi-delta .pos { color: var(--positive); }
.kpi-delta .neg { color: var(--negative); }
.kpi-delta .baseline { color: var(--faint); }
.kpi-delta .sep { color: var(--faint); }

/* ---------- dashboard grid ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  margin-top: var(--gap);
}
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.panel {
  min-width: 0;
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 {
  font-size: var(--fs-section);
  line-height: 20px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.panel-head .meta {
  margin-top: 2px;
  color: var(--faint);
  font-size: var(--fs-small);
  line-height: 16px;
}
.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-underline-offset: 3px;
}
.panel-link::after {
  content: "";
  width: 12px; height: 12px;
  background: currentColor;
  -webkit-mask: var(--chevron) center / 12px no-repeat;
  mask: var(--chevron) center / 12px no-repeat;
}
.panel-link:hover { text-decoration: underline; }
:root {
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 2.5 8 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* chart panel */
.chart-panel { display: flex; flex-direction: column; }
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.chart-summary {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}
.chart-summary strong { color: var(--text); font-weight: 500; }
.chart { flex: 1; min-width: 0; }
.chart-source {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12px;
  line-height: 15px;
}

/* right rail: plan mix + roast plan */
.rail { display: flex; flex-direction: column; gap: var(--gap); height: 100%; }
.rail .roast-panel { flex: 1; display: flex; flex-direction: column; }
.plan-share {
  display: flex;
  gap: 2px;
  height: 6px;
  margin: 2px 0 14px;
}
.plan-share span { display: block; height: 6px; border-radius: 1px; }
.plan-legend { display: flex; flex-direction: column; }
.plan-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
.plan-swatch { width: 6px; height: 6px; border-radius: 1px; }
.plan-name { font-size: 13px; line-height: 18px; }
.plan-count { color: var(--text); font-size: 13px; text-align: right; }
.plan-count small { margin-left: 2px; color: var(--faint); font-size: 11px; font-weight: 400; }
.plan-percent { width: 44px; color: var(--faint); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.roast-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.roast-figure {
  font-size: 22px;
  line-height: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.roast-figure small { margin-left: 2px; color: var(--faint); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.roast-pct { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.capacity {
  display: block;
  height: 8px;
  margin-top: 10px;
  border-radius: 4px;
  background: var(--raised);
  overflow: hidden;
}
.capacity i { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.roast-note { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 16px; }
/* risk list */
.risk-panel { display: flex; flex-direction: column; }
.risk-list { display: flex; flex-direction: column; }
.risk-head {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1.2fr) 44px 52px;
  gap: 12px;
  align-items: center;
  height: 28px;
  color: var(--muted);
  font-size: var(--fs-small);
}
.risk-head .num, .risk-head .head-action { text-align: right; }
.risk-row {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1.2fr) 44px 52px;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}
.risk-row:first-child { border-top: 0; }
.who { min-width: 0; }
.who .name { display: block; font-size: 14px; font-weight: 500; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .sub { display: block; color: var(--faint); font-size: 12px; line-height: 15px; }
.signal { color: var(--muted); font-size: 13px; line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.risk-rank { color: var(--text); font-size: 13px; text-align: right; }
.risk-panel .row-action { text-align: right; justify-self: end; }

/* channels */
.channels-panel { display: flex; flex-direction: column; }
.channel-list { display: flex; flex-direction: column; flex: 1; }
.channel-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  flex: 1;
  min-height: 44px;
  border-top: 1px solid var(--rule);
}
.channel-row:first-child { border-top: 0; }
.channel-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.channel-label { font-size: 13px; }
.channel-value { color: var(--text); font-size: 13px; font-weight: 500; }
.channel-track { height: 2px; background: var(--rule); border-radius: 1px; overflow: hidden; }
.channel-track i { display: block; height: 2px; border-radius: 1px; background: var(--chart-muted); }
.channel-row:first-child .channel-track i { background: var(--text); }

/* ---------- subscribers view ---------- */
.subs-title { align-items: flex-end; }
.view-sub { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 20px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.field-search { position: relative; display: flex; align-items: center; width: 260px; max-width: 100%; }
.field-search svg { position: absolute; left: 10px; width: 14px; height: 14px; color: var(--faint); pointer-events: none; }
.field-search input {
  width: 100%;
  height: var(--control-height);
  padding: 0 10px 0 30px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
}
.toolbar .spacer { flex: 1; }
.result-count { color: var(--faint); font-size: var(--fs-small); }
.chips { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 6px; background: var(--raised); }
.chip {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; }
.chip .count { margin-left: 4px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count { color: var(--muted); }

.table-wrap { overflow: visible; }
.subs-table { width: 100%; border-collapse: collapse; }
.subs-table th {
  height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  background: var(--surface);
}
.subs-table th.n, .subs-table td.n { text-align: right; }
.subs-table td {
  height: 52px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  vertical-align: middle;
}
.subs-table tbody tr:last-child td { border-bottom: 0; }
.subs-table th:first-child, .subs-table td:first-child { padding-left: 0; }
.subs-table th:last-child, .subs-table td:last-child { padding-right: 0; }
.subs-table .name { display: block; font-size: 14px; font-weight: 500; line-height: 18px; }
.subs-table .id { display: block; color: var(--faint); font-family: var(--font-mono); /* taste-skill-ignore: IDs only */ font-size: 11px; line-height: 14px; }
.subs-table .signal-cell { max-width: 300px; }
.subs-table .signal-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subs-table .action-cell { text-align: right; }
.subs-table .risk-cell { font-variant-numeric: tabular-nums; }
.subs-cards { display: none; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 20px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-card);
  color: var(--muted);
  text-align: center;
}
.empty-state strong { color: var(--text); font-weight: 500; }
.empty-state .row-action { color: var(--text); }

/* ---------- message sheet ---------- */
.sheet-dialog {
  margin: 0 0 0 auto;
  width: min(440px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
}
.sheet-dialog::backdrop { background: rgba(23, 26, 22, 0.26); }
.sheet-dialog[open] { animation: sheet-in 180ms var(--ease-out); }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-inner { display: flex; flex-direction: column; min-height: 100%; padding: 20px 24px 24px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-head .meta { margin-top: 3px; color: var(--faint); font-size: 12px; line-height: 16px; }
.msg-context {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-card);
  background: var(--raised);
}
.msg-context .who { font-size: 14px; font-weight: 500; line-height: 18px; }
.msg-context .meta { color: var(--muted); font-size: 12px; line-height: 16px; }
.msg-context .signal { margin-top: 6px; color: var(--muted); font-size: 12px; white-space: normal; }
.msg-field { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; flex: 1; }
.msg-field label { font-size: 13px; font-weight: 500; }
.msg-field textarea {
  width: 100%;
  flex: 1;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-hint { margin-top: 10px; color: var(--faint); font-size: 12px; line-height: 16px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 861px) {
  .toolbar .field-search { display: none; }
}
body.menu-locked { overflow: hidden; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .span-8, .span-4 { grid-column: 1 / -1; }
  .rail { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); height: auto; }
  .table-wrap { display: none; }
  .subs-table { display: none; }
  .subs-cards { display: flex; flex-direction: column; }
}

/* ---------- phone: the frame disappears ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--t-ui) var(--ease-out), visibility 0s linear var(--t-ui);
    background: var(--ground);
    padding: 18px 16px;
    z-index: 50;
  }
  .sidebar.open { transform: none; visibility: visible; transition: transform var(--t-ui) var(--ease-out); }
  .sidebar-close { display: grid; }
  .brand { padding-right: 44px; }
  .menu-toggle { display: grid; }
  .mobile-brand { display: flex; }
  .main { min-height: 100svh; }
  .topbar { padding: 0 16px; gap: 10px; }
  .crumbs { display: none; }
  .search { display: none; }
  .topbar-actions { margin-left: auto; }
  .export-text { display: none; }
  .btn.export { width: var(--control-height); padding: 0; }
  .sheet {
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 16px;
    min-height: calc(100svh - var(--topbar-height));
  }
  .title-row { flex-direction: column; gap: 12px; margin-bottom: 14px; }
  .title-row h1 { font-size: 20px; line-height: 26px; }
  .finding { font-size: 13px; line-height: 19px; }
  .title-actions { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
  .title-actions .btn { flex: initial; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--border); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi { padding: 12px 14px; }
  .kpi.lead .kpi-value { font-size: 26px; line-height: 30px; }
  .kpi-value { font-size: 21px; line-height: 26px; }
  .rail { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 16px; }
  .chart-head { align-items: flex-start; }
  .chart-head .segmented { width: auto; }
  .chart-head .segmented button { flex: 0 0 auto; }
  .risk-head { display: none; }
  .risk-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who risk" "signal action";
    gap: 4px 12px;
    padding: 10px 0;
  }
  .risk-row .who { grid-area: who; }
  .risk-row .signal { grid-area: signal; white-space: normal; }
  .risk-row .risk-rank { grid-area: risk; }
  .risk-row .row-action { grid-area: action; }
  .sub-row { padding: 12px 0; border-top: 1px solid var(--rule); }
  .sub-row:first-child { border-top: 0; }
  .sub-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .sub-top .name { display: block; font-size: 14px; font-weight: 500; line-height: 18px; }
  .sub-top .id { display: block; color: var(--faint); font-family: var(--font-mono); /* taste-skill-ignore: IDs only */ font-size: 11px; line-height: 14px; }
  .sub-risk { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
  .sub-meta { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 17px; }
  .sub-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 6px; }
  .sub-bottom .signal { white-space: normal; }
  .sub-bottom .row-action { flex: none; }
  .field-search { width: 100%; }
  .toolbar .chips { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chip { width: 100%; }
  .toolbar .spacer { display: none; }
  .result-count { width: 100%; }
  .sheet-dialog { width: 100%; border-left: 0; }
  .dialog-inner { padding: 16px 16px 20px; min-height: 100svh; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; height: 40px; }
}

@media (max-width: 480px) {
  .kpi.lead .kpi-value { font-size: 22px; line-height: 27px; }
  .kpi-value { font-size: 19px; line-height: 24px; }
  .kpi-label { font-size: 13px; }
  .kpi-delta { font-size: 12px; }
  .kpi-delta .baseline { display: block; }
  .kpi-delta .sep { display: none; }
  .segmented { width: auto; }
  .segmented button { flex: 0 0 auto; }
  .chart-summary { font-size: 12px; }
  .roast-figure { font-size: 20px; }
}

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