/* ============================================================
   增长控制台 · GROWTH CONSOLE
   Internal ad-intelligence console — static, no build step.
   ============================================================ */

:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #fafbfb;
  --surface-3: #f6f8f8;
  --line: #e3e8e9;
  --line-soft: #eef2f2;
  --line-strong: #d2dadb;
  --ink: #182523;
  --ink-2: #42524f;
  --ink-3: #6d7c79;
  --ink-4: #93a09d;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e7f3f1;
  --accent-line: #cde5e1;
  --amber: #a05c08;
  --amber-soft: #fdf4e4;
  --amber-line: #f0ddb8;
  --red: #b3261e;
  --red-soft: #fdeeec;
  --red-line: #f3d2ce;
  --blue: #1d4ed8;
  --blue-soft: #ecf1fe;
  --sidebar: #13211f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas", monospace;
  --shadow-sm: 0 1px 2px rgba(17, 31, 29, 0.04);
  --shadow-md: 0 1px 2px rgba(17, 31, 29, 0.05), 0 6px 16px -10px rgba(17, 31, 29, 0.18);
  --radius: 10px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: #cdeae6; }

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  transition: top 0.15s;
}
.skip-link:focus { top: 8px; }

/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px 14px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(28, 71, 66, 0.55), transparent 62%),
    var(--sidebar);
  color: #cfdad7;
  border-right: 1px solid #0b1514;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
}

.brand-mark {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #14877d, #0b5c56);
  color: #eafaf7;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-en {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #8fb3ad;
  white-space: nowrap;
}
.brand-zh {
  font-size: 14.5px;
  font-weight: 600;
  color: #f0f6f4;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  color: #b9c8c4;
  text-decoration: none;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  transition: background 0.14s, color 0.14s;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.055); color: #f2f8f6; }
.nav-item[aria-current="page"] {
  background: rgba(28, 168, 154, 0.16);
  color: #ffffff;
  font-weight: 600;
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #2dd4bf;
}

.nav-icon {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.readonly-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: #9db5b0;
}
.lock-icon {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  margin-top: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-meta {
  font-size: 10.5px;
  color: #748f8a;
  line-height: 1.5;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 24px;
  flex-wrap: wrap;
  padding: 12px 26px;
  background: rgba(244, 246, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-head { min-width: 0; }
#page-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.page-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}
.page-meta .dot-sep { color: var(--ink-4); }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 1px;
}

.readonly-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
  background: #eef2f2;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
}

.range-group {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.range-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.6;
  transition: background 0.14s, color 0.14s;
  white-space: nowrap;
}
.range-btn:hover { background: var(--surface-3); color: var(--ink); }
.range-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover { background: var(--surface-3); border-color: #c4cfd0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--line); }
.btn-danger { color: var(--red); border-color: var(--red-line); background: var(--surface); }
.btn-danger:hover { background: var(--red-soft); border-color: #e7bab4; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.btn.is-busy .btn-icon { animation: spin 0.9s linear infinite; }

/* ------------------------------------------------------------------
   View & cards
   ------------------------------------------------------------------ */

#view {
  padding: 20px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1500px;
  width: 100%;
  outline: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head.plain { border-bottom: 0; padding-bottom: 2px; }
.card-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-title .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  text-transform: uppercase;
}
.card-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.55; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.card-body.tight { padding: 10px 16px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.empty-note {
  padding: 22px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------
   KPI
   ------------------------------------------------------------------ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.kpi-label .info-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--ink-4);
  font-size: 9px;
  display: grid;
  place-items: center;
  cursor: help;
  flex: 0 0 auto;
}
.kpi-value {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
}
.kpi-value .unit {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-4);
  margin-left: 3px;
  letter-spacing: 0;
}
.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 16px;
  font-size: 11px;
  color: var(--ink-4);
}
.kpi-foot .foot-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-spark { flex: 0 0 56px; height: 18px; }
.kpi-spark svg { display: block; width: 100%; height: 100%; }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta.good { color: var(--accent); }
.delta.bad { color: var(--red); }
.delta.muted { color: var(--ink-4); font-weight: 500; }

/* ------------------------------------------------------------------
   Badges, tags, code
   ------------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.6;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}
.badge.high { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.badge.medium { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.badge.info { background: #eef2f3; color: #4d5f5c; border-color: #e1e8e8; }
.badge.teal { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.badge.red { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: #d7e1fb; }
.badge.gray { background: #f1f4f4; color: var(--ink-3); border-color: var(--line); }
.badge.solid-teal { background: var(--accent); color: #fff; border-color: var(--accent); }
.badge .badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.platform { color: #365a55; background: #f0f6f5; border-color: #dce9e7; }
.tag.type { color: #5a5140; background: #faf6ee; border-color: #eee2cd; }

.code {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}
.mono { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

/* ------------------------------------------------------------------
   Toolbar / filters / segmented
   ------------------------------------------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-label {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}
.seg button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(17, 31, 29, 0.08), inset 0 0 0 1px var(--accent-line);
}

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  min-width: 210px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.search svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--ink-4);
  stroke-width: 2;
  stroke-linecap: round;
  flex: 0 0 auto;
}
.search input {
  border: 0;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 12.5px;
  min-width: 0;
}
.search input::placeholder { color: var(--ink-4); }

select.select {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12.5px;
  padding: 0 6px;
  color: var(--ink);
  cursor: pointer;
}

.hint { font-size: 11.5px; color: var(--ink-3); }
.hint strong { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------ */

.table-wrap { width: 100%; overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}
.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  white-space: nowrap;
}
.data tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.data tbody td.wrap { white-space: normal; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: #f8fbfa; }
.data tfoot td {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.data .num, .data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.table-pager .pager-info { font-size: 11.5px; color: var(--ink-3); }
.table-pager .pager-info strong { color: var(--ink-2); font-weight: 600; }
.table-pager .pager-btns { display: flex; gap: 6px; align-items: center; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  letter-spacing: inherit;
}
.sort-btn:hover { color: var(--accent-strong); }
.sort-btn .sort-arrow { font-size: 9px; opacity: 0.4; }
th[aria-sort="ascending"] .sort-btn,
th[aria-sort="descending"] .sort-btn { color: var(--accent-strong); }
th[aria-sort="ascending"] .sort-btn .sort-arrow,
th[aria-sort="descending"] .sort-btn .sort-arrow { opacity: 1; }

.account-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.account-link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.account-sub { font-size: 10.5px; color: var(--ink-4); font-family: var(--mono); margin-top: 1px; }

tr.row-click { cursor: pointer; }

/* ------------------------------------------------------------------
   Overview specifics
   ------------------------------------------------------------------ */

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}
.platform-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 0;
  overflow: hidden;
}
.platform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fbfdfc, #ffffff);
}
.platform-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.03em;
  font-family: var(--mono);
}
.platform-name .p-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.85;
}
.platform-acc { font-size: 10.5px; color: var(--ink-4); font-family: var(--mono); }
.metric-rows { padding: 4px 13px 8px; }
.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12.5px;
}
.metric-row:last-child { border-bottom: 0; }
.metric-label { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.metric-value { font-variant-numeric: tabular-nums; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.metric-value .delta { font-weight: 600; }
.platform-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 13px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--ink-3);
}

.insight-list { display: flex; flex-direction: column; }
.insight {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
}
.insight:first-child { border-top: 0; }
.insight-badge { padding-top: 1px; }
.insight-title { font-size: 13px; font-weight: 650; line-height: 1.5; }
.insight-text { margin-top: 3px; font-size: 12.5px; color: var(--ink-2); line-height: 1.65; }
.insight-evidence {
  margin-top: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 6px 6px 0;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-3);
  white-space: pre-wrap;
  word-break: break-word;
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
}
.strip-item {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
  transition: background 0.14s;
}
a.strip-item:hover { background: var(--surface-3); }
.strip-label { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.strip-value { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.strip-value.risk { color: var(--red); }
.strip-value.ok { color: var(--accent); }

.mini-diag {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  width: 100%;
  text-align: left;
  background: none;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.mini-diag:first-child { border-top: 0; }
.mini-diag:hover { background: var(--surface-3); }
.mini-diag-title { font-size: 12.8px; font-weight: 600; line-height: 1.5; }
.mini-diag-meta { margin-top: 3px; font-size: 11px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mini-diag-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------------
   Charts
   ------------------------------------------------------------------ */

.chart-wrap { display: flex; flex-direction: column; gap: 10px; }
.chart-legend { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px 9px 2px 7px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: opacity 0.14s, border-color 0.14s, background 0.14s;
}
.legend-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.legend-btn[aria-pressed="false"] { opacity: 0.42; text-decoration: line-through; }
.legend-btn[aria-pressed="false"] .legend-dot { background: var(--ink-4) !important; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.legend-unit { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }

.chart-canvas { width: 100%; min-width: 0; }
.chart-canvas svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
}

.chart text { font-family: var(--sans); font-size: 10.5px; fill: var(--ink-3); }
.chart .grid-line { stroke: #edf1f2; stroke-width: 1; }
.chart .axis-line { stroke: #dbe3e3; stroke-width: 1; }
.chart .zero-line { stroke: #c2cecd; stroke-width: 1.2; stroke-dasharray: 3 3; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: #fff; stroke-width: 1.4; }
.chart .bar { transition: opacity 0.12s; }
.chart .bar:hover { opacity: 0.82; }
.chart .tick-label { fill: var(--ink-3); }
.chart .x-label { fill: var(--ink-4); font-size: 10px; }
.chart .y-label { fill: var(--ink-4); font-size: 10px; }

/* ------------------------------------------------------------------
   Diagnosis
   ------------------------------------------------------------------ */

.diag-list { display: flex; flex-direction: column; }
.diag { border-top: 1px solid var(--line-soft); padding: 13px 16px; }
.diag:first-child { border-top: 0; }
.diag-head { display: flex; align-items: flex-start; gap: 10px; }
.diag-main { min-width: 0; flex: 1 1 auto; }
.diag-title { font-size: 13.5px; font-weight: 650; line-height: 1.5; }
.diag-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 9px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--ink-3);
}
.diag-finding { margin-top: 7px; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.diag-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.diag-panel { margin-top: 10px; }
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 22px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dotted #e4eaea;
  font-size: 12px;
  min-width: 0;
}
.kv:last-child { border-bottom: 0; }
.kv-key {
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}
.kv-val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  flex: 0 0 auto;
}
.kv-wide {
  grid-column: 1 / -1;
  align-items: flex-start;
}
.kv-wide .kv-val {
  flex: 1 1 0;
  text-align: left;
  white-space: normal;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  word-break: break-word;
}

/* ------------------------------------------------------------------
   Loop (actions)
   ------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.8px;
  padding: 10px 10px 9px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.14s, border-color 0.14s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--accent-strong);
  font-weight: 650;
  border-bottom-color: var(--accent);
}
.tab-count {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink-3);
  border-radius: 999px;
  padding: 0 5px;
  min-width: 18px;
  text-align: center;
  line-height: 15px;
}
.tab[aria-selected="true"] .tab-count { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.action-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.action-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.action-top .spacer { flex: 1 1 auto; }
.action-title-btn {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  font-size: 13.8px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
}
.action-title-btn:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.action-rat {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.target-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  font-size: 12px;
  flex-wrap: wrap;
}
.target-line .t-label { color: var(--ink-4); font-size: 11px; }
.target-line .t-value { font-family: var(--mono); font-weight: 600; font-size: 12.5px; }
.target-line .t-arrow { color: var(--ink-4); font-size: 12px; }
.target-line .t-target { color: var(--accent-strong); }
.action-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.action-meta .m-item { display: flex; gap: 8px; justify-content: space-between; min-width: 0; }
.action-meta .m-item > span:first-child { flex: 0 0 auto; }
.action-meta .m-item span:last-child {
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.verdict-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
  flex-wrap: wrap;
  border-top: 1px dashed var(--line-soft);
  padding-top: 8px;
}
.action-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.action-foot .spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------------
   Playbook
   ------------------------------------------------------------------ */

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.pb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.pb-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pb-top .spacer { flex: 1 1 auto; }
.pb-title { font-size: 13.8px; font-weight: 650; line-height: 1.45; }
.pb-statement { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.pb-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11px;
  color: var(--ink-3);
  border-top: 1px dashed var(--line-soft);
  padding-top: 8px;
}
.pb-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.pb-foot .spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------------
   Supply / data health
   ------------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.stat {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-label { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.stat-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; white-space: nowrap; }
.stat-value.risk { color: var(--red); }
.stat-foot { font-size: 10.5px; color: var(--ink-4); }
.stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); }

.callout {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--surface-2);
}
.callout .c-icon {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.4px solid currentColor;
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--mono);
}
.callout.warn { background: var(--amber-soft); border-color: var(--amber-line); color: #7a4706; }
.callout.danger { background: var(--red-soft); border-color: var(--red-line); color: #8a2019; }
.callout.info { background: #f3f6f7; border-color: var(--line); color: var(--ink-2); }
.callout.teal { background: var(--accent-soft); border-color: var(--accent-line); color: #0a4f49; }
.callout strong { font-weight: 650; }

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
}

.def-list { display: flex; flex-direction: column; }
.def-item {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 4px 18px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.def-item:first-child { border-top: 0; }
.def-item.single { grid-template-columns: minmax(0, 1fr); }
.def-key { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); font-weight: 600; word-break: break-all; }
.def-text { color: var(--ink-3); line-height: 1.65; }

.warn-list { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------------
   Modal
   ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 20px 40px;
  background: rgba(15, 27, 26, 0.46);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  animation: fade-in 0.14s ease-out;
}
.modal {
  width: min(880px, 100%);
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 24px 64px rgba(10, 24, 22, 0.3);
  animation: modal-in 0.16s ease-out;
  overflow: hidden;
}
.modal.wide { width: min(1000px, 100%); }
.modal.narrow { width: min(560px, 100%); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 16px; font-weight: 650; line-height: 1.45; }
.modal-sub {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
}
.icon-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.14s, color 0.14s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal-body {
  padding: 15px 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-foot .spacer { flex: 1 1 auto; }
.modal-foot .note { font-size: 11.5px; color: var(--ink-3); }
.modal-section-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  text-transform: uppercase;
  font-family: var(--mono);
  margin-bottom: -6px;
}
.modal-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}
.modal-kpi { background: var(--surface); padding: 9px 12px; display: flex; flex-direction: column; gap: 2px; }
.modal-kpi .k-label { font-size: 10.5px; color: var(--ink-3); }
.modal-kpi .k-value { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.modal-kpi .k-value.risk { color: var(--red); }

.timeline { display: flex; flex-direction: column; }
.tl-item {
  position: relative;
  padding: 0 0 12px 18px;
  border-left: 1px solid var(--line);
  margin-left: 5px;
}
.tl-item:last-child { padding-bottom: 0; border-left-color: transparent; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.tl-when { font-size: 10.5px; color: var(--ink-4); font-family: var(--mono); }
.tl-what { font-size: 12.5px; color: var(--ink); margin-top: 1px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.tl-note { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.6; }

.note-field { display: flex; flex-direction: column; gap: 5px; }
.note-field label { font-size: 11.5px; color: var(--ink-3); }
.note-field textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12.5px;
  line-height: 1.6;
  outline: none;
  background: var(--surface);
}
.note-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.btn-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------
   States: loading / error / toasts
   ------------------------------------------------------------------ */

.view-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 22px 4px;
  font-size: 13px;
  color: var(--ink-3);
}
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.8px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.skeleton-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-line {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, #edf1f1 25%, #f6f8f8 37%, #edf1f1 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-line.w30 { width: 30%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w70 { width: 70%; }
.skeleton-line.tall { height: 150px; border-radius: 8px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }

.state-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.state-card .state-title { font-size: 14px; font-weight: 650; }
.state-card .state-text { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; max-width: 480px; word-break: break-word; }
.state-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  color: var(--amber);
  font-weight: 700;
  font-family: var(--mono);
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #142a28;
  color: #e9f3f1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(10, 24, 22, 0.25);
  font-size: 12.5px;
  line-height: 1.55;
  animation: toast-in 0.16s ease-out;
  word-break: break-word;
}
.toast.error { background: #3a1714; border-color: #86302a; color: #ffe9e6; }
.toast.ok { background: #0c3b36; border-color: #2a6f66; color: #e6faf6; }
.toast-icon {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  margin-top: 1px;
  border: 1px solid currentColor;
  opacity: 0.85;
}
.toast-text { flex: 1 1 auto; min-width: 0; }
.toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
  margin-top: 1px;
}
.toast-close:hover { opacity: 1; }

.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 26px 18px;
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  padding: 12px 16px;
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red);
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
}

/* ------------------------------------------------------------------
   Small utilities
   ------------------------------------------------------------------ */

.meter {
  display: inline-block;
  width: 100%;
  max-width: 140px;
  height: 5px;
  border-radius: 4px;
  background: #eef2f2;
  overflow: hidden;
  vertical-align: middle;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  opacity: 0.6;
}
.dot-sep { color: var(--ink-4); }

.pb-evidence { margin-top: 1px; }
.pb-evidence summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--ink-3);
  list-style-position: inside;
}
.pb-evidence summary:hover { color: var(--accent-strong); }
.pb-evidence[open] summary { color: var(--ink-2); }

.callout .c-icon { flex: 0 0 15px; }

/* ------------------------------------------------------------------
   Animation
   ------------------------------------------------------------------ */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 1320px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .action-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .skeleton-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .split, .split.wide-left { grid-template-columns: minmax(0, 1fr); }
  .readonly-note { order: 3; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px 10px; }
  .brand { justify-content: center; padding: 0 0 12px; }
  .brand-text, .nav-label, .sidebar-meta, .readonly-line span { display: none; }
  .sidebar-foot { padding: 10px 0 4px; display: grid; place-items: center; }
  .readonly-line { gap: 0; }
  .readonly-line .lock-icon { margin-top: 0; }
  .nav-item { justify-content: center; padding: 0; height: 40px; }
  .nav-item[aria-current="page"]::before { left: -8px; }
  .topbar { padding: 10px 16px; }
  #view { padding: 16px 16px 32px; }
  .page-foot { padding: 0 16px 16px; }
  .readonly-note { font-size: 10px; padding: 3px 7px; }
  .action-grid, .playbook-grid { grid-template-columns: minmax(0, 1fr); }
  .def-item { grid-template-columns: minmax(0, 1fr); }
  .modal-backdrop { padding: 2vh 10px 20px; }
  .modal-body { max-height: calc(100vh - 200px); }
}

@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-controls { justify-content: flex-start; width: 100%; }
  .kpi-value { font-size: 20px; }
  .card-head { flex-direction: column; align-items: flex-start; }
}

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

/* ============================================================
   READABILITY OVERRIDE — appended (2026-12-01)
   One block, scoped to body / .app. Raises the whole console to a
   16px / weight-500 base with heavier headings and 14px tables.
   Nothing above this line is rewritten.
   ============================================================ */

body {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
}

.app {
  font-size: 16px;
  font-weight: 500;
}

/* --- base text -------------------------------------------------- */
.app .skip-link { font-size: 14px; font-weight: 600; }
.app .view-loading { font-size: 14.5px; font-weight: 600; gap: 9px; }
.app .empty-note { font-size: 14px; }
.app .mono { font-size: 13px; }
.app .hint { font-size: 13px; }
.app .code { font-size: 11.5px; }
.app .tag { font-size: 11.5px; }
.app .badge { font-size: 12px; font-weight: 650; padding: 2px 8px; }
.app .delta { font-size: 12.5px; }
.app .state-card .state-title { font-size: 16px; font-weight: 700; }
.app .state-card .state-text { font-size: 14px; }
.app .toast { font-size: 14px; }
.app .toast-icon { font-size: 11px; }
.app .toast-close { font-size: 16px; }
.app .page-foot { font-size: 12px; }
.app .noscript { font-size: 14px; }

/* --- headings & page chrome ------------------------------------- */
.app h1, .app h2, .app h3, .app h4 { font-weight: 700; }
.app #page-title { font-size: 22px; font-weight: 700; letter-spacing: 0; }
.app .page-meta { font-size: 13.5px; }
.app .readonly-note { font-size: 12.5px; }
.app .toolbar-label { font-size: 12.5px; font-weight: 600; }
.app .card-title { font-size: 15.5px; font-weight: 700; }
.app .card-title .eyebrow { font-size: 11.5px; font-weight: 700; }
.app .card-sub { font-size: 13.5px; line-height: 1.6; }
.app .modal-title { font-size: 19px; font-weight: 700; }
.app .modal-sub { font-size: 13px; }
.app .modal-section-title { font-size: 12.5px; font-weight: 700; }
.app .modal-foot .note { font-size: 13px; }
.app .modal-kpi .k-label { font-size: 12px; }
.app .modal-kpi .k-value { font-size: 18px; }
.app .modal-text { font-size: 14px; line-height: 1.7; color: var(--ink-2); }

/* --- sidebar / brand / nav -------------------------------------- */
.app .brand-mark { font-size: 12.5px; }
.app .brand-en { font-size: 11.5px; }
.app .brand-zh { font-size: 15.5px; font-weight: 700; }
.app .nav-item { font-size: 15px; font-weight: 600; height: 42px; }
.app .nav-icon { flex-basis: 18px; width: 18px; height: 18px; }
.app .readonly-line { font-size: 12.5px; }
.app .sidebar-meta { font-size: 11.5px; }

/* --- buttons / controls ----------------------------------------- */
.app .btn { font-size: 14px; font-weight: 600; height: 36px; padding: 0 14px; gap: 7px; }
.app .btn.btn-sm { font-size: 13px; font-weight: 600; height: 30px; padding: 0 10px; }
.app .btn-icon { width: 15px; height: 15px; }
.app .range-btn { font-size: 14px; font-weight: 600; padding: 5px 12px; }
.app .seg button { font-size: 13.5px; font-weight: 600; }
.app .search input { font-size: 14px; }
.app select.select { font-size: 14px; }
.app .tab { font-size: 13.5px; font-weight: 600; }
.app .tab-count { font-size: 12px; }
.app .legend-btn { font-size: 13px; }
.app .legend-unit { font-size: 11.5px; }
.app .pb-evidence summary { font-size: 13px; }

/* --- tables ------------------------------------------------------ */
.app table.data { font-size: 14px; font-weight: 500; }
.app .data thead th { font-size: 13.5px; font-weight: 650; padding: 10px 12px; }
.app .data tbody td { font-size: 14px; font-weight: 500; padding: 9px 12px; }
.app .data tfoot td { font-size: 13.5px; font-weight: 600; }
.app .table-pager .pager-info { font-size: 13px; }
.app .sort-btn .sort-arrow { font-size: 11px; }
.app .account-sub { font-size: 12px; }

/* --- KPI --------------------------------------------------------- */
.app .kpi { padding: 14px 16px 13px; gap: 5px; }
.app .kpi-label { font-size: 13.5px; font-weight: 600; }
.app .kpi-label .info-dot { font-size: 11px; width: 15px; height: 15px; }
.app .kpi-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.app .kpi-value .unit { font-size: 13px; }
.app .kpi-foot { font-size: 12.5px; min-height: 18px; }
.app .strip-label { font-size: 12.5px; }
.app .strip-value { font-size: 22px; font-weight: 700; }
.app .stat-label { font-size: 12.5px; }
.app .stat-value { font-size: 23px; font-weight: 700; }
.app .stat-foot { font-size: 12px; }

/* --- cards / insights / platform -------------------------------- */
.app .platform-name { font-size: 14px; }
.app .platform-acc { font-size: 12px; }
.app .platform-foot { font-size: 12.5px; }
.app .metric-row { font-size: 14px; padding: 6px 0; }
.app .metric-label { font-size: 13.5px; }
.app .insight-title { font-size: 14.5px; font-weight: 650; }
.app .insight-text { font-size: 14px; line-height: 1.65; }
.app .insight-evidence { font-size: 12.5px; }
.app .mini-diag-title { font-size: 14px; font-weight: 600; }
.app .mini-diag-meta { font-size: 12.5px; }
.app .mini-diag-text { font-size: 13.5px; }
.app .diag-title { font-size: 15px; font-weight: 650; }
.app .diag-meta { font-size: 12.5px; }
.app .diag-finding { font-size: 14px; line-height: 1.7; }
.app .kv { font-size: 13px; }
.app .kv-val { font-size: 13px; }
.app .kv-wide .kv-val { font-size: 13.5px; }
.app .def-item { font-size: 13.5px; }
.app .def-key { font-size: 13px; }
.app .callout { font-size: 13.5px; line-height: 1.65; }
.app .callout .c-icon { font-size: 12px; }
.app .banner { font-size: 13.5px; }

/* --- actions / playbook ----------------------------------------- */
.app .action-title-btn { font-size: 15px; font-weight: 600; }
.app .action-rat { font-size: 13px; }
.app .target-line { font-size: 13px; }
.app .target-line .t-label { font-size: 12.5px; }
.app .target-line .t-value { font-size: 13.5px; }
.app .target-line .t-arrow { font-size: 13px; }
.app .action-meta { font-size: 13px; }
.app .action-meta .m-item span:last-child { font-size: 12.5px; }
.app .verdict-row { font-size: 12.5px; }
.app .pb-title { font-size: 15px; font-weight: 650; }
.app .pb-statement { font-size: 14px; line-height: 1.7; }
.app .pb-meta { font-size: 12.5px; }

/* --- timeline / note fields ------------------------------------- */
.app .tl-when { font-size: 12px; }
.app .tl-what { font-size: 14px; }
.app .tl-note { font-size: 13px; }
.app .note-field label { font-size: 13px; }
.app .note-field textarea { font-size: 14px; }

/* --- charts (labels >= 12px) ------------------------------------ */
.app .chart text { font-size: 13.5px; font-weight: 500; }
.app .chart .x-label,
.app .chart .y-label { font-size: 13px; }
.app .chart-empty { font-size: 14px; }

/* --- spacing so the larger type is not cramped ------------------ */
.app #view { gap: 18px; padding: 22px 26px 44px; }
.app .topbar { padding: 14px 26px; }
.app .card-head { padding: 15px 18px 13px; gap: 12px 18px; }
.app .card-body:not(.flush) { padding: 16px 18px; }
.app .card-body.tight:not(.flush) { padding: 12px 18px; }
.app .nav { gap: 3px; }
.app .kpi-grid { gap: 14px; }
.app .toolbar { padding: 12px 18px; }
.app .table-pager { padding: 10px 16px; }

@media (max-width: 720px) {
  .app #page-title { font-size: 19px; }
  .app .kpi-value { font-size: 24px; }
  .app #view { padding: 16px 16px 36px; }
}

/* ============================================================
   LOGIN — full-screen split layout (new)
   ============================================================ */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    radial-gradient(70% 55% at 12% 6%, #1b4a44 0%, transparent 62%),
    #0d1a18;
  color: #cfe3df;
}

.boot-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #14877d, #0b5c56);
  color: #eafaf7;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.boot-screen .spinner {
  width: 18px;
  height: 18px;
  border-width: 2.2px;
  border-color: rgba(255, 255, 255, 0.22);
  border-top-color: #2dd4bf;
}

.boot-text { font-size: 14px; font-weight: 500; color: #9fc3bd; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(460px, 0.94fr);
  background: #ffffff;
}

.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding: clamp(32px, 4.4vw, 64px);
  background: radial-gradient(120% 85% at 6% 0%, #1d4f49 0%, #122523 48%, #0b1615 100%);
  color: #e7f2f0;
}

.login-brand-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(85% 78% at 18% 8%, #000 0%, transparent 76%);
  mask-image: radial-gradient(85% 78% at 18% 8%, #000 0%, transparent 76%);
}

.login-brand-glow {
  position: absolute;
  width: 640px;
  height: 640px;
  right: -200px;
  top: -220px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.22), transparent 62%);
}

.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.login-brand-top { display: flex; align-items: center; gap: 12px; }

.login-mark {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #14877d, #0b5c56);
  color: #eafaf7;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.login-brand-name { display: flex; flex-direction: column; gap: 1px; }
.login-brand-en {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: #8fb3ad;
}
.login-brand-zh { font-size: 17px; font-weight: 700; letter-spacing: 0.06em; color: #f2f9f7; }

.login-headline {
  margin: 0;
  font-size: clamp(30px, 3.1vw, 44px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.login-lede {
  font-size: 16.5px;
  line-height: 1.7;
  font-weight: 500;
  color: rgba(214, 235, 231, 0.82);
  max-width: 520px;
}

.login-props {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-props li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14.5px;
  line-height: 1.65;
  font-weight: 500;
  color: rgba(203, 228, 223, 0.78);
}
.login-props strong {
  display: block;
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 650;
  margin-bottom: 2px;
}
.login-prop-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #7fc9bf;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  margin-top: 1px;
}

.login-badges { display: flex; flex-wrap: wrap; gap: 10px; }
.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #cfe6e1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.login-badge svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: #6fc3b8;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-brand-foot {
  position: absolute;
  left: clamp(32px, 4.4vw, 64px);
  bottom: clamp(20px, 2.6vw, 34px);
  z-index: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(160, 196, 190, 0.72);
}

.login-panel {
  display: grid;
  place-items: center;
  padding: clamp(24px, 4vw, 56px);
  background:
    radial-gradient(70% 50% at 100% 0%, rgba(15, 118, 110, 0.07), transparent 60%),
    linear-gradient(180deg, #fbfcfc, #f3f6f6 60%, #eef3f2);
}

.login-card {
  width: min(430px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(17, 31, 29, 0.05), 0 26px 64px -34px rgba(17, 31, 29, 0.32);
  padding: 32px 32px 26px;
}

.login-card-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.login-card-head p {
  margin-top: 6px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-3);
}

#login-form { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; }

.login-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.login-field label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.login-field input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 500;
  background: #ffffff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field input::placeholder { color: var(--ink-4); font-weight: 400; }
.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.login-pw { position: relative; }
.login-pw input { padding-right: 48px; }
.login-pw-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.login-pw-toggle:hover { background: var(--surface-3); color: var(--ink); }
.login-pw-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.login-pw-toggle[aria-pressed="true"] { color: var(--accent-strong); }

.login-error {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
}

.login-submit {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.login-submit:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.login-submit:disabled { opacity: 0.72; cursor: progress; }
.login-submit-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}
.login-submit.is-busy .login-submit-spinner { display: inline-block; }

.login-card-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-3);
}
.login-card-meta { color: var(--ink-4); }

@media (max-width: 1080px) {
  .login-screen { grid-template-columns: minmax(0, 1fr) minmax(410px, 0.95fr); }
  .login-headline { font-size: 34px; }
  .login-lede { font-size: 15.5px; }
}

@media (max-width: 920px) {
  .login-screen { grid-template-columns: minmax(0, 1fr); }
  .login-brand { min-height: auto; padding: 26px 24px 26px; gap: 22px; }
  .login-brand-content { gap: 16px; }
  .login-props { display: none; }
  .login-lede { font-size: 14.5px; }
  .login-headline { font-size: 26px; }
  .login-brand-foot { display: none; }
  .login-panel { padding: 26px 18px 44px; }
  .login-card { width: min(460px, 100%); }
}

@media (max-width: 560px) {
  .login-brand { padding: 20px 18px 22px; }
  .login-headline { font-size: 22px; }
  .login-badge { font-size: 12px; padding: 5px 10px; }
  .login-card { padding: 22px 20px 20px; }
  .login-card-head h1 { font-size: 22px; }
}

/* ============================================================
   SIDEBAR USER BLOCK (new)
   ============================================================ */

.user-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.user-ident { display: flex; align-items: center; gap: 9px; min-width: 0; }

.user-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #1a9a8f, #0b5c56);
  color: #eafaf7;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.user-name {
  font-size: 13.5px;
  font-weight: 650;
  color: #f0f8f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11.5px;
  font-weight: 600;
  color: #9fc3bd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role.role-admin { color: #8fd9cf; }

.user-logout {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #c9dad6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.user-logout:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; border-color: rgba(255, 255, 255, 0.24); }
.user-logout:disabled { opacity: 0.5; cursor: progress; }
.user-logout svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 900px) {
  .user-block {
    gap: 6px;
    padding: 6px 0;
    background: transparent;
    border: 0;
  }
  .user-ident { justify-content: center; }
  .user-info { display: none; }
  .user-logout { padding: 6px; }
  .user-logout-label { display: none; }
}

/* ============================================================
   PERSONAL ASSISTANT (new)
   ============================================================ */

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.assistant-main { display: flex; flex-direction: column; min-width: 0; }

.scope-banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 12px 18px 0;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}
.scope-icon { flex: 0 0 17px; margin-top: 1px; }
.scope-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scope-text strong { font-weight: 700; }
.scope-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: #3c6b66;
}

.chat-log {
  height: clamp(320px, 42vh, 520px);
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-empty {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
}
.chat-empty-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 700;
}
.chat-empty-title { font-size: 15px; font-weight: 650; color: var(--ink); }
.chat-empty-text { margin-top: 4px; font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }

.msg { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}
.msg.user .msg-avatar { background: #e7ecf7; color: #33507f; }
.msg-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 86%; }
.msg.user .msg-main { align-items: flex-end; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-4);
}
.msg-author { font-weight: 600; color: var(--ink-3); }
.msg-model {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 5px;
  padding: 1px 5px;
}
.msg-bubble {
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}
.msg.assistant .msg-bubble { border-bottom-left-radius: 4px; }
.msg.assistant .msg-bubble strong { font-weight: 700; color: var(--ink); }
.msg.user .msg-bubble strong { font-weight: 700; color: #ffffff; }
.msg.user .msg-bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.msg-loading { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-weight: 600; }
.msg-loading .spinner { width: 14px; height: 14px; }

.chat-error {
  margin: 0 18px 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.55;
}

.inline-note {
  margin: 10px 18px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
}
.inline-note.is-error { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }

.suggest-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 18px 6px;
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}
.suggest-label {
  flex: 0 0 auto;
  padding-top: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-4);
  white-space: nowrap;
}
.suggest-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); }

.composer {
  margin: 8px 18px 18px;
  padding: 8px 11px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 180px;
  border: 0;
  outline: none;
  resize: vertical;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
}
.composer textarea::placeholder { color: var(--ink-4); font-weight: 400; }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid var(--line-soft);
}

.assistant-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.assistant-rail .card-body { padding: 6px 18px 14px; }
.rail-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-2);
}

@media (max-width: 1240px) {
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
  .assistant-rail { flex-direction: row; }
  .assistant-rail .card { flex: 1 1 0; }
}
@media (max-width: 760px) {
  .assistant-rail { flex-direction: column; }
  .chat-log { height: clamp(300px, 50vh, 460px); padding: 14px; }
  .msg-main { max-width: 92%; }
  .scope-banner, .suggest-wrap, .composer, .chat-error, .inline-note { margin-left: 12px; margin-right: 12px; }
}

/* ============================================================
   ACCOUNT MANAGEMENT (new)
   ============================================================ */

.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.user-cell-username { font-weight: 600; margin-right: 6px; }
.scope-cell { max-width: 300px; white-space: normal; line-height: 1.5; }

.admin-form { display: flex; flex-direction: column; gap: 16px; }

.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.inline-pw { display: flex; align-items: center; gap: 8px; }
.inline-pw input { flex: 1 1 auto; }

.form-error {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.55;
}
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.people-picker {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.people-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.people-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--ink-4);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.people-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.people-search input::placeholder { color: var(--ink-4); font-weight: 400; }
.people-list {
  max-height: 276px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.people-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.people-item:hover { background: var(--surface-3); }
.people-item input {
  margin: 0;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.people-item-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.people-nick { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-key { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.people-dept { flex: 0 0 auto; font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.people-selected {
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-top: 1px solid var(--accent-line);
  word-break: break-word;
}
.people-selected.is-empty { color: var(--ink-3); background: var(--surface-2); border-top-color: var(--line-soft); }
.people-empty { padding: 14px; text-align: center; font-size: 13px; color: var(--ink-3); }

.onetime {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
}
.onetime-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.onetime-head strong { font-size: 14.5px; font-weight: 700; color: var(--accent-strong); }
.onetime-head span { font-size: 12.5px; font-weight: 500; color: #33635e; }
.onetime-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--accent-line);
}
.onetime-label {
  flex: 0 0 130px;
  font-size: 12.5px;
  font-weight: 600;
  color: #33635e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.onetime-value {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}
.onetime-actions { display: flex; gap: 8px; margin-top: 10px; }

@media (max-width: 1080px) {
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .people-list { grid-template-columns: minmax(0, 1fr); }
  .onetime-row { flex-wrap: wrap; }
  .onetime-label { flex-basis: 100%; }
}

/* ============================================================
   END READABILITY OVERRIDE / NEW PAGES
   ============================================================ */
/* Change-password action in the sidebar user block */
.user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.user-actions .user-logout { width: 100%; }
@media (max-width: 900px) {
  .user-actions { grid-template-columns: 1fr; }
}

/* Simplified assistant layout without the explanatory rail */
.assistant-layout.assistant-solo { grid-template-columns: minmax(0, 1fr); }

/* ============================================================
   CHART INTERACTION V2 + AUDIT LOG  (appended 2026-12-01)
   ============================================================ */

/* --- chart shell: legend -> latest -> scrollable canvas + tooltip --- */
.chart-wrap { display: flex; flex-direction: column; gap: 8px; }
.chart-latest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  line-height: 1.5;
}
.chart-latest .latest-label { color: var(--ink-4); font-weight: 600; }
.chart-latest .latest-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chart-latest .latest-date { font-family: var(--mono); font-size: 12px; color: var(--ink-4); }
.chart-latest .latest-name { color: var(--ink-2); }
.chart-latest .latest-value { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-latest .latest-empty { color: var(--ink-4); }

.chart-body { position: relative; min-width: 0; }
.chart-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.chart-scroll::-webkit-scrollbar { height: 8px; }
.chart-scroll::-webkit-scrollbar-thumb { background: #d5dddd; border-radius: 4px; }

.chart-tooltip {
  position: absolute;
  z-index: 6;
  min-width: 132px;
  max-width: min(300px, calc(100% - 16px));
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(19, 33, 31, 0.95);
  color: #eaf5f2;
  box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.55);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
}
.chart-tip-date { margin-bottom: 4px; color: #fff; font-weight: 700; font-size: 12.5px; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 2px; }
.chart-tip-name { color: #cfe2de; padding-right: 14px; }
.chart-tip-val { margin-left: auto; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-tip-empty { color: #9db5b0; }

/* --- chart drawing details --- */
.app .chart-canvas { width: 100%; min-width: 0; }
.app .chart-canvas svg { display: block; width: 100%; height: auto; min-width: 880px; }
.app .chart .grid-line { stroke: #eef2f3; stroke-width: 1; }
.app .chart .axis-line { stroke: #dbe3e3; stroke-width: 1; }
.app .chart .zero-line { stroke: #9aa8a5; stroke-width: 1.4; stroke-dasharray: 5 3; }
.app .chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.app .chart .series-area { stroke: none; pointer-events: none; }
.app .chart .series-dot { stroke: #fff; stroke-width: 1.2; pointer-events: none; }
.app .chart .bar { cursor: pointer; transition: opacity 0.12s linear; }
.app .chart .bar-hover { stroke: #182523; stroke-width: 1.5; pointer-events: none; }
.app .chart .hover-layer { pointer-events: none; }
.app .chart .hover-line { stroke: #5b6f6b; stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.8; }
.app .chart .hover-dot { stroke: #fff; stroke-width: 1.6; pointer-events: none; }
.app .chart text { font-family: var(--sans); font-size: 13px; font-weight: 500; }
.app .chart .x-label, .app .chart .y-label { fill: var(--ink-3); font-size: 13px; }

/* --- audit log --- */
.audit-toolbar { align-items: center; }
.audit-filter { display: inline-flex; align-items: center; gap: 7px; }
.audit-filter select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}
.audit-filter select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.audit-search { width: 210px; }
.audit-time { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.audit-user { margin-right: 6px; font-weight: 600; }
.audit-target { max-width: 260px; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); word-break: break-all; }
.audit-path { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-path .mono { font-size: 12.5px; color: var(--ink-2); }
.audit-ip { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.audit-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
}
.audit-code.ok { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.audit-code.warn { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.audit-code.err { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.audit-code.gray { background: #f1f4f4; color: var(--ink-3); border-color: var(--line); }

@media (max-width: 900px) {
  .audit-search { width: 100%; }
  .chart-tooltip { max-width: calc(100% - 12px); }
}
@media (max-width: 720px) {
  .chart-latest { gap: 3px 10px; }
  .chart-latest .latest-item { white-space: normal; }
}

/* sidebar quick actions: keep both labels on one line */
.user-actions { gap: 5px; }
.user-actions .user-logout { padding: 6px 4px; gap: 4px; white-space: nowrap; }
.user-actions .user-logout svg { width: 13px; height: 13px; }
.user-actions .user-logout-label { font-size: 11.5px; white-space: nowrap; }

/* ============================================================
   STRUCTURE PAGE + OVERVIEW SECONDARY KPI  (appended 2026-12-01)
   ============================================================ */

/* secondary KPI row under the main 6 cards */
.app .kpi-grid.kpi-secondary { gap: 12px; }
.app .kpi-grid.kpi-secondary .kpi { padding: 11px 14px 10px; gap: 3px; border-style: dashed; background: var(--surface-2); }
.app .kpi-grid.kpi-secondary .kpi-label { font-size: 12.5px; font-weight: 600; }
.app .kpi-grid.kpi-secondary .kpi-value { font-size: 21px; font-weight: 700; }
.app .kpi-grid.kpi-secondary .kpi-value .unit { font-size: 12px; }
.app .kpi-grid.kpi-secondary .kpi-foot { font-size: 12px; }

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

/* structure page */
.structure-toolbar { gap: 10px 16px; }
.structure-search { width: 230px; }

.structure-totals {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.structure-total { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.structure-total .st-label { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.structure-total .st-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mat-name,
.mat-name-link {
  display: block;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mat-name { font-weight: 600; color: var(--ink); }
.mat-name-link { text-align: left; }
#structure-table td .account-sub { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-chart-block { margin-top: 16px; padding-top: 4px; }
.modal-chart-block .modal-section-title { margin-bottom: 6px; }

@media (max-width: 1320px) {
  .structure-totals { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .structure-search { width: 100%; }
  .structure-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   ASSISTANT CONVERSATION LAYOUT  (appended 2026-12-01)
   ============================================================ */

.chat-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 170px);
  align-items: stretch;
}

/* ---- left conversation rail ---- */
.chat-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 170px);
  min-height: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.chat-side-head { padding: 16px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.chat-side-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.chat-new-btn {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--accent-strong);
  border-radius: 12px;
  background: linear-gradient(135deg, #12857c, #0b5c56);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 18px -12px rgba(11, 92, 86, 0.7);
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s;
}
.chat-new-btn:hover { background: linear-gradient(135deg, #0f766e, #0a4f49); transform: translateY(-1px); }
.chat-new-btn:active { transform: translateY(0); }
.chat-new-btn-sm { width: auto; height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }

.chat-session-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.chat-session {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.chat-session:hover { background: var(--surface-3); }
.chat-session.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.chat-session-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-session-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-session.is-active .chat-session-title { color: var(--accent-strong); }
.chat-session-count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
}
.chat-session-last {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
}
.chat-session-time { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.chat-session-empty { padding: 18px 12px; font-size: 13px; line-height: 1.65; color: var(--ink-3); text-align: center; }
.chat-side-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line-soft); }

/* ---- main conversation ---- */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - 170px);
  min-height: 520px;
  background: linear-gradient(180deg, #ffffff, #fbfdfc 42%, #f7faf9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px clamp(18px, 2.4vw, 26px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(6px);
}
.chat-head-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-title {
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head-meta { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-width: 0; }
.chat-model { flex: 0 0 auto; }
.chat-scope { font-size: 12.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-scope strong { color: var(--ink-2); font-weight: 700; }
.chat-count { font-size: 12px; color: var(--ink-4); }

.chat-mobile-bar { display: none; gap: 8px; align-items: center; padding: 10px 12px 0; }
.chat-sessions-select {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow-y: auto;
  padding: 22px clamp(18px, 2.6vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
.chat-message-list { display: flex; flex-direction: column; gap: 20px; }
.chat-loading {
  margin: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-3);
}

/* messages inside the new shell */
.chat-shell .msg { gap: 12px; }
.chat-shell .msg-main { max-width: min(88%, 860px); gap: 5px; }
.chat-shell .msg-avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 12.5px; }
.chat-shell .msg-meta { gap: 9px; font-size: 12px; }
.chat-shell .msg-bubble {
  max-width: 820px;
  padding: 13px 17px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.78;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px -22px rgba(17, 31, 29, 0.5);
}
.chat-shell .msg.assistant .msg-bubble { border-bottom-left-radius: 5px; }
.chat-shell .msg.user .msg-bubble {
  background: linear-gradient(135deg, #11776f, #0a544e);
  border-color: #0a544e;
  color: #ffffff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 14px 26px -18px rgba(10, 84, 78, 0.65);
}
.chat-shell .msg.user .msg-bubble strong { color: #ffffff; }
.chat-shell .msg.assistant .msg-bubble strong { color: var(--ink); }
.chat-typing .msg-bubble { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-3); font-weight: 600; }
.typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: chat-dot 1.05s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.28; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.msg-tools { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .msg-tools,
.msg:focus-within .msg-tools { opacity: 1; }
.msg-tool {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.msg-tool:hover { color: var(--accent-strong); border-color: var(--accent-line); background: var(--accent-soft); }
.msg.user .msg-tools { justify-content: flex-end; }
@media (hover: none) {
  .msg-tools { opacity: 1; }
}

.msg-bubble.is-editing {
  width: min(820px, 100%);
  background: var(--surface);
  border: 1px solid var(--accent-line);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
  padding: 10px;
}
.chat-shell .msg.user .msg-bubble.is-editing {
  background: var(--surface);
  border-color: var(--accent-line);
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}
.chat-shell .msg.user .msg-bubble.is-editing .msg-edit-area { color: var(--ink); }
.msg-edit-area {
  width: 100%;
  min-height: 76px;
  max-height: 200px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
}
.msg-edit-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* welcome / empty state */
.chat-welcome { margin: auto; width: 100%; max-width: 800px; padding: 8px 4px 16px; }
.chat-welcome-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(150deg, #13857c, #0b5c56);
  color: #eafaf7;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 26px -16px rgba(11, 92, 86, 0.8);
}
.chat-welcome-title { margin-top: 16px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.chat-welcome-text { margin-top: 8px; max-width: 660px; font-size: 15px; line-height: 1.75; color: var(--ink-2); }
.suggest-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 720px;
}
.suggest-grid.is-compact { grid-template-columns: minmax(0, 1fr); max-width: 620px; }
.suggest-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s, background 0.14s;
}
.suggest-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent-line);
  background: linear-gradient(180deg, #ffffff, #f4faf8);
  box-shadow: 0 14px 26px -20px rgba(11, 92, 86, 0.5);
}
.suggest-card-text { font-size: 14px; font-weight: 600; line-height: 1.6; color: var(--ink-2); }
.suggest-card-arrow { flex: 0 0 auto; color: var(--accent); font-weight: 700; }
.chat-suggestion-empty { margin-top: 20px; font-size: 13px; color: var(--ink-4); }

/* error + composer */
.chat-shell .chat-error {
  margin: 0 clamp(18px, 2.6vw, 30px) 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
}
.chat-composer { border-top: 1px solid var(--line-soft); padding: 12px clamp(18px, 2.4vw, 26px) 16px; background: rgba(255, 255, 255, 0.9); }
.chat-composer-box {
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  padding: 8px 10px 6px;
  box-shadow: 0 12px 24px -20px rgba(17, 31, 29, 0.4);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1); }
.chat-input {
  width: 100%;
  min-height: 48px;
  max-height: 200px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.68;
  padding: 6px 6px 2px;
  overflow-y: auto;
}
.chat-input::placeholder { color: var(--ink-4); font-weight: 400; }
.chat-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 0;
  margin-top: 4px;
  border-top: 1px solid var(--line-soft);
}
.chat-hint { font-size: 12px; font-weight: 500; color: var(--ink-4); }
.chat-send {
  height: 36px;
  padding: 0 20px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.chat-send:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.chat-send:disabled { opacity: 0.6; cursor: progress; }

@media (max-width: 1024px) {
  .chat-shell { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .chat-shell {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .chat-side { display: none; }
  .chat-mobile-bar { display: flex; }
  .chat-main { height: calc(100vh - 190px); min-height: 460px; border-radius: 14px; }
  .chat-head { padding: 12px 14px; }
  .chat-log { padding: 16px 14px; }
  .chat-shell .chat-error { margin: 0 14px 8px; }
  .chat-composer { padding: 10px 14px 14px; }
  .chat-shell .msg-main { max-width: 94%; }
  .suggest-grid { grid-template-columns: minmax(0, 1fr); }
  .chat-welcome { padding: 4px 2px 12px; }
  .chat-welcome-title { font-size: 21px; }
}
