/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--tx); font-size: var(--t-sm); font-weight: 600; white-space: nowrap;
  box-shadow: var(--sh-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), transform 80ms var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--n-400); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn--primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: var(--sh-sm); }
.btn--primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn--ai { background: var(--ai-500); border-color: var(--ai-500); color: #fff; }
.btn--ai:hover { background: var(--ai-600); border-color: var(--ai-600); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--tx-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--tx); }
.btn--danger { color: var(--risk-600); border-color: color-mix(in srgb, var(--risk-500) 35%, var(--line)); }
.btn--danger:hover { background: var(--risk-50); border-color: var(--risk-500); }
.btn--sm { padding: 6px 11px; font-size: var(--t-xs); border-radius: var(--r-sm); }
.btn--lg { padding: 12px 22px; font-size: var(--t-base); }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn--icon { padding: 8px; }
.btn--icon svg { width: 16px; height: 16px; }

/* Permission-blocked buttons stay visible but explain themselves */
.btn--locked { opacity: .5; cursor: not-allowed; }
.btn--locked:active { transform: none; }

.btngroup { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 2px; gap: 2px; }
.btngroup button {
  padding: 6px 13px; border: 0; background: transparent; border-radius: 7px;
  font-size: var(--t-sm); font-weight: 600; color: var(--tx-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btngroup button:hover { color: var(--tx); }
.btngroup button[aria-pressed="true"] { background: var(--surface); color: var(--tx); box-shadow: var(--sh-xs); }

/* ===================== Cards ===================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-xs);
}
.card--pad { padding: var(--s-6); }
.card--flush { overflow: hidden; }
.card--inv { background: var(--surface-inv); border-color: transparent; color: #dbe6f2; }
.card--inv h2, .card--inv h3 { color: #fff; }
.card--soft { background: var(--surface-2); box-shadow: none; }
.card--interactive { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card--interactive:hover { border-color: var(--brand-300); box-shadow: var(--sh-md); }
button.card { text-align: left; width: 100%; display: block; font: inherit; color: inherit; }

.cardhead {
  display: flex; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-5) var(--s-5) 0;
}
.cardhead--bordered { padding-bottom: var(--s-4); border-bottom: 1px solid var(--line-soft); }
.card--pad > .cardhead { padding: 0 0 var(--s-4); }
.cardhead__text { flex: 1; min-width: 0; }
.cardhead h2 { font-size: var(--t-lg); }
.cardhead h3 { font-size: var(--t-md); }
.cardhead p { font-size: var(--t-sm); color: var(--tx-3); margin-top: 3px; }
.cardhead__actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.cardbody { padding: var(--s-5); }
.cardfoot {
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft);
  background: var(--surface-2); display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ===================== Grid ===================== */
.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.grid--6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.grid--sidebar { grid-template-columns: minmax(0,1fr) 380px; }
.grid--sidebar-l { grid-template-columns: 320px minmax(0,1fr); }
.grid--master { grid-template-columns: 384px minmax(0,1fr); align-items: start; }
@media (max-width: 1400px) { .grid--6 { grid-template-columns: repeat(3, minmax(0,1fr)); } .grid--5 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 1240px) {
  .grid--sidebar, .grid--sidebar-l, .grid--master { grid-template-columns: minmax(0,1fr); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1000px) { .grid--3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) {
  /* Keep stat tiles two-up on phones — one-up turns a KPI row into a scroll. */
  .grid--4, .grid--5, .grid--6 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid--2, .grid--3 { grid-template-columns: minmax(0,1fr); }
  .metric { padding: var(--s-4); }
  .metric__value { font-size: var(--t-xl); }
}
@media (max-width: 460px) {
  .grid--4, .grid--5, .grid--6 { grid-template-columns: minmax(0,1fr); }
}

/* ===================== Badges, pills, tags ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 650; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--tx-2);
  border: 1px solid transparent;
}
.badge svg { width: 12px; height: 12px; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--ok    { background: var(--ok-50);   color: var(--ok-600); }
.badge--warn  { background: var(--warn-50); color: var(--warn-600); }
.badge--risk  { background: var(--risk-50); color: var(--risk-600); }
.badge--info  { background: var(--info-50); color: var(--info-500); }
.badge--brand { background: var(--brand-50); color: var(--brand-700); }
.badge--ai    { background: var(--ai-50);   color: var(--ai-600); }
.badge--teal  { background: var(--teal-50); color: var(--teal-600); }
.badge--outline { background: transparent; border-color: var(--line-strong); color: var(--tx-2); }
/* For long descriptive labels that must not force a horizontal scrollbar. */
.badge--wrap { white-space: normal; text-align: left; }

/* The honesty marker — used anywhere a number is synthetic */
.datatag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--warn-600); background: var(--warn-50);
  border: 1px dashed color-mix(in srgb, var(--warn-500) 40%, transparent);
  border-radius: var(--r-sm); padding: 1px 6px; white-space: nowrap;
}
.datatag svg { width: 10px; height: 10px; }
.datatag--quiet { background: transparent; border-color: transparent; color: var(--tx-weak); text-transform: none; letter-spacing: 0; font-weight: 500; padding: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--t-xs); font-weight: 600; color: var(--tx-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
button.chip:hover { border-color: var(--n-400); color: var(--tx); }
button.chip[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.chip__x { width: 13px; height: 13px; opacity: .7; }

.chiprow { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* Channel glyphs */
.glyph {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  color: #fff; letter-spacing: -.02em;
}
.glyph--sm { width: 22px; height: 22px; border-radius: 6px; font-size: 9px; }
.glyph--lg { width: 42px; height: 42px; border-radius: 12px; font-size: 14px; }
.glyph svg { width: 60%; height: 60%; }

/* ===================== Metrics ===================== */
.metric { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.metric__label { font-size: var(--t-xs); font-weight: 650; color: var(--tx-3); letter-spacing: .01em; display: flex; align-items: center; gap: 6px; }
.metric__label svg { width: 13px; height: 13px; color: var(--tx-weak); }
/* Large standalone values use proportional figures; tabular is for columns. */
.metric__value { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.metric__value small { font-size: var(--t-md); font-weight: 600; color: var(--tx-3); margin-left: 2px; }
.metric__foot { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-top: auto; }
.metric__spark { margin-top: var(--s-1); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--t-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.delta svg { width: 13px; height: 13px; }
.delta--up   { color: var(--ok-600); }
.delta--down { color: var(--risk-600); }
.delta--flat { color: var(--tx-3); }
/* A drop in negative sentiment is good — semantics are set per-usage */
.delta--good { color: var(--ok-600); }
.delta--bad  { color: var(--risk-600); }

/* ===================== Tables ===================== */
.tablewrap { overflow-x: auto; }
table.data { font-size: var(--t-sm); }
table.data th {
  text-align: left; font-weight: 650; font-size: var(--t-xs); color: var(--tx-3);
  letter-spacing: .04em; text-transform: uppercase;
  padding: 11px var(--s-4); border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--tx); }
table.data th .sorticon { display: inline-block; width: 11px; margin-left: 4px; opacity: .45; }
table.data th[aria-sort] .sorticon { opacity: 1; color: var(--brand-600); }
table.data td { padding: 13px var(--s-4); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { transition: background var(--dur) var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data .cell-primary { font-weight: 600; color: var(--tx); }
table.data .cell-sub { font-size: var(--t-xs); color: var(--tx-3); margin-top: 2px; }

/* ===================== Forms ===================== */
.field { display: block; }
.field__label { display: block; font-size: var(--t-sm); font-weight: 600; margin-bottom: 6px; }
.field__hint { font-size: var(--t-xs); color: var(--tx-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  font-size: var(--t-sm); color: var(--tx);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--n-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.62; font-size: var(--t-base); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7685' stroke-width='1.6'%3E%3Cpath d='M4 6.5L8 10.5L12 6.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 15px; }
[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a8b4c2' stroke-width='1.6'%3E%3Cpath d='M4 6.5L8 10.5L12 6.5'/%3E%3C/svg%3E"); }
.searchinput { position: relative; }
.searchinput svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--tx-weak); pointer-events: none; }
.searchinput .input { padding-left: 34px; }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 40px; height: 23px; border-radius: var(--r-full); background: var(--n-300);
  position: relative; flex: none; transition: background var(--dur) var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-sm);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand-600); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ===================== Filter bar ===================== */
.filterbar {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.filterbar .searchinput { flex: 1; min-width: 210px; }
.filterbar__count { font-size: var(--t-xs); color: var(--tx-3); font-weight: 600; margin-left: auto; white-space: nowrap; }

/* ===================== Lists / master-detail ===================== */
.masterlist { max-height: calc(100vh - 220px); overflow-y: auto; }
.listrow {
  width: 100%; display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent; text-align: left; position: relative;
  transition: background var(--dur) var(--ease);
}
.listrow:hover { background: var(--surface-2); }
.listrow[aria-selected="true"] { background: var(--brand-50); }
.listrow[aria-selected="true"]::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-600); }
.listrow__body { flex: 1; min-width: 0; }
.listrow__title { font-size: var(--t-sm); font-weight: 640; line-height: 1.4; }
.listrow__meta { font-size: var(--t-xs); color: var(--tx-3); margin-top: 4px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.listrow__unread { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); flex: none; margin-top: 6px; }

/* Ranked queue rows */
.queuerow {
  display: flex; align-items: center; gap: var(--s-4); width: 100%;
  padding: var(--s-4) var(--s-5); border: 0; border-top: 1px solid var(--line-soft);
  background: transparent; text-align: left;
  transition: background var(--dur) var(--ease);
}
.queuerow:hover { background: var(--surface-2); }
.queuerow__rank {
  width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--tx-3); font-size: var(--t-xs); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.queuerow__rank--hot { background: var(--risk-50); color: var(--risk-600); }
.queuerow__body { flex: 1; min-width: 0; }
.queuerow__body h3 { font-size: var(--t-sm); font-weight: 640; }
.queuerow__body p { font-size: var(--t-xs); color: var(--tx-3); margin-top: 3px; }
.queuerow__go { width: 16px; height: 16px; color: var(--tx-weak); flex: none; }

/* ===================== Progress & meters ===================== */
.meter { height: 7px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.meter__fill { height: 100%; border-radius: var(--r-full); background: var(--brand-500); transition: width 420ms var(--ease); }
.meter--sm { height: 5px; }
.meter__fill--ok { background: var(--ok-500); }
.meter__fill--warn { background: var(--warn-500); }
.meter__fill--risk { background: var(--risk-500); }
.meter__fill--ai { background: var(--ai-500); }

.stackbar { display: flex; height: 8px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-3); }
.stackbar > span { display: block; height: 100%; }
.stackbar__legend { display: flex; gap: var(--s-4); flex-wrap: wrap; margin-top: var(--s-2); font-size: var(--t-xs); color: var(--tx-3); }
.stackbar__legend b { color: var(--tx); font-weight: 650; font-variant-numeric: tabular-nums; }
.stackbar__legend span { display: inline-flex; align-items: center; gap: 5px; }
.stackbar__legend i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* ===================== Timeline ===================== */
.timeline { position: relative; padding-left: var(--s-6); }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline__item { position: relative; padding-bottom: var(--s-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: calc(-1 * var(--s-6) + 1px); top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--n-400);
}
.timeline__dot--ok { border-color: var(--ok-500); }
.timeline__dot--warn { border-color: var(--warn-500); }
.timeline__dot--risk { border-color: var(--risk-500); }
.timeline__dot--brand { border-color: var(--brand-500); }
.timeline__item h4 { font-size: var(--t-sm); font-weight: 640; }
.timeline__item p { font-size: var(--t-xs); color: var(--tx-3); margin-top: 3px; }
.timeline__time { font-size: 11px; color: var(--tx-weak); font-variant-numeric: tabular-nums; }

/* ===================== Empty / loading ===================== */
.empty { padding: var(--s-9) var(--s-6); text-align: center; }
.empty__icon {
  width: 52px; height: 52px; margin: 0 auto var(--s-4);
  display: grid; place-items: center; border-radius: var(--r-lg);
  background: var(--surface-3); color: var(--tx-weak);
}
.empty__icon svg { width: 24px; height: 24px; }
.empty h3 { font-size: var(--t-md); }
.empty p { font-size: var(--t-sm); color: var(--tx-3); margin: var(--s-2) auto var(--s-4); max-width: 46ch; }

.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.35s infinite linear; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel--text { height: 11px; margin-bottom: 9px; }
.skel--title { height: 20px; width: 45%; margin-bottom: var(--s-4); }
.skel--block { height: 92px; }

.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .62s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Modal & drawer ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(12,20,32,.52);
  backdrop-filter: blur(3px); animation: fadeIn 160ms var(--ease);
  display: flex; align-items: center; justify-content: center; padding: var(--s-6);
}
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 80px);
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl); display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 200ms var(--ease);
}
.modal--wide { width: min(1120px, 100%); }
.modal--narrow { width: min(520px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal__head {
  display: flex; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line);
}
.modal__head h2 { font-size: var(--t-lg); }
.modal__head p { font-size: var(--t-sm); color: var(--tx-3); margin-top: 3px; }
.modal__body { padding: var(--s-6); overflow-y: auto; flex: 1; }
.modal__foot {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2);
}
.modal__foot .spacer { flex: 1; }

.drawer {
  position: fixed; inset: 0 0 0 auto; z-index: 100;
  width: min(680px, 100%); background: var(--surface);
  box-shadow: var(--sh-xl); display: flex; flex-direction: column;
  animation: drawerIn 240ms var(--ease); border-left: 1px solid var(--line);
}
.drawer--wide { width: min(860px, 100%); }
@keyframes drawerIn { from { transform: translateX(28px); opacity: 0; } }
.drawer__head { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: var(--s-4); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--s-6); }
.drawer__foot { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }

/* ===================== Tabs ===================== */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 11px var(--s-4); border: 0; background: transparent;
  font-size: var(--t-sm); font-weight: 600; color: var(--tx-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--tx); }
.tab[aria-selected="true"] { color: var(--brand-600); border-bottom-color: var(--brand-600); }
.tab__count { font-size: 11px; font-weight: 700; margin-left: 5px; background: var(--surface-3); border-radius: var(--r-full); padding: 1px 6px; color: var(--tx-3); }
.tab[aria-selected="true"] .tab__count { background: var(--brand-50); color: var(--brand-700); }

/* ===================== Toast ===================== */
.toaststack { position: fixed; bottom: var(--s-6); left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 11px var(--s-4) 11px var(--s-4); border-radius: var(--r-md);
  background: var(--n-900); color: #fff; box-shadow: var(--sh-xl);
  font-size: var(--t-sm); font-weight: 550; max-width: 520px; pointer-events: auto;
  animation: toastIn 220ms var(--ease);
}
[data-theme="dark"] .toast { background: var(--n-800); border: 1px solid var(--line); }
.toast.is-out { animation: toastOut 180ms var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast--ok svg { color: #55d39a; }
.toast--risk svg { color: #ff8b80; }
.toast__action { margin-left: var(--s-2); background: rgba(255,255,255,.14); border: 0; color: #fff; padding: 4px 10px; border-radius: var(--r-sm); font-size: var(--t-xs); font-weight: 650; }
.toast__action:hover { background: rgba(255,255,255,.24); }

/* ===================== Command palette ===================== */
.palette {
  width: min(660px, 100%); margin-top: 8vh; align-self: flex-start;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  overflow: hidden; display: flex; flex-direction: column; max-height: 72vh;
  animation: modalIn 180ms var(--ease);
}
.palette__input { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.palette__input svg { width: 18px; height: 18px; color: var(--tx-weak); flex: none; }
.palette__input input { flex: 1; border: 0; background: transparent; font-size: var(--t-lg); outline: none; }
.palette__input input::placeholder { color: var(--tx-weak); }
.palette__results { overflow-y: auto; padding: var(--s-2); }
.palette__group { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tx-weak); padding: var(--s-3) var(--s-3) var(--s-2); }
.palette__item {
  width: 100%; display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3); border: 0; background: transparent; border-radius: var(--r-md); text-align: left;
}
.palette__item[aria-selected="true"] { background: var(--brand-50); }
.palette__item .glyph, .palette__item > svg { flex: none; }
.palette__item > svg { width: 17px; height: 17px; color: var(--tx-3); }
.palette__item b { display: block; font-size: var(--t-sm); font-weight: 600; }
.palette__item span { display: block; font-size: var(--t-xs); color: var(--tx-3); }
.palette__item em { margin-left: auto; font-style: normal; font-size: var(--t-xs); color: var(--tx-weak); flex: none; }
.palette__foot { padding: 9px var(--s-5); border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: var(--s-4); font-size: var(--t-xs); color: var(--tx-3); }
.palette__foot kbd { font-family: var(--font); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-weight: 650; }

/* ===================== Copilot ===================== */
.copilot-fab {
  position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: 90;
  display: flex; align-items: center; gap: 9px; padding: 12px 18px;
  border: 0; border-radius: var(--r-full); background: var(--ai-500); color: #fff;
  font-size: var(--t-sm); font-weight: 650; box-shadow: 0 10px 30px rgba(109,74,255,.38);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.copilot-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(109,74,255,.46); }
.copilot-fab svg { width: 17px; height: 17px; }

.copilot {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 95;
  width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100vh - 100px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl); display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 200ms var(--ease);
}
.copilot__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.copilot__head .glyph { background: var(--ai-500); }
.copilot__head b { font-size: var(--t-sm); font-weight: 650; display: block; }
.copilot__head span { font-size: var(--t-xs); color: var(--tx-3); display: block; }
.copilot__thread { flex: 1; overflow-y: auto; padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.bubble { max-width: 94%; font-size: var(--t-sm); line-height: 1.6; }
.bubble--ai { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: var(--s-3) var(--s-4); }
.bubble--me { align-self: flex-end; background: var(--brand-600); color: #fff; border-radius: 14px 4px 14px 14px; padding: var(--s-3) var(--s-4); }
.bubble strong { font-weight: 650; }
.bubble ul { margin: var(--s-2) 0 0; padding-left: 0; }
.bubble li { position: relative; padding-left: 15px; margin-bottom: 5px; }
.bubble li::before { content: ""; position: absolute; left: 3px; top: 8px; width: 4px; height: 4px; border-radius: 50%; background: var(--ai-500); }
.bubble__cite { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px dashed var(--line); font-size: var(--t-xs); color: var(--tx-3); }
.bubble__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-3); }
.copilot__prompts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--s-5) var(--s-3); }
.copilot__input { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface-2); }
.copilot__input input { flex: 1; border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 12px; font-size: var(--t-sm); background: var(--surface); }
.copilot__input input:focus { outline: none; border-color: var(--ai-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-500) 16%, transparent); }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--tx-weak); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

/* ===================== Tour ===================== */
.tour-spot { position: fixed; z-index: 108; border-radius: var(--r-lg); box-shadow: 0 0 0 9999px rgba(10,18,30,.66), 0 0 0 3px var(--brand-400); pointer-events: none; transition: all 260ms var(--ease); }
.tourcard {
  position: fixed; z-index: 110; width: min(420px, calc(100vw - 32px));
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  padding: var(--s-5) var(--s-5) var(--s-4); animation: modalIn 200ms var(--ease);
}
.tourcard__step { font-size: var(--t-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-600); }
.tourcard h3 { font-size: var(--t-lg); margin-top: var(--s-2); }
.tourcard p { font-size: var(--t-sm); color: var(--tx-2); margin-top: var(--s-2); line-height: 1.6; }
.tourcard__foot { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-5); }
.tourcard__dots { display: flex; gap: 5px; margin-right: auto; }
.tourcard__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.tourcard__dots i.on { background: var(--brand-600); width: 18px; border-radius: 3px; }

/* ===================== Utilities ===================== */
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.col { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--s-4); }
.stack--sm > * + * { margin-top: var(--s-2); }
.stack--lg > * + * { margin-top: var(--s-6); }
.spacer { flex: 1; }
.muted { color: var(--tx-3); }
.small { font-size: var(--t-xs); }
.lead { font-size: var(--t-md); color: var(--tx-2); line-height: 1.62; }
.prose { font-size: var(--t-base); line-height: 1.68; color: var(--tx-2); }
.prose p + p { margin-top: var(--s-3); }
.prose strong { color: var(--tx); font-weight: 640; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.divider { height: 1px; background: var(--line); }
.nowrap { white-space: nowrap; }

/* Quote block for sample (synthetic) conversations */
.quote {
  border-left: 3px solid var(--line-strong); padding: var(--s-2) 0 var(--s-2) var(--s-4);
  font-size: var(--t-sm); color: var(--tx-2); line-height: 1.6;
}
.quote--risk { border-left-color: var(--risk-500); }
.quote--ok { border-left-color: var(--ok-500); }

/* Definition list */
.dl { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 9px var(--s-5); font-size: var(--t-sm); }
.dl dt { color: var(--tx-3); font-weight: 550; }
.dl dd { margin: 0; font-weight: 600; }
/* Label above value — for narrow columns where side-by-side would wrap badly. */
.dl--stack { grid-template-columns: minmax(0,1fr); gap: 3px; }
.dl--stack dt { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }

/* Key/value stat strip */
.statstrip { display: flex; flex-wrap: wrap; gap: var(--s-6) var(--s-8); }
.statstrip__item b { display: block; font-size: var(--t-xl); font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.statstrip__item span { display: block; font-size: var(--t-xs); color: var(--tx-3); margin-top: 2px; }
.card--inv .statstrip__item span { color: #92a9c4; }

/* On phones a long action label wraps and goes full width rather than
   pushing the page sideways. */
@media (max-width: 720px) {
  .cardfoot { flex-direction: column; align-items: stretch; }
  .cardfoot .btn, .modal__foot .btn, .drawer__foot .btn {
    white-space: normal; text-align: center; width: 100%; justify-content: center;
  }
  .cardfoot .spacer, .modal__foot .spacer { display: none; }
  .pagehead__actions { width: 100%; }
  .pagehead__actions .btn { white-space: normal; }
}
