/* ============================================================
   Artehmis — application styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--plane);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--brand-tint-2); color: var(--text); }

/* visible, consistent focus everywhere */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
.ta-l { text-align: left; }
.ta-r { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* ============================================================
   Layout
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.app.side-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.main {
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  outline: none;
}
@media (prefers-reduced-motion: reduce) { .main { scroll-behavior: auto; } }

.screen { min-height: 100%; }
.home-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 40px 96px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px 12px;
  gap: 4px;
}
.side-top { display: flex; align-items: center; gap: 4px; }
.workspace {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  background: transparent; border: 0; border-radius: var(--r-md);
  cursor: pointer; text-align: left;
  transition: background 140ms var(--ease);
}
.workspace:hover { background: var(--surface-sunken); }
.ws-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  background: var(--brand); color: #fff;
}
.ws-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ws-name { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-org  { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-chev { color: var(--text-muted); display: grid; place-items: center; flex: none; }

/* Workspace options. Separate from the logo so the logo itself can navigate —
   see the sidebar in app.js. */
.ws-menu {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.ws-menu:hover,
.ws-menu.is-anchored { background: var(--surface-sunken); color: var(--text); }

.side-collapse {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.side-collapse:hover { background: var(--surface-sunken); color: var(--text); }

.new-chat {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0 6px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: box-shadow 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease);
}
.new-chat:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.new-chat:active { transform: translateY(1px); }
.new-chat .nav-icon { color: var(--brand); }

.side-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item, .recent-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 0; border-radius: 9px;
  background: transparent;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; text-align: left; width: 100%;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}
.nav-item:hover, .recent-item:hover { background: var(--surface-sunken); color: var(--text); }
.nav-item.is-active {
  background: var(--brand-tint);
  color: var(--brand-ink);
  font-weight: 600;
}
.nav-item.is-active .nav-icon { color: var(--brand); }
.nav-icon { display: grid; place-items: center; flex: none; width: 20px; color: var(--text-muted); }
.nav-item.is-active .nav-icon, .nav-item:hover .nav-icon { color: currentColor; }
.nav-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto; flex: none;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--critical); color: #fff;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.nav-badge[hidden] { display: none; }

.side-section { margin-top: 18px; min-height: 0; display: flex; flex-direction: column; }
.side-section-title {
  padding: 0 10px 6px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
}
.recent-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-bottom: 4px; }
.recent-item { font-size: 13.5px; font-weight: 450; }

.side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.account {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border: 0; border-radius: var(--r-md); background: transparent;
  cursor: pointer; text-align: left;
  transition: background 140ms var(--ease);
}
.account:hover { background: var(--surface-sunken); }
.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-tint-2); color: var(--brand-ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
}

/* collapsed sidebar */
.side-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
.side-collapsed .ws-text,
.side-collapsed .ws-chev,
.side-collapsed .ws-menu,
.side-collapsed .nav-text,
.side-collapsed .side-section { display: none; }
/* A collapsed sidebar must not swallow the fact that something has fired —
   the count becomes a dot rather than disappearing. */
.side-collapsed .nav-badge,
.is-narrow-nav .nav-badge {
  position: absolute; top: 3px; right: 9px;
  min-width: 9px; width: 9px; height: 9px; padding: 0;
  font-size: 0; line-height: 0;
  border: 2px solid var(--sidebar);
}
.side-collapsed .new-chat,
.side-collapsed .nav-item,
.side-collapsed .workspace,
.side-collapsed .account { justify-content: center; padding-left: 6px; padding-right: 6px; }
.side-collapsed .side-top { flex-direction: column; gap: 6px; }

/* ============================================================
   Buttons, inputs, chips
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms var(--ease), box-shadow 140ms var(--ease),
              border-color 140ms var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-primary { background: var(--brand); color: var(--text-on-brand); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--brand-hover); box-shadow: var(--shadow-sm); }
.btn-quiet {
  background: var(--surface); color: var(--text-secondary);
  border-color: var(--border); box-shadow: var(--shadow-xs);
}
.btn-quiet:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }

.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.icon-btn.is-on { background: var(--brand-tint); color: var(--brand-ink); }
.icon-btn.is-anchored { background: var(--surface-sunken); color: var(--text); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-danger:hover { background: var(--critical-tint); color: var(--critical-ink); }

.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}
.link-btn:hover { background: var(--surface-sunken); color: var(--brand-ink); }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease),
              border-color 150ms var(--ease), color 150ms var(--ease);
}
.chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--brand-tint-2);
  color: var(--brand-ink);
}
.chip-sm { padding: 6px 12px; font-size: 13px; }

.input-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  font-size: 14px; font-family: inherit; color: var(--text);
  transition: border-color 130ms var(--ease), box-shadow 130ms var(--ease);
}
.input-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
select.input-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235E6A78' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8.25 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  padding-right: 30px;
  cursor: pointer;
}
.input-num { font-variant-numeric: tabular-nums; }

/* ============================================================
   Home — hero
   ============================================================ */
.hero { max-width: 760px; margin: 22px auto 52px; text-align: center; }
.scan-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: 12.5px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 22px;
}
.scan-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.15);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.15); }
  50%      { box-shadow: 0 0 0 5px rgba(12, 163, 12, 0.05); }
}
@media (prefers-reduced-motion: reduce) { .scan-dot { animation: none; } }

.hero-title {
  font-size: 38px; font-weight: 680; letter-spacing: -0.028em; line-height: 1.15;
  margin-bottom: 10px;
}
.hero-sub { font-size: 16.5px; color: var(--text-muted); margin-bottom: 28px; }

.hero-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  transition: box-shadow 200ms var(--ease), border-color 200ms var(--ease);
  text-align: left;
  overflow: hidden;
}
.hero-box:focus-within {
  border-color: var(--brand);
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--brand-ring);
}
.hero-input-wrap { display: flex; align-items: flex-end; gap: 10px; padding: 16px 16px 12px 20px; }
.hero-input {
  flex: 1;
  border: 0; outline: none; resize: none;
  background: transparent;
  font: inherit; font-size: 16.5px; line-height: 1.55;
  color: var(--text);
  max-height: 180px;
  padding: 2px 0;
}
.hero-input::placeholder { color: #94A0AE; }
.hero-send {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 11px;
  background: var(--brand); color: #fff;
  cursor: pointer;
  transition: background 140ms var(--ease), opacity 140ms var(--ease), transform 120ms var(--ease);
}
.hero-send:hover:not(:disabled) { background: var(--brand-hover); }
.hero-send:active:not(:disabled) { transform: translateY(1px); }
.hero-send:disabled { background: var(--surface-sunken); color: #A6B0BD; cursor: default; }

.hero-foot {
  padding: 9px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-inset);
}
.hero-source {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-muted);
}
.hero-source svg { flex: none; }

.hero-chips {
  display: flex; flex-wrap: wrap; gap: 9px; justify-content: center;
  margin-top: 20px;
}

/* ============================================================
   Sections & cards
   ============================================================ */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 16px;
}
.section-head-left { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.section-icon {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
  margin-top: 1px;
}
.section-title { font-size: 19px; font-weight: 650; letter-spacing: -0.017em; }
.page-title { font-size: 27px; font-weight: 680; letter-spacing: -0.024em; }
.section-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 1px; }
.section-link {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 13.5px; font-weight: 600; color: var(--brand-ink);
  padding: 5px 8px; border-radius: 8px; flex: none;
  transition: background 130ms var(--ease), gap 130ms var(--ease);
}
.section-link:hover { background: var(--brand-tint); gap: 6px; }
.page-head { margin-bottom: 22px; }

.home-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}
.home-col { min-width: 0; }
.card-stack { display: flex; flex-direction: column; gap: 12px; }
.card-grid { display: grid; gap: 14px; }
.card-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.triggered-wrap:not(:empty) { margin-bottom: 34px; }

/* --- insight card --- */
.insight-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 17px 18px 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out),
              border-color 180ms var(--ease);
  animation: cardIn 460ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .insight-card { animation: none; } }
.insight-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.insight-card:hover .ic-cta { color: var(--brand-ink); gap: 6px; }

.ic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.ic-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.ic-title { font-size: 16px; font-weight: 640; letter-spacing: -0.014em; line-height: 1.35; margin-bottom: 5px; }
.ic-summary {
  font-size: 13.8px; line-height: 1.55; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ic-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ic-spark { flex: none; display: flex; }
.ic-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 0; }
.ic-metric { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ic-impact { font-size: 12px; color: var(--good-ink); font-weight: 600; }
.ic-cta {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 11px;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: color 150ms var(--ease), gap 150ms var(--ease);
}

/* --- a triggered alert breathes, so it reads as urgent from across the room ---
   Only triggered alerts get this. If every critical card pulsed it would be
   noise, and the whole point of rationing red is that it still means something.
   The static border and ring are declared outside the keyframes so a viewer
   with reduced motion still gets the red treatment, just without the movement. */
.insight-card.is-alert {
  border-color: var(--critical);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(208, 59, 59, 0.12);
  animation-name: cardIn, alertPulse;
  animation-duration: 460ms, 2400ms;
  animation-timing-function: var(--ease-out), var(--ease);
  animation-delay: calc(var(--i, 0) * 70ms), 500ms;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: backwards, none;
}
.insight-card.is-alert:hover {
  border-color: var(--critical);
}
@keyframes alertPulse {
  0%, 100% {
    border-color: #F3C6C2;
    box-shadow: var(--shadow-sm), 0 0 0 2px rgba(208, 59, 59, 0.07);
  }
  50% {
    border-color: var(--critical);
    box-shadow: var(--shadow-md), 0 0 0 7px rgba(208, 59, 59, 0.20);
  }
}
@media (prefers-reduced-motion: reduce) {
  .insight-card.is-alert { animation: none; }
}

/* --- badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.005em;
  white-space: nowrap;
}
.badge-icon { display: grid; place-items: center; }
.badge-icon svg { width: 13px; height: 13px; }
.badge-critical { background: var(--critical-tint); color: var(--critical-ink); box-shadow: inset 0 0 0 1px var(--critical-line); }
.badge-warning  { background: var(--warning-tint); color: var(--warning-ink); box-shadow: inset 0 0 0 1px #FBE3B8; }
.badge-reco     { background: var(--good-tint); color: var(--good-ink); box-shadow: inset 0 0 0 1px var(--good-line); }
.badge-reco-soft { background: var(--brand-tint); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-tint-2); }

/* --- skeletons --- */
.insight-card.skeleton { pointer-events: none; animation: none; }
.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, #EEF0F4 25%, #F6F7F9 37%, #EEF0F4 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk-badge { width: 74px; height: 19px; border-radius: var(--r-pill); margin-bottom: 13px; }
.sk-title { width: 62%; height: 16px; margin-bottom: 11px; }
.sk-line  { width: 100%; height: 11px; margin-bottom: 7px; }
.sk-short { width: 78%; }
.sk-spark { width: 100%; height: 32px; margin-top: 16px; }

/* --- empty state --- */
.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 34px 28px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.empty-lg { padding: 48px 32px; }
.empty-icon {
  width: 44px; height: 44px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--brand-tint); color: var(--brand);
}
.empty-title { font-size: 17px; font-weight: 650; margin-bottom: 7px; letter-spacing: -0.014em; }
.empty-body {
  font-size: 14.5px; color: var(--text-muted);
  max-width: 460px; margin: 0 auto 18px; line-height: 1.6;
}

/* ============================================================
   Stat tiles — label · value · delta · trend
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}
.stat-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat-tile {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 15px 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 160ms var(--ease), border-color 160ms var(--ease);
  min-width: 0;
}
.stat-tile:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.stat-label {
  font-size: 12.5px; font-weight: 550; color: var(--text-muted);
  line-height: 1.4; margin-bottom: 7px;
  padding-right: 26px;
}
.stat-value-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat-value {
  font-size: 25px; font-weight: 660; letter-spacing: -0.024em; line-height: 1.15;
  /* proportional figures — tabular would make a big number look loose */
}
.stat-delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12.5px; font-weight: 650;
  padding: 2px 7px 2px 5px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.stat-arrow { display: grid; place-items: center; }
.tone-critical { background: var(--critical-tint); color: var(--critical-ink); }
.tone-warning  { background: var(--warning-tint);  color: var(--warning-ink); }
.tone-good     { background: var(--good-tint);     color: var(--good-ink); }
.tone-neutral  { background: var(--surface-sunken); color: var(--text-muted); }
.stat-sub { font-size: 12.2px; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
.stat-spark { margin-top: auto; padding-top: 10px; }
.stat-spark svg { display: block; width: 100%; height: 32px; }

/* the bell that makes any metric alertable */
.alertable { position: relative; }
.metric-bell {
  position: absolute; top: 9px; right: 9px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0; transform: scale(0.92);
  box-shadow: var(--shadow-xs);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease),
              color 140ms var(--ease), border-color 140ms var(--ease), background 140ms var(--ease);
}
.metric-bell svg { width: 15px; height: 15px; }
.alertable:hover .metric-bell,
.alertable:focus-within .metric-bell,
.metric-bell:focus-visible,
.metric-bell.is-anchored { opacity: 1; transform: none; }
.metric-bell:hover, .metric-bell.is-anchored {
  color: var(--brand-ink); border-color: var(--brand-tint-2); background: var(--brand-tint);
}
@media (hover: none) { .metric-bell { opacity: 1; transform: none; } }

.alert-pill {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 9px;
  padding: 2px 8px 2px 6px;
  border-radius: var(--r-pill);
  background: var(--brand-tint); color: var(--brand-ink);
  font-size: 11.5px; font-weight: 600;
}
.alert-pill svg { width: 12px; height: 12px; }
.alert-pill.is-triggered { background: var(--critical-tint); color: var(--critical-ink); }
.alert-pill.is-paused { background: var(--surface-sunken); color: var(--text-muted); }

/* ============================================================
   Chart card
   ============================================================ */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
  margin: 22px 0;
  min-width: 0;
}
.chart-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 12px;
}
.chart-titles { min-width: 0; }
.chart-title { font-size: 14.5px; font-weight: 640; letter-spacing: -0.012em; line-height: 1.4; }
.chart-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.chart-tools { display: flex; gap: 2px; flex: none; opacity: 0.55; transition: opacity 150ms var(--ease); }
.chart-card:hover .chart-tools, .chart-card:focus-within .chart-tools { opacity: 1; }
@media (hover: none) { .chart-tools { opacity: 1; } }

.chart-body { position: relative; min-width: 0; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-svg:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.chart-svg .hit { cursor: crosshair; }
.chart-svg .mark { transition: opacity 120ms var(--ease); }

/* chart text — always ink tokens, never the series color */
.axis-text { font-size: 11px; font-weight: 500; fill: var(--axis-ink); font-variant-numeric: tabular-nums; }
.cat-text  { font-size: 12px; font-weight: 500; fill: var(--text-muted); }
.val-text  { font-size: 12px; font-weight: 650; fill: var(--text); font-variant-numeric: tabular-nums; }
.sub-text  { font-size: 11px; font-weight: 500; fill: var(--text-muted); }
.end-label { font-size: 11.5px; font-weight: 620; fill: var(--text-secondary); }
.ann-label { font-size: 10.5px; font-weight: 650; }
.ann-value { font-size: 11.5px; font-weight: 700; }
.donut-value { font-size: 21px; font-weight: 660; fill: var(--text); letter-spacing: -0.02em; }
.donut-label { font-size: 11px; font-weight: 500; fill: var(--text-muted); }
.donut-legend-name { font-size: 12.5px; font-weight: 500; fill: var(--text-secondary); }
.donut-legend-value { font-size: 12.5px; font-weight: 650; fill: var(--text); font-variant-numeric: tabular-nums; }
.ta-mid { text-anchor: middle; }
.ta-end { text-anchor: end; }

.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--border);
}
.chart-legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-key { flex: none; display: block; }
.legend-line { width: 14px; height: 3px; border-radius: 2px; }
.legend-rect { width: 11px; height: 11px; border-radius: 3px; }
.legend-band { width: 13px; height: 11px; border-radius: 3px; border: 1px solid transparent; }
.legend-label { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }

.chart-note {
  font-size: 11.5px; line-height: 1.55; color: var(--text-muted);
  margin-top: 10px; padding-top: 9px;
  border-top: 1px solid var(--border);
}
.chart-legend + .chart-note { border-top: 0; padding-top: 6px; margin-top: 4px; }

/* tooltip */
.chart-tip {
  position: absolute; z-index: 5;
  min-width: 132px; max-width: 260px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.tip-title { font-size: 11.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tip-val { font-size: 13.5px; font-weight: 660; font-variant-numeric: tabular-nums; }
.tip-name { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* the table twin — every chart has one */
.chart-table-wrap { max-height: 320px; overflow: auto; margin-top: 4px; border-radius: 10px; border: 1px solid var(--border); }
.chart-table-wrap[hidden] { display: none; }
.chart-table { font-size: 13px; }
.chart-table th, .chart-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.chart-table thead th {
  position: sticky; top: 0;
  background: var(--surface-inset);
  font-size: 11.5px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.chart-table td { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.chart-table td.ta-l { color: var(--text); font-variant-numeric: normal; }
.chart-table tbody tr:last-child td { border-bottom: 0; }
.chart-table tbody tr:hover td { background: var(--surface-inset); }

/* ============================================================
   Data table block
   ============================================================ */
.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  margin: 22px 0;
  overflow: hidden;
}
.data-table-scroll { overflow-x: auto; }
.data-table { font-size: 13.5px; min-width: 480px; }
.data-table th, .data-table td { padding: 10px 15px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table thead th {
  background: var(--surface-inset);
  font-size: 11.5px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table td.ta-r { font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #FAFBFC; }
.data-table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px 8px 15px;
  border-top: 1px solid var(--border);
  background: var(--surface-inset);
}
.data-table-caption { font-size: 12px; color: var(--text-muted); }
.delta-up { color: var(--good-ink); font-weight: 640; }
.delta-down { color: var(--critical-ink); font-weight: 640; }

/* ============================================================
   Callout
   ============================================================ */
.callout {
  display: flex; gap: 12px;
  padding: 15px 17px;
  border-radius: var(--r-md);
  margin: 22px 0;
}
.callout-icon { flex: none; margin-top: 1px; }
.callout-title { font-size: 14px; font-weight: 650; margin-bottom: 3px; letter-spacing: -0.01em; }
.callout-text { font-size: 14px; line-height: 1.62; }
.callout-critical { background: var(--critical-tint); box-shadow: inset 0 0 0 1px var(--critical-line); }
.callout-critical .callout-icon, .callout-critical .callout-title { color: var(--critical-ink); }
.callout-critical .callout-text { color: #8B2018; }
.callout-warning { background: var(--warning-tint); box-shadow: inset 0 0 0 1px #FBE3B8; }
.callout-warning .callout-icon, .callout-warning .callout-title { color: var(--warning-ink); }
.callout-warning .callout-text { color: #8A3908; }
.callout-brand { background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand-tint-2); }
.callout-brand .callout-icon, .callout-brand .callout-title { color: var(--brand-ink); }
.callout-brand .callout-text { color: #17408F; }
.callout-good { background: var(--good-tint); box-shadow: inset 0 0 0 1px var(--good-line); }
.callout-good .callout-icon, .callout-good .callout-title { color: var(--good-ink); }
.callout-good .callout-text { color: #04503A; }

/* ============================================================
   Mini dashboard (inside a chat answer)
   ============================================================ */
.mini-dash {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-inset);
  padding: 16px;
  margin: 20px 0;
}
.mini-dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.mini-dash-title { font-size: 15px; font-weight: 650; letter-spacing: -0.014em; }
.mini-dash-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.mini-dash .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 14px 0; }
.mini-dash-grid { display: grid; gap: 14px; }
.mini-dash-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini-dash .chart-card { margin: 0; }

/* ============================================================
   Article
   ============================================================ */
.screen-article { padding: 0; }
.article { max-width: 880px; margin: 0 auto; padding: 28px 40px 100px; }
.article-back { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px 5px 7px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: 13.5px; font-weight: 600; color: var(--text-secondary);
  transition: color 140ms var(--ease), border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.back-link:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.crumb { font-size: 12.5px; font-weight: 550; color: var(--text-muted); }

.article-head { margin-bottom: 26px; }
.article-badges { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; flex-wrap: wrap; }
.article-time { font-size: 13px; color: var(--text-muted); }
.article-title {
  font-size: 32px; font-weight: 690; letter-spacing: -0.028em; line-height: 1.2;
  margin-bottom: 12px;
}
.article-lead { font-size: 17.5px; line-height: 1.6; color: var(--text-secondary); }

.trust-strip {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.trust-item {
  flex: 1 1 auto; min-width: 150px;
  padding: 10px 15px;
  border-right: 1px solid var(--border);
}
.trust-item:last-child { border-right: 0; }
.trust-label {
  display: block;
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 2px;
}
.trust-value { display: block; font-size: 12.8px; font-weight: 550; color: var(--text-secondary); line-height: 1.45; }
.trust-item:first-child .trust-value { color: var(--good-ink); font-weight: 680; }

.article-actions { display: flex; gap: 9px; margin-top: 20px; flex-wrap: wrap; }

.article-body { margin-top: 8px; }
.article-h {
  font-size: 20px; font-weight: 660; letter-spacing: -0.019em;
  margin: 34px 0 10px;
}
.article-h3 { font-size: 16px; font-weight: 640; margin: 24px 0 8px; }
.article-p { font-size: 16px; line-height: 1.72; color: var(--text-secondary); margin: 0 0 14px; }
.article-p b, .article-lead b, .callout-text b, .article-list b { color: var(--text); font-weight: 650; }
.article-list { margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.article-list li {
  position: relative;
  padding-left: 22px;
  font-size: 15.5px; line-height: 1.68; color: var(--text-secondary);
}
.article-list li::before {
  content: ''; position: absolute; left: 4px; top: 10px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-tint-2);
  box-shadow: inset 0 0 0 1.5px var(--brand);
}

.related { margin-top: 44px; padding-top: 30px; border-top: 1px solid var(--border); }
.related .article-h { margin-top: 0; }

.continue { margin-top: 40px; padding-top: 30px; border-top: 1px solid var(--border); }
.continue-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }

/* ============================================================
   Chat
   ============================================================ */
.screen-chat { display: flex; flex-direction: column; height: 100%; }
.chat-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(1.6) blur(10px);
  position: sticky; top: 0; z-index: 4;
  flex: none;
}
.chat-bar-title {
  font-size: 14.5px; font-weight: 620; letter-spacing: -0.012em;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-bar-tools { margin-left: auto; flex: none; }
.chat-host { flex: 1; min-height: 0; display: flex; }

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
.chat-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 30px 0 26px;
  display: flex; flex-direction: column; gap: 26px;
}
.chat-thread > * { max-width: 860px; width: 100%; margin: 0 auto; padding: 0 40px; }

.turn { display: flex; gap: 13px; }
.turn-user { justify-content: flex-end; }
.bubble-user {
  max-width: 78%;
  padding: 11px 16px;
  border-radius: 16px 16px 5px 16px;
  background: var(--brand);
  color: var(--text-on-brand);
  font-size: 15.5px; line-height: 1.6;
  box-shadow: var(--shadow-xs);
  white-space: pre-wrap; word-break: break-word;
}
.turn-ai { align-items: flex-start; }
.ai-avatar {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--brand-tint); color: var(--brand);
  margin-top: 1px;
}
.ai-content { min-width: 0; flex: 1; }
.ai-blocks > .article-p:first-child { margin-top: 3px; }
.ai-blocks .chart-card:first-child, .ai-blocks .mini-dash:first-child { margin-top: 4px; }
.ai-blocks > *:last-child { margin-bottom: 0; }

.block-in { opacity: 0; transform: translateY(7px); transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out); }
.block-in.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .block-in { opacity: 1; transform: none; transition: none; } }

/* thinking */
.thinking {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px 15px;
  box-shadow: var(--shadow-xs);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.thinking.is-collapsing { opacity: 0; transform: translateY(-4px); }
.thinking-label { display: flex; align-items: center; gap: 9px; }
.thinking-title { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand);
  animation: bob 1.15s var(--ease) infinite;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.14s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.28s; }
@keyframes bob { 0%, 100% { opacity: 0.3; transform: translateY(0); } 45% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .thinking-dots i { animation: none; opacity: 0.75; } }

.thinking-steps { margin-top: 9px; display: flex; flex-direction: column; gap: 5px; }
.thinking-step {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.8px; color: #9AA4B1;
  transition: color 200ms var(--ease);
}
.step-mark {
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  border: 1.5px solid #DCE1E8;
  position: relative;
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
.thinking-step.is-active { color: var(--text-secondary); }
.thinking-step.is-active .step-mark { border-color: var(--brand); }
.thinking-step.is-active .step-mark::after {
  content: ''; position: absolute; inset: 2.5px;
  border-radius: 50%; background: var(--brand);
  animation: pulseDot 1s var(--ease) infinite;
}
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.thinking-step.is-done { color: var(--text-muted); }
.thinking-step.is-done .step-mark { border-color: var(--good); background: var(--good); }
.thinking-step.is-done .step-mark::after {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 7.2 2.2 2.2 4.8-5'/%3E%3C/svg%3E") center/11px no-repeat;
  animation: none;
}

/* follow-up chips */
.followups { margin-top: 18px; }
.followups-label {
  display: block;
  font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.followups-list { display: flex; flex-wrap: wrap; gap: 8px; }
.followups-starter { margin-top: 0; }

/* chat context banner in the embedded panel */
.chat-context {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: var(--brand-tint);
  box-shadow: inset 0 0 0 1px var(--brand-tint-2);
}
.chat-context-icon {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface); color: var(--brand);
}
.chat-context-title { font-size: 13.5px; font-weight: 640; color: var(--brand-ink); }
.chat-context-body { font-size: 12.8px; color: #2A5BC0; margin-top: 1px; }

/* composer */
.composer {
  flex: none;
  padding: 14px 0 20px;
  background: linear-gradient(180deg, rgba(247, 248, 250, 0), var(--plane) 34%);
  position: sticky; bottom: 0;
}
.composer-shell {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 9px;
  padding: 10px 10px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.composer-shell:focus-within { border-color: var(--brand); box-shadow: var(--shadow-lg), 0 0 0 4px var(--brand-ring); }
.composer-input {
  flex: 1;
  border: 0; outline: none; resize: none; background: transparent;
  font: inherit; font-size: 15.5px; line-height: 1.55;
  max-height: 160px; padding: 5px 0;
}
.composer-input::placeholder { color: #94A0AE; }
.send-btn {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: var(--brand); color: #fff;
  cursor: pointer;
  transition: background 140ms var(--ease), transform 120ms var(--ease);
}
.send-btn:hover:not(:disabled) { background: var(--brand-hover); }
.send-btn:active:not(:disabled) { transform: translateY(1px); }
.send-btn:disabled { background: var(--surface-sunken); color: #A6B0BD; cursor: default; }
.composer-hint {
  max-width: 860px; margin: 8px auto 0;
  font-size: 11.5px; color: var(--text-muted); text-align: center;
}
.composer, .composer-shell, .composer-hint { padding-left: 40px; padding-right: 40px; }
.composer-shell { padding-left: 18px; padding-right: 10px; max-width: 860px; }

/* embedded variant sits inline in the article, no sticky bar */
.chat-embedded { display: block; }
.chat-embedded .chat-thread {
  overflow: visible; padding: 0; gap: 22px; display: flex;
}
.chat-embedded .chat-thread > * { max-width: none; padding: 0; }
.composer-embedded {
  position: static; padding: 16px 0 0; background: none;
}
.composer-embedded .composer-shell { max-width: none; margin: 0; box-shadow: var(--shadow-sm); }
.composer-embedded .composer-hint { max-width: none; text-align: left; padding: 0; }

/* ============================================================
   Alerts screen
   ============================================================ */
.alert-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 17px;
  border-radius: var(--r-md);
  background: var(--critical-tint);
  box-shadow: inset 0 0 0 1px var(--critical-line);
  margin-bottom: 18px;
}
.alert-banner-icon { flex: none; color: var(--critical-ink); margin-top: 1px; }
.alert-banner-title { font-size: 14.5px; font-weight: 660; color: var(--critical-ink); }
.alert-banner-body { font-size: 13.2px; color: #8B2018; margin-top: 2px; line-height: 1.55; }

.alerts-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.alerts-table { font-size: 14px; min-width: 860px; }
.alerts-table th {
  padding: 11px 16px;
  background: var(--surface-inset);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
  text-align: left; white-space: nowrap;
}
.alerts-table th.ta-r { text-align: right; }
.alerts-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.alerts-table tbody tr:last-child td { border-bottom: 0; }
.alert-row { transition: background 140ms var(--ease); }
.alert-row:hover td { background: #FAFBFC; }
.alert-row.is-triggered td { background: #FFF9F8; }
.alert-row.is-triggered:hover td { background: #FEF3F2; }
.alert-row.is-triggered td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.alert-row.is-paused td { opacity: 0.62; }
.alert-row.is-paused:hover td { opacity: 0.85; }

.alert-metric { display: flex; flex-direction: column; gap: 1px; }
.alert-metric-name { font-size: 14px; font-weight: 620; color: var(--text); letter-spacing: -0.01em; }
.alert-row.is-triggered .alert-metric-name { color: var(--critical-ink); }
.alert-metric:hover .alert-metric-name { text-decoration: underline; text-underline-offset: 2px; }
.alert-freq { display: block; font-size: 11.8px; color: var(--text-muted); margin-top: 3px; }
.alert-cond { font-size: 13.5px; color: var(--text-secondary); white-space: nowrap; }
.alerts-table td.num { font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.alert-current { font-weight: 640; }
.alert-current.is-breach { color: var(--critical-ink); }
.alert-created { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 620; white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.status-triggered { background: var(--critical-tint); color: var(--critical-ink); box-shadow: inset 0 0 0 1px var(--critical-line); }
.status-triggered .status-dot { background: var(--critical); animation: pulse2 2s var(--ease) infinite; }
@keyframes pulse2 { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status-triggered .status-dot { animation: none; } }
.status-active { background: var(--good-tint); color: var(--good-ink); box-shadow: inset 0 0 0 1px var(--good-line); }
.status-active .status-dot { background: var(--good); }
.status-paused { background: var(--surface-sunken); color: var(--text-muted); }
.status-paused .status-dot { background: #A6B0BD; }

.col-actions { width: 1%; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0.5; transition: opacity 140ms var(--ease); }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* how alerts work */
.how-box {
  margin-top: 22px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.how-compact { margin: 4px 0 20px; text-align: left; background: var(--surface-inset); border-color: transparent; box-shadow: none; }
.how-title { font-size: 14.5px; font-weight: 650; margin-bottom: 14px; letter-spacing: -0.012em; }
.how-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.how-step { display: flex; gap: 11px; align-items: flex-start; }
.how-num {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-tint); color: var(--brand-ink);
  font-size: 12px; font-weight: 700;
}
.how-step-title { font-size: 13.5px; font-weight: 620; margin-bottom: 2px; }
.how-step-body { font-size: 12.8px; color: var(--text-muted); line-height: 1.55; }
.how-demo {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border);
  max-width: 330px;
}
.how-demo-label {
  font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 9px;
}

/* ============================================================
   Layers: menu, popover, toast
   ============================================================ */
.layer {
  position: fixed; z-index: 60;
  opacity: 0; transform: translateY(-5px) scale(0.985);
  transform-origin: top;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.layer.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .layer { transition: none; } }

.menu {
  min-width: 210px;
  padding: 5px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent;
  font-size: 13.8px; font-weight: 500; text-align: left;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.menu-item:hover { background: var(--surface-inset); color: var(--text); }
.menu-item.is-danger:hover { background: var(--critical-tint); color: var(--critical-ink); }
.menu-icon { display: grid; place-items: center; color: var(--text-muted); flex: none; }
.menu-item:hover .menu-icon { color: currentColor; }
.menu-label { min-width: 0; }
.menu-check { margin-left: auto; color: var(--brand); display: grid; place-items: center; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* --- Set Alert popover --- */
.popover {
  width: 340px; max-width: calc(100vw - 24px);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.pop-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 15px 16px 12px;
}
.pop-title { font-size: 15px; font-weight: 660; letter-spacing: -0.014em; }
.pop-metric { font-size: 12.8px; color: var(--text-muted); margin-top: 1px; line-height: 1.4; }
.pop-bell {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--brand-tint); color: var(--brand);
}
.pop-current {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 0 16px 14px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-inset);
}
.pop-current-label {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
}
.pop-current-value { font-size: 15px; font-weight: 660; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.pop-body { padding: 0 16px; display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 620; color: var(--text-secondary); }
.field-hint { font-size: 11.8px; color: var(--text-muted); line-height: 1.5; }

.threshold-wrap { display: flex; align-items: center; gap: 7px; }
.threshold-wrap .input-num { flex: 1; min-width: 0; }
.threshold-dash { font-size: 12.5px; color: var(--text-muted); flex: none; }
.threshold-suffix { font-size: 13.5px; font-weight: 600; color: var(--text-muted); flex: none; }
.threshold-dash[hidden], .threshold-suffix[hidden], .input-num[hidden] { display: none; }

.delivery { display: flex; flex-direction: column; gap: 2px; }
.switch-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 2px;
  cursor: pointer;
}
.switch-label { font-size: 13.8px; color: var(--text-secondary); }
.switch-note { font-size: 11.5px; color: var(--text-muted); }
.switch {
  margin-left: auto; flex: none;
  width: 36px; height: 21px;
  border: 0; border-radius: var(--r-pill);
  background: #D6DCE4;
  position: relative; cursor: pointer;
  transition: background 160ms var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-xs);
  transition: transform 180ms var(--ease-out);
}
.switch.is-on { background: var(--brand); }
.switch.is-on::after { transform: translateX(15px); }
.switch.is-locked { background: var(--brand); opacity: 0.5; cursor: default; }
.switch.is-locked::after { transform: translateX(15px); }

.pop-preview {
  font-size: 12.5px; line-height: 1.55; color: var(--brand-ink);
  background: var(--brand-tint);
  padding: 9px 11px;
  border-radius: 9px;
  margin-top: 1px;
}
.pop-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 16px 15px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-inset);
}

/* --- toast --- */
.toast-host {
  position: fixed; z-index: 80;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(400px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  opacity: 0; transform: translateY(10px) scale(0.98);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(6px) scale(0.98); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity 120ms linear; transform: none; } }
.toast-icon {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--good-tint); color: var(--good-ink);
}
.toast-critical .toast-icon { background: var(--critical-tint); color: var(--critical-ink); }
.toast-text { min-width: 0; flex: 1; }
.toast-title { font-size: 13.8px; font-weight: 640; letter-spacing: -0.01em; }
.toast-body { font-size: 12.8px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.toast-action {
  flex: none; align-self: center;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px; font-weight: 620; color: var(--brand-ink);
  cursor: pointer;
  transition: background 130ms var(--ease), border-color 130ms var(--ease);
}
.toast-action:hover { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.toast-close {
  flex: none; align-self: flex-start;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent;
  color: #A6B0BD; cursor: pointer;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}
.toast-close:hover { background: var(--surface-sunken); color: var(--text-secondary); }

/* ============================================================
   Responsive — laptop first, degrades to tablet
   ============================================================ */
@media (max-width: 1200px) {
  .home-inner { padding: 36px 28px 88px; }
  .article { padding: 24px 28px 88px; }
  .chat-thread > *, .composer, .composer-hint { padding-left: 28px; padding-right: 28px; }
  .composer-shell { padding-left: 16px; padding-right: 10px; }
}
@media (max-width: 1080px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .app .ws-text, .app .ws-chev, .app .ws-menu, .app .nav-text,
  .app .side-section { display: none; }
  .app .nav-badge {
    position: absolute; top: 3px; right: 9px;
    min-width: 9px; width: 9px; height: 9px; padding: 0;
    font-size: 0; line-height: 0;
    border: 2px solid var(--sidebar);
  }
  .app .new-chat, .app .nav-item, .app .workspace, .app .account {
    justify-content: center; padding-left: 6px; padding-right: 6px;
  }
  .app .side-top { flex-direction: column; gap: 6px; }
  .app.side-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .stat-row, .mini-dash .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .how-list { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 940px) {
  .home-cols { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .card-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-dash-grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .hero-title { font-size: 32px; }
  .article-title { font-size: 27px; }
}
@media (max-width: 720px) {
  .home-inner { padding: 26px 18px 80px; }
  .article { padding: 20px 18px 80px; }
  .chat-thread > *, .composer, .composer-hint { padding-left: 18px; padding-right: 18px; }
  .composer-shell { padding-left: 14px; padding-right: 8px; }
  .card-grid.cols-2, .card-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .stat-row, .mini-dash .stat-row { grid-template-columns: minmax(0, 1fr); }
  .hero-title { font-size: 27px; }
  .hero-sub { font-size: 15px; }
  .article-title { font-size: 23px; }
  .article-lead { font-size: 16px; }
  .bubble-user { max-width: 88%; }
  .trust-item { min-width: 50%; }
  .toast-host { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

/* ============================================================
   Print — "Download report" opens the print dialog
   ============================================================ */
@media print {
  .sidebar, .chat-bar, .composer, .continue, .article-actions,
  .chart-tools, .metric-bell, .toast-host, .followups, .article-back,
  .related, .link-btn, .data-table-foot { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; height: auto; }
  body { background: #fff; }
  .article { max-width: none; padding: 0; }
  .chart-card, .stat-tile, .data-table-wrap, .callout, .trust-strip {
    box-shadow: none; border: 1px solid #D8DDE4;
    break-inside: avoid; page-break-inside: avoid;
  }
  .article-h { break-after: avoid; page-break-after: avoid; }
}

/* ============================================================
   States the server-backed build adds
   ============================================================ */
.boot-loading {
  display: grid;
  place-items: center;
  min-height: 60vh;
  font-size: 14.5px;
  color: var(--text-muted);
}
.side-empty {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-muted);
}
