/*
 * A Polaris-like design system in plain CSS.
 *
 * Why imitate Polaris rather than use it: the real package needs React and a
 * build step, and this app is deliberately build-free. Merchants spend their day
 * in Shopify admin, so an app that looks native is one they trust and already
 * know how to drive — same spacing, same radii, same button weights, same badge
 * tones. Every colour is a token on :root so dark mode is one redefinition.
 */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #f3f3f3;
  --surface-hover: #f7f7f7;
  --surface-selected: #f1f1f1;
  --surface-inverse: #303030;
  --border: #e3e3e3;
  --border-strong: #c9c9c9;
  --border-input: #8a8a8a;
  --text: #303030;
  --text-2: #616161;
  --text-3: #8a8a8a;
  --text-inverse: #ffffff;
  --link: #005bd3;
  --focus: #005bd3;

  --btn-primary: #303030;
  --btn-primary-hover: #1a1a1a;
  --btn-primary-text: #ffffff;
  --btn-secondary: #ffffff;
  --btn-secondary-hover: #f7f7f7;
  --btn-critical: #c70a24;
  --btn-critical-hover: #a3081d;

  --success-bg: #cdfee1; --success-text: #0c5132; --success-strong: #29845a;
  --info-bg: #e0f0ff;    --info-text: #00527c;    --info-strong: #0094d5;
  --attention-bg: #fff1a8; --attention-text: #4f4700; --attention-strong: #c4a000;
  --warning-bg: #ffd6a4; --warning-text: #5e4200; --warning-strong: #e8a600;
  --critical-bg: #fedad9; --critical-text: #8e1f0b; --critical-strong: #e22c38;
  --neutral-bg: #e3e3e3; --neutral-text: #303030;

  --banner-info: #eaf4ff;
  --banner-success: #ebfff1;
  --banner-warning: #fff5ea;
  --banner-critical: #fff0ef;

  --code-bg: #1e1e1e; --code-text: #e6e6e6;
  --skeleton: #e3e3e3; --skeleton-shine: #f3f3f3;
  --backdrop: rgba(0, 0, 0, 0.5);

  --shadow-card: 0 1px 0 0 rgba(26, 26, 26, 0.07), 0 0 0 1px rgba(26, 26, 26, 0.05);
  --shadow-btn: 0 -1px 0 0 #b5b5b5 inset, 0 0 0 1px rgba(0, 0, 0, 0.1) inset, 0 0.5px 0 1.5px #fff inset;
  --shadow-primary: 0 -1px 0 1px rgba(0, 0, 0, 0.8) inset, 0 0 0 1px #303030 inset, 0 0.5px 0 1.5px rgba(255, 255, 255, 0.25) inset;
  --shadow-pop: 0 8px 16px -4px rgba(26, 26, 26, 0.22), 0 0 0 1px rgba(26, 26, 26, 0.08);
  --shadow-modal: 0 26px 48px -12px rgba(26, 26, 26, 0.4), 0 0 0 1px rgba(26, 26, 26, 0.08);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --topbar-h: 56px;
  --nav-w: 240px;
}

/* Dark mode, twice: once for "follow the system" (unless the user forced light),
   once for an explicit dark choice. CSS cannot share a block between the two. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a1a; --surface: #262626; --surface-2: #2e2e2e; --surface-3: #333333;
    --surface-hover: #2f2f2f; --surface-selected: #383838; --surface-inverse: #e3e3e3;
    --border: #3a3a3a; --border-strong: #4d4d4d; --border-input: #6b6b6b;
    --text: #e3e3e3; --text-2: #b5b5b5; --text-3: #8a8a8a; --text-inverse: #1a1a1a;
    --link: #6cb4ff; --focus: #6cb4ff;
    --btn-primary: #e3e3e3; --btn-primary-hover: #ffffff; --btn-primary-text: #1a1a1a;
    --btn-secondary: #333333; --btn-secondary-hover: #3d3d3d;
    --btn-critical: #e22c38; --btn-critical-hover: #ff4a55;
    --success-bg: #0c3a24; --success-text: #8ef0b5; --success-strong: #3fbf7f;
    --info-bg: #08324d; --info-text: #9ed8ff; --info-strong: #3aaeef;
    --attention-bg: #3d3600; --attention-text: #f5e27a; --attention-strong: #d9bd2a;
    --warning-bg: #4a2e00; --warning-text: #ffcf8a; --warning-strong: #f0a52a;
    --critical-bg: #4d1410; --critical-text: #ffb3ac; --critical-strong: #ff5c5c;
    --neutral-bg: #3a3a3a; --neutral-text: #e3e3e3;
    --banner-info: #10283a; --banner-success: #0f2a1d; --banner-warning: #33240d; --banner-critical: #3a1714;
    --code-bg: #141414; --code-text: #e6e6e6;
    --skeleton: #333333; --skeleton-shine: #3d3d3d;
    --backdrop: rgba(0, 0, 0, 0.65);
    --shadow-card: 0 0 0 1px #3a3a3a;
    --shadow-btn: 0 0 0 1px #4d4d4d inset;
    --shadow-primary: 0 0 0 1px #e3e3e3 inset;
    --shadow-pop: 0 8px 20px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px #3a3a3a;
    --shadow-modal: 0 26px 48px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px #3a3a3a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1a; --surface: #262626; --surface-2: #2e2e2e; --surface-3: #333333;
  --surface-hover: #2f2f2f; --surface-selected: #383838; --surface-inverse: #e3e3e3;
  --border: #3a3a3a; --border-strong: #4d4d4d; --border-input: #6b6b6b;
  --text: #e3e3e3; --text-2: #b5b5b5; --text-3: #8a8a8a; --text-inverse: #1a1a1a;
  --link: #6cb4ff; --focus: #6cb4ff;
  --btn-primary: #e3e3e3; --btn-primary-hover: #ffffff; --btn-primary-text: #1a1a1a;
  --btn-secondary: #333333; --btn-secondary-hover: #3d3d3d;
  --btn-critical: #e22c38; --btn-critical-hover: #ff4a55;
  --success-bg: #0c3a24; --success-text: #8ef0b5; --success-strong: #3fbf7f;
  --info-bg: #08324d; --info-text: #9ed8ff; --info-strong: #3aaeef;
  --attention-bg: #3d3600; --attention-text: #f5e27a; --attention-strong: #d9bd2a;
  --warning-bg: #4a2e00; --warning-text: #ffcf8a; --warning-strong: #f0a52a;
  --critical-bg: #4d1410; --critical-text: #ffb3ac; --critical-strong: #ff5c5c;
  --neutral-bg: #3a3a3a; --neutral-text: #e3e3e3;
  --banner-info: #10283a; --banner-success: #0f2a1d; --banner-warning: #33240d; --banner-critical: #3a1714;
  --code-bg: #141414; --code-text: #e6e6e6;
  --skeleton: #333333; --skeleton-shine: #3d3d3d;
  --backdrop: rgba(0, 0, 0, 0.65);
  --shadow-card: 0 0 0 1px #3a3a3a;
  --shadow-btn: 0 0 0 1px #4d4d4d inset;
  --shadow-primary: 0 0 0 1px #e3e3e3 inset;
  --shadow-pop: 0 8px 20px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px #3a3a3a;
  --shadow-modal: 0 26px 48px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px #3a3a3a;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 13px; line-height: 20px; font-weight: 450;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); box-shadow: var(--shadow-pop); }

/* Text */
.text-heading-lg { font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -0.2px; }
.text-heading-md { font-size: 14px; line-height: 20px; font-weight: 650; }
.text-heading-sm { font-size: 13px; line-height: 20px; font-weight: 650; }
.text-subdued, .muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-sm { font-size: 12px; line-height: 16px; }
.text-strong { font-weight: 650; }
.text-success { color: var(--success-strong); }
.text-critical { color: var(--critical-strong); }
.text-warning { color: var(--warning-text); }
.text-mono { font-family: var(--mono); font-size: 12px; }
.text-break { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-xs { display: flex; flex-direction: column; gap: var(--s1); }
.inline { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.inline-tight { display: inline-flex; align-items: center; gap: var(--s1); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.layout-main-aside { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .layout-main-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ── App frame ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4);
  background: #1a1a1a; color: #e3e3e3;
}
.topbar .brand { display: flex; align-items: center; gap: var(--s2); font-weight: 650; font-size: 14px; color: #fff; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius); display: grid; place-items: center;
  background: linear-gradient(135deg, #36fba1, #0094d5); color: #0b1d14;
}
.topbar .spacer { flex: 1; }
.topbar-select {
  appearance: none; background: #303030 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23b5b5b5' d='M10 13.5 6 9.5h8z'/%3E%3C/svg%3E") no-repeat right 6px center;
  color: #e3e3e3; border: 1px solid #4a4a4a; border-radius: var(--radius); height: 32px;
  padding: 0 28px 0 10px; font: inherit; max-width: 240px; min-width: 0;
}
.topbar-btn {
  position: relative; display: inline-grid; place-items: center; width: 36px; height: 32px;
  border: 0; border-radius: var(--radius); background: transparent; color: #e3e3e3; cursor: pointer;
}
.topbar-btn:hover { background: #303030; }
.count-dot {
  position: absolute; top: 1px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full); background: #e22c38; color: #fff; font-size: 11px; line-height: 18px;
  font-weight: 650; text-align: center;
}
.menu-btn { display: none; }

.embedded-bar {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.embedded-bar .spacer { flex: 1; }
.embedded-bar .topbar-select { background-color: var(--surface); color: var(--text); border-color: var(--border-strong);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23616161' d='M10 13.5 6 9.5h8z'/%3E%3C/svg%3E"); }
.embedded-bar .topbar-btn { color: var(--text); }
.embedded-bar .topbar-btn:hover { background: var(--surface-hover); }

.frame { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.frame.no-nav { grid-template-columns: minmax(0, 1fr); }
.nav {
  position: sticky; top: var(--topbar-h); align-self: start; height: calc(100vh - var(--topbar-h));
  overflow-y: auto; padding: var(--s3) var(--s2); background: var(--surface-3); border-right: 1px solid var(--border);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s2); border-radius: var(--radius);
  color: var(--text); font-weight: 550; text-decoration: none;
}
.nav-link:hover { background: var(--surface-hover); text-decoration: none; }
.nav-link.is-active { background: var(--surface); box-shadow: var(--shadow-card); font-weight: 650; }
.nav-link .icon { color: var(--text-2); }
.nav-link.is-active .icon { color: var(--text); }
.nav-link .nav-count {
  margin-left: auto; background: var(--neutral-bg); color: var(--neutral-text);
  border-radius: var(--radius); padding: 0 6px; font-size: 12px; font-weight: 550;
}
.nav-foot { margin-top: var(--s4); padding: var(--s2); }

.main { min-width: 0; }
.page { max-width: 1000px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s10); }
.page.page-wide { max-width: 1240px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-header .page-title-group { display: flex; gap: var(--s2); align-items: flex-start; min-width: 0; }
.page-header .subtitle { color: var(--text-2); margin-top: 2px; max-width: 640px; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.back-btn { margin-top: -2px; }

@media (max-width: 768px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .nav {
    display: none; position: fixed; top: var(--topbar-h); left: 0; right: 0; height: auto; max-height: calc(100vh - var(--topbar-h));
    z-index: 25; border-right: 0; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-pop);
  }
  .nav.is-open { display: block; }
  .menu-btn { display: inline-grid; }
  .topbar .brand-name { display: none; }
  .topbar-select { max-width: 150px; }
  .page { padding: var(--s4) var(--s4) var(--s10); }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); min-width: 0; }
.card-section { padding: var(--s4); }
.card-section + .card-section { border-top: 1px solid var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s4) var(--s4) 0; flex-wrap: wrap; }
.card-header + .card-section { padding-top: var(--s3); }
.card-subdued { background: var(--surface-2); }
.card-footer { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; }
.card.is-clickable { cursor: pointer; transition: box-shadow 0.12s; }
.card.is-clickable:hover { box-shadow: var(--shadow-pop); }
@media (max-width: 640px) { .card { border-radius: var(--radius); } }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: var(--radius);
  font-size: 12px; line-height: 16px; font-weight: 550; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-text);
}
.badge .icon { width: 14px; height: 14px; margin-left: -3px; }
.badge.tone-success { background: var(--success-bg); color: var(--success-text); }
.badge.tone-info { background: var(--info-bg); color: var(--info-text); }
.badge.tone-attention { background: var(--attention-bg); color: var(--attention-text); }
.badge.tone-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge.tone-critical { background: var(--critical-bg); color: var(--critical-text); }
.badge.tone-new { background: transparent; box-shadow: 0 0 0 1px var(--border-strong) inset; color: var(--text-2); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 2px; background: currentColor; opacity: 0.8; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 28px; padding: 4px 12px; border: 0; border-radius: var(--radius); cursor: pointer;
  font-weight: 550; font-size: 13px; line-height: 20px; white-space: nowrap; text-decoration: none;
  background: var(--btn-secondary); color: var(--text); box-shadow: var(--shadow-btn);
  transition: background 0.1s;
}
.btn:hover { background: var(--btn-secondary-hover); text-decoration: none; }
.btn:active { box-shadow: 0 2px 1px 0 rgba(26, 26, 26, 0.2) inset; }
.btn.btn-primary { background: var(--btn-primary); color: var(--btn-primary-text); box-shadow: var(--shadow-primary); }
.btn.btn-primary:hover { background: var(--btn-primary-hover); }
.btn.btn-critical { background: var(--btn-critical); color: #fff; box-shadow: 0 -1px 0 1px rgba(0,0,0,.2) inset; }
.btn.btn-critical:hover { background: var(--btn-critical-hover); }
.btn.btn-plain, .btn.btn-tertiary { background: transparent; box-shadow: none; color: var(--link); padding: 4px 6px; }
.btn.btn-tertiary { color: var(--text); }
.btn.btn-plain:hover, .btn.btn-tertiary:hover { background: var(--surface-hover); }
.btn.btn-plain.tone-critical { color: var(--critical-strong); }
.btn.btn-sm { min-height: 24px; padding: 2px 8px; font-size: 12px; }
.btn.btn-lg { min-height: 36px; padding: 6px 16px; font-size: 14px; }
.btn.btn-icon { padding: 4px; min-width: 28px; }
.btn.btn-full { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-2) transparent var(--text-2) transparent;
  animation: spin 0.7s linear infinite;
}
.btn.btn-primary.is-loading::after { border-color: var(--btn-primary-text) transparent var(--btn-primary-text) transparent; }
.btn-group { display: inline-flex; gap: var(--s2); flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--text); animation: spin 0.7s linear infinite;
}
.spinner.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Icons ──────────────────────────────────────────────────────────────── */
.icon {
  width: 20px; height: 20px; flex: 0 0 auto; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-tile {
  width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -0.2px; flex: 0 0 auto;
  background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--border) inset;
}

/* ── Banners ────────────────────────────────────────────────────────────── */
.banner {
  display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--radius-lg);
  background: var(--banner-info); box-shadow: 0 0 0 1px var(--border) inset; align-items: flex-start;
}
.banner .banner-icon { color: var(--info-strong); margin-top: 0; }
.banner.tone-success { background: var(--banner-success); } .banner.tone-success .banner-icon { color: var(--success-strong); }
.banner.tone-warning { background: var(--banner-warning); } .banner.tone-warning .banner-icon { color: var(--warning-strong); }
.banner.tone-critical { background: var(--banner-critical); } .banner.tone-critical .banner-icon { color: var(--critical-strong); }
.banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s1); }
.banner-title { font-weight: 650; }
.banner-actions { display: flex; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.banner ul { margin: 0; padding-left: 18px; }
.banner-dismiss { margin: -4px -8px -4px 0; }

.demo-strip {
  display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s4); font-size: 12px;
  background: var(--attention-bg); color: var(--attention-text); flex-wrap: wrap;
}
.demo-strip .spacer { flex: 1; }
.demo-strip .link-btn { color: inherit; text-decoration: underline; font-weight: 600; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field-label { font-weight: 550; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.field-label .optional { color: var(--text-2); font-weight: 450; }
.help { color: var(--text-2); font-size: 12px; line-height: 16px; }
.field-error { color: var(--critical-text); font-size: 12px; line-height: 16px; display: flex; gap: 4px; align-items: flex-start; }
.field-error .icon { width: 16px; height: 16px; color: var(--critical-strong); }
.input, .select, .textarea {
  width: 100%; min-height: 32px; padding: 5px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius);
  border-top-color: #898f94;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-2); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--surface-3); color: var(--text-2); border-color: var(--border); cursor: not-allowed; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--critical-strong); background: var(--banner-critical); }
.textarea { resize: vertical; min-height: 72px; line-height: 20px; }
.textarea.textarea-code { font-family: var(--mono); font-size: 12px; min-height: 140px; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%238a8a8a' d='M10 4.5 13 8H7zm0 11L7 12h6z'/%3E%3C/svg%3E") no-repeat right 8px center;
}
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }
.search-field { position: relative; }
.search-field .icon { position: absolute; left: 8px; top: 6px; color: var(--text-3); pointer-events: none; }
.search-field .input { padding-left: 32px; }
.checkbox { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.checkbox input, input[type="checkbox"].cb, input[type="radio"].cb {
  width: 16px; height: 16px; margin: 0; accent-color: var(--btn-primary); cursor: pointer; flex: 0 0 auto;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0; cursor: pointer; }
.switch-track {
  width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--border-input);
  position: relative; transition: background 0.15s; flex: 0 0 auto;
}
.switch-track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--success-strong); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--border) inset; max-width: 100%; overflow-x: auto;
}
.segmented button {
  border: 0; background: transparent; padding: 3px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 550; color: var(--text-2); white-space: nowrap; min-height: 24px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.segmented button[disabled] { opacity: 0.45; cursor: not-allowed; }
.segmented.tone-mode button[data-value="on"][aria-checked="true"] { background: var(--success-bg); color: var(--success-text); }
.segmented.tone-mode button[data-value="monitor"][aria-checked="true"] { background: var(--info-bg); color: var(--info-text); }

/* Multiselect chips */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-full);
  box-shadow: 0 0 0 1px var(--border-strong) inset; background: var(--surface); cursor: pointer; font-weight: 550;
}
.chip input { margin: 0; accent-color: var(--btn-primary); }
.chip.is-on { background: var(--surface-selected); box-shadow: 0 0 0 1.5px var(--text) inset; }
.chip.is-disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; padding: var(--s2); overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--border);
}
.tab {
  border: 0; background: transparent; padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  font-weight: 550; color: var(--text-2); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tab:hover { background: var(--surface-hover); color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface-selected); color: var(--text); }
.tab .tab-count { font-size: 12px; color: var(--text-2); font-weight: 450; }

/* ── Index table ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.itable { width: 100%; border-collapse: collapse; }
.itable th {
  text-align: left; font-weight: 550; font-size: 12px; color: var(--text-2); padding: 6px var(--s3);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.itable td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.itable tbody tr:last-child td { border-bottom: 0; }
.itable tbody tr:hover { background: var(--surface-hover); }
.itable tbody tr.is-selected { background: var(--surface-selected); }
.itable tbody tr.is-clickable { cursor: pointer; }
.itable .col-check { width: 36px; padding-right: 0; }
.itable .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.itable .col-actions { text-align: right; white-space: nowrap; }
.itable .cell-title { font-weight: 550; }
.itable .cell-sub { color: var(--text-2); font-size: 12px; line-height: 16px; }
.bulk-bar {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3);
  background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s2); padding: var(--s3); border-top: 1px solid var(--border); }

/* Phones: rows become stacked cards so nothing scrolls sideways. */
@media (max-width: 640px) {
  .itable thead { display: none; }
  .itable, .itable tbody, .itable tr, .itable td { display: block; width: 100%; }
  .itable tr { padding: var(--s3); border-bottom: 1px solid var(--border); position: relative; }
  .itable tbody tr:last-child { border-bottom: 0; }
  .itable td { border: 0; padding: 2px 0; display: flex; gap: var(--s3); justify-content: space-between; align-items: center; text-align: right; }
  .itable td::before { content: attr(data-label); color: var(--text-2); font-size: 12px; text-align: left; flex: 0 0 auto; }
  .itable td[data-label=""]::before, .itable td:not([data-label])::before { content: none; }
  .itable td.col-primary { display: block; text-align: left; padding-right: 28px; margin-bottom: var(--s1); }
  .itable td.col-primary::before { content: none; }
  .itable td.col-check { position: absolute; right: var(--s3); top: var(--s3); width: auto; padding: 0; }
  .itable td.col-actions { justify-content: flex-end; margin-top: var(--s2); }
  .itable td.col-actions::before { content: none; }
  .itable .col-num { text-align: right; }
}

/* ── Modal & sheet ──────────────────────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--backdrop); display: flex;
  align-items: center; justify-content: center; padding: var(--s4); animation: fade 0.12s ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  width: min(620px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  animation: rise 0.16s ease-out;
}
.modal.modal-sm { width: min(440px, 100%); }
.modal.modal-lg { width: min(860px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-body { padding: var(--s4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); flex-wrap: wrap; }
.backdrop.is-sheet { justify-content: flex-end; align-items: stretch; padding: 0; }
.backdrop.is-sheet .modal { width: min(560px, 100%); max-height: none; height: 100%; border-radius: 0; animation: slide 0.18s ease-out; }
.backdrop.is-sheet .modal-header { border-radius: 0; }
@media (max-width: 640px) {
  .backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed; bottom: var(--s6); left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: var(--s2); align-items: center; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: var(--s3); padding: 10px 12px 10px 16px; border-radius: var(--radius);
  background: #1a1a1a; color: #fff; box-shadow: var(--shadow-pop); font-weight: 550; animation: rise 0.16s ease-out;
  max-width: 100%;
}
.toast.tone-critical { background: #8e1f0b; }
.toast .toast-action { color: #fff; text-decoration: underline; background: none; border: 0; cursor: pointer; font-weight: 650; padding: 0; white-space: nowrap; }
.toast .toast-close { background: none; border: 0; color: #fff; opacity: 0.8; cursor: pointer; padding: 0; display: grid; }

/* ── Popover ────────────────────────────────────────────────────────────── */
.popover {
  position: absolute; z-index: 50; background: var(--surface); color: var(--text); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); width: min(380px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto;
}
.popover-section { padding: var(--s3) var(--s4); }
.popover-section + .popover-section { border-top: 1px solid var(--border); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s10) var(--s4); }
.empty-state .empty-illustration {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}
.empty-state .empty-illustration .icon { width: 32px; height: 32px; }
.empty-state p { max-width: 420px; color: var(--text-2); }

/* ── Skeleton ───────────────────────────────────────────────────────────── */
.skeleton {
  display: block; border-radius: var(--radius-sm); height: 12px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-shine) 50%, var(--skeleton) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton.sk-title { height: 20px; width: 40%; }
.skeleton.sk-block { height: 120px; border-radius: var(--radius-lg); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner, .btn.is-loading::after { animation-duration: 3s; } }

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; box-shadow: 0 0 0 1px var(--border) inset; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--text); transition: width 0.3s; }
.progress.tone-success .progress-fill { background: var(--success-strong); }
.progress.tone-warning .progress-fill { background: var(--warning-strong); }
.progress.tone-critical .progress-fill { background: var(--critical-strong); }
.progress.tone-info .progress-fill { background: var(--info-strong); }
.progress.progress-sm { height: 6px; }
.score-cell { display: flex; align-items: center; gap: var(--s2); min-width: 90px; }
.score-cell .progress { flex: 1; min-width: 40px; }

/* ── Home ───────────────────────────────────────────────────────────────── */
.health { display: flex; gap: var(--s6); align-items: center; flex-wrap: wrap; }
.ring { position: relative; width: 132px; height: 132px; flex: 0 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--surface-3); }
.ring .ring-value { transition: stroke-dashoffset 0.6s ease-out; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label .ring-score { font-size: 32px; line-height: 36px; font-weight: 700; letter-spacing: -0.5px; }
.breakdown { flex: 1 1 260px; display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 2px var(--s3); align-items: center; }
.breakdown-row .progress { grid-column: 1 / -1; }
.attention-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 900px) { .attention-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.attention-item {
  display: flex; flex-direction: column; gap: 2px; padding: var(--s3); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); text-decoration: none; box-shadow: 0 0 0 1px var(--border) inset;
}
.attention-item:hover { background: var(--surface-hover); text-decoration: none; box-shadow: 0 0 0 1px var(--border-strong) inset; }
.attention-item .big { font-size: 24px; line-height: 32px; font-weight: 700; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist-item { display: flex; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border); align-items: flex-start; }
.checklist-item:first-child { border-top: 0; }
.check-circle {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--border-input); flex: 0 0 auto;
  display: grid; place-items: center; margin-top: 1px;
}
.check-circle.is-done { background: var(--text); border: 0; color: var(--surface); }
.check-circle .icon { width: 16px; height: 16px; }
.checklist-item.is-done .checklist-label { color: var(--text-2); text-decoration: line-through; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .stat-value { font-size: 20px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Checks ─────────────────────────────────────────────────────────────── */

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.check-row { display: flex; gap: var(--s2); align-items: flex-start; }
.check-row .icon { width: 18px; height: 18px; margin-top: 1px; }
.check-row.is-pass .icon { color: var(--success-strong); }
.check-row.is-warn .icon { color: var(--warning-strong); }
.check-row.is-fail .icon { color: var(--critical-strong); }

.sticky-actions {
  position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding: var(--s3) var(--s4); display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center;
}

@media (min-width: 961px) { .mobile-only { display: none !important; } }

/* ── Technical / code ───────────────────────────────────────────────────── */
.toggle-row { display: flex; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--border); align-items: flex-start; flex-wrap: wrap; }
.toggle-row:first-child { border-top: 0; padding-top: 0; }
.toggle-row .toggle-info { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toggle-row .toggle-controls { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.code-block { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: var(--radius); overflow: hidden; }
.code-block pre { margin: 0; padding: var(--s4); overflow-x: auto; font-size: 12px; line-height: 18px; max-height: 340px; white-space: pre; }
.code-block .code-copy { position: absolute; top: var(--s2); right: var(--s2); }
.code-block .code-copy .btn { background: #303030; color: #fff; box-shadow: 0 0 0 1px #555 inset; }
.code-block .code-copy .btn:hover { background: #3d3d3d; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--s2); }
.steps li { counter-increment: step; display: flex; gap: var(--s3); align-items: flex-start; }
.steps li::before {
  content: counter(step); flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); box-shadow: 0 0 0 1px var(--border-strong) inset; font-size: 12px; font-weight: 650;
}
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--s4); }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 0; } .kv dd { margin-bottom: var(--s2); } }
details.disclosure > summary { cursor: pointer; color: var(--link); font-weight: 550; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸"; font-size: 11px; transition: transform 0.15s; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }

/* ── Settings ───────────────────────────────────────────────────────────── */
.settings-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--s2) var(--s6); padding: var(--s4) 0; border-top: 1px solid var(--border); align-items: start; }
.settings-field:first-child { border-top: 0; padding-top: 0; }
.settings-field:last-child { padding-bottom: 0; }
.settings-field .sf-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-field .sf-control { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.settings-field.is-inherited .sf-control > :not(.inherit-line) { opacity: 0.7; }
.settings-field.is-dirty { box-shadow: -3px 0 0 0 var(--attention-strong); padding-left: var(--s3); margin-left: calc(-1 * var(--s3)); }
.inherit-line { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
@media (max-width: 720px) { .settings-field { grid-template-columns: minmax(0, 1fr); } }
.save-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--topbar-h); padding: 0 var(--s4);
  display: flex; align-items: center; gap: var(--s3); background: #1a1a1a; color: #fff; box-shadow: var(--shadow-pop);
  animation: fade 0.12s;
}
.save-bar .spacer { flex: 1; }
.save-bar .btn:not(.btn-primary) { background: #303030; color: #fff; box-shadow: 0 0 0 1px #555 inset; }
.save-bar .btn.btn-primary { background: #fff; color: #1a1a1a; box-shadow: none; }
.save-bar .btn.btn-primary.is-loading::after { border-color: #1a1a1a transparent #1a1a1a transparent; }
.section-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.section-nav a { padding: 4px var(--s2); border-radius: var(--radius-sm); color: var(--text-2); font-weight: 550; }
.section-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s5); align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: minmax(0, 1fr); } .section-nav { display: none; } }

/* ── Activity ───────────────────────────────────────────────────────────── */
.notif { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); align-items: flex-start; }
.notif:first-child { border-top: 0; }
.notif.is-unread { background: var(--surface-2); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; background: transparent; }
.notif.is-unread .notif-dot { background: var(--info-strong); }
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.json-mini { font-family: var(--mono); font-size: 11px; color: var(--text-2); overflow-wrap: anywhere; }

.settings-field.is-dimmed .sf-control, .settings-field.is-dimmed .sf-info { opacity: 0.5; }

/* ── Section anatomy (shared by every screen) ───────────────────────────── */
.section-head { display: flex; gap: var(--s3); align-items: flex-start; flex-wrap: wrap; }
.section-head .grow { flex: 1 1 260px; }
.section-card .section-head:not(.bare) { margin-bottom: var(--s4); }
.section-icon {
  width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; flex: 0 0 auto;
  background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--border) inset;
}
.feature-row { display: flex; gap: var(--s6); align-items: center; flex-wrap: wrap; }

.legend-row { display: flex; gap: var(--s4); flex-wrap: wrap; color: var(--text-2); padding: 0 var(--s1); }
.toggle-list { display: flex; flex-direction: column; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: flex; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border); align-items: flex-start; }
.feed li:first-child { border-top: 0; padding-top: var(--s1); }
.feed-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: 0 0 auto; }
pre.numbered { counter-reset: line; }
pre.numbered .code-line { counter-increment: line; }
pre.numbered .code-line::before { content: counter(line); display: inline-block; width: 2.4em; margin-right: 1em; text-align: right; color: #7a7a7a; user-select: none; }
.code-block pre { padding-top: 44px; }
.code-block .code-copy { z-index: 1; }

.ribbon {
  display: inline-block; font-size: 11px; line-height: 16px; font-weight: 650; letter-spacing: .02em;
  padding: 2px 8px; border-radius: var(--radius-full); background: var(--info-bg); color: var(--info-text);
}
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.status-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-input); }
.status-dot.tone-success .dot { background: var(--success-strong); }
.status-dot.tone-critical .dot { background: var(--critical-strong); }
.status-dot.tone-critical { color: var(--critical-text); }
.link-like { color: var(--link); font-weight: 550; display: inline-flex; align-items: center; gap: 2px; }
.sheet-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
/* One hue per category so a tile is recognisable before it is read. */
.icon-tile.tile-c0 { background: #e8f0fe; color: #1a56db; }
.icon-tile.tile-c1 { background: #e6f7f1; color: #0b7a55; }
.icon-tile.tile-c2 { background: #f1ebff; color: #6b3fd4; }
.icon-tile.tile-c3 { background: #fff2e0; color: #a35a00; }
.icon-tile.tile-c4 { background: #e3f6fb; color: #0a6c87; }
.icon-tile.tile-c5 { background: #fde8f0; color: #b0245e; }
.icon-tile.tile-c6 { background: #eef1f4; color: #3d4b5c; }
:root[data-theme="dark"] .icon-tile[class*="tile-c"] { filter: saturate(.9) brightness(.85); box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-tile[class*="tile-c"] { filter: saturate(.9) brightness(.85); box-shadow: none; } }
.stepper li { padding-bottom: var(--s1); }

/* Settings */
.page-tabs { border-bottom: 0; padding: 0 0 var(--s4); gap: var(--s1); }
.page-tabs .tab { text-decoration: none; }

.section-nav { gap: 2px; }
.section-link {
  display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s2); border: 0; background: none; cursor: pointer;
  border-radius: var(--radius); color: var(--text-2); font: inherit; font-weight: 550; text-align: left; width: 100%;
}
.section-link:hover { background: var(--surface-hover); color: var(--text); }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--attention-strong); margin-left: auto; }
.chip-flat { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-2); font-size: 12px; }
.input-num { max-width: 160px; }
.settings-section { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.settings-section.is-flash { box-shadow: 0 0 0 3px var(--focus), var(--shadow-card); transition: box-shadow .3s; }

/* Billing */
.price { display: flex; align-items: baseline; gap: 2px; }
.price-amount { font-size: 28px; line-height: 32px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.meters { margin-top: var(--s5); }
.meter { display: flex; flex-direction: column; gap: var(--s2); }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); align-items: stretch; }
@media (max-width: 1100px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } }
.plan-card > .card-section { height: 100%; }
.plan-card.is-current { box-shadow: 0 0 0 2px var(--success-strong), var(--shadow-card); }
.plan-card.is-popular:not(.is-current) { box-shadow: 0 0 0 2px var(--info-strong), var(--shadow-card); }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.feature-list li { display: flex; gap: var(--s2); align-items: flex-start; }
.feature-list .icon { color: var(--success-strong); margin-top: 2px; }
.feature-list li.is-locked { color: var(--text-3); }
.feature-list li.is-locked .icon { color: var(--text-3); }

/* Activity */
.notif-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: var(--surface-3); color: var(--text-2); }
.notif-icon.tone-critical { background: var(--critical-bg); color: var(--critical-text); }
.notif-icon.tone-warning { background: var(--warning-bg); color: var(--warning-text); }
.notif-icon.tone-info { background: var(--info-bg); color: var(--info-text); }
.notif-icon.tone-success { background: var(--success-bg); color: var(--success-text); }
.notif .notif-dot { margin-top: 0; }
#main:focus { outline: none; }
.breakdown-row { grid-template-columns: minmax(0, 1fr) auto; }

/* Home */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: var(--s4); border-radius: var(--radius-lg); text-decoration: none; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow-card); transition: transform .2s, box-shadow .2s; min-width: 0;
}
.kpi:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.kpi-icon { width: 32px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-bottom: var(--s2); }
.kpi-value { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-2); }
.trend-chip { align-self: flex-start; margin-top: var(--s2); display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); font-size: 12px; font-weight: 550; background: var(--surface-3); color: var(--text-2); max-width: 100%; }
.trend-chip.tone-success { background: var(--success-bg); color: var(--success-text); }
.trend-chip.tone-critical { background: var(--critical-bg); color: var(--critical-text); }
.trend-chip.tone-warning { background: var(--warning-bg); color: var(--warning-text); }
.health-hero .ring { width: 168px; height: 168px; }
.health-hero .ring-label .ring-score { font-size: 44px; line-height: 48px; }
.attention-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s1); }
.attention-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.attention-row:hover { background: var(--surface-hover); text-decoration: none; }

.stepper-list { counter-reset: none; }
.stepper-list .checklist-item { position: relative; border-top: 0; padding: var(--s2) 0 var(--s3); }
.stepper-list .checklist-item:not(:last-child)::after { content: ""; position: absolute; left: 10px; top: 30px; bottom: -4px; width: 2px; background: var(--border); border-radius: 2px; }
.stepper-list .checklist-item.is-done:not(:last-child)::after { background: var(--success-strong); opacity: .5; }
.stepper-list .check-circle.is-done { background: var(--success-strong); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.status-pip { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--border-strong); }
.status-pip.pip-ready { background: var(--success-strong); }
.status-pip.pip-warning { background: var(--warning-strong); }
.status-pip.pip-critical { background: var(--critical-strong); }
.status-pip.pip-done { background: var(--info-strong); }
@media (max-width: 640px) { .itable td .chips { justify-content: flex-end; }  }

.avatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--border) inset; }
.illustration { width: 132px; height: 99px; fill: none; stroke: var(--text-2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.illustration .ill-soft { fill: var(--surface-3); stroke: none; }
[data-skin="glass"] .illustration { stroke: var(--accent); }
[data-skin="glass"] .illustration .ill-soft { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.appearance { margin-bottom: var(--s4); }
.appearance > summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
.appearance > summary::-webkit-details-marker { display: none; }
.appearance[open] .disclosure-chevron { transform: rotate(180deg); }
.disclosure-chevron { transition: transform .2s; color: var(--text-2); }
@media (max-width: 640px) {
  .demo-strip > .icon { display: none; }
}

.feature-row > .grow { flex: 1 1 380px; }

/* ── Shell extras ───────────────────────────────────────────────────────── */
.topbar-shop { color: inherit; opacity: 0.8; max-width: 40vw; }
.embedded-bar .topbar-shop { color: var(--text-2); opacity: 1; }

/* ── Home ───────────────────────────────────────────────────────────────── */
.kpi-row.kpi-row-6 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi.is-static:hover { transform: none; box-shadow: var(--shadow-card); }
.kpi-sep { color: var(--text-3); font-weight: 400; }
@media (max-width: 400px) { .kpi-row.kpi-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); } .kpi { padding: var(--s3); } .kpi-value { font-size: 22px; line-height: 28px; } }
.readiness-checks { gap: var(--s4); }
.readiness-checks .check-row > .icon { margin-top: 2px; }
.check-fix { display: flex; gap: 6px; align-items: flex-start; color: var(--text); padding: var(--s2); border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }
.check-fix .icon { margin-top: 2px; color: var(--text-2); }

/* ── Lists ──────────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; border-bottom: 1px solid var(--border); }
.filter-bar .search-field { flex: 1 1 240px; }
.filter-bar .field { flex: 0 1 180px; min-width: 140px; }
@media (max-width: 640px) { .filter-bar .field { flex: 1 1 140px; } }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-list > li + li { border-top: 1px solid var(--border); }
.conv-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); padding: var(--s3) var(--s4); color: var(--text); text-decoration: none; align-items: start; }
.conv-row:hover { background: var(--surface-hover); text-decoration: none; }
.conv-row:focus-visible { outline-offset: -2px; }
.conv-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); box-shadow: 0 0 0 1px var(--border) inset; }
.conv-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.conv-top { display: flex; gap: var(--s2); align-items: baseline; min-width: 0; }
.conv-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.conv-meta { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.conv-time { white-space: nowrap; }
@media (max-width: 520px) {
  .conv-row { grid-template-columns: minmax(0, 1fr) auto; padding: var(--s3); }
  .conv-avatar, .conv-email { display: none; }
}
.billable-mark { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 550; color: var(--text-2); }
.rating { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; }
.rating.is-up { background: var(--success-bg); color: var(--success-text); }
.rating.is-down { background: var(--critical-bg); color: var(--critical-text); }

/* ── Transcript (mirrors the storefront widget) ─────────────────────────── */
.transcript { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.msg { display: flex; flex-direction: column; gap: 6px; max-width: min(560px, 88%); }
.msg.is-user { align-self: flex-end; align-items: flex-end; }
.msg.is-assistant { align-self: flex-start; align-items: flex-start; }
.msg-head { display: flex; gap: var(--s2); align-items: baseline; }
.bubble { padding: 10px 14px; border-radius: 16px; line-height: 20px; overflow-wrap: anywhere; }
.msg.is-user .bubble { background: var(--btn-primary); color: var(--btn-primary-text); border-bottom-right-radius: 4px; }
.msg.is-assistant .bubble { background: var(--surface-3); color: var(--text); border-bottom-left-radius: 4px; box-shadow: 0 0 0 1px var(--border) inset; }
.pcards { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--s2); flex-wrap: wrap; }
.pcard { display: flex; gap: var(--s2); width: 230px; max-width: 100%; padding: var(--s2); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.pcard-img { width: 52px; height: 52px; flex: 0 0 auto; border-radius: var(--radius); background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); overflow: hidden; }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; }
.pcard-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.pcard-title { font-weight: 600; line-height: 18px; overflow-wrap: anywhere; }
.pcard-price { font-variant-numeric: tabular-nums; }
.actions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.action-chip { display: inline-flex; gap: 6px; align-items: flex-start; padding: 6px 10px; border-radius: var(--radius); font-size: 13px; background: var(--banner-info); color: var(--text); box-shadow: 0 0 0 1px var(--border) inset; }
.action-chip .icon { margin-top: 2px; flex: 0 0 auto; }
.action-chip.is-confirm { background: var(--banner-warning); }
.action-chip.is-handoff { background: var(--attention-bg); color: var(--attention-text); }
.msg-sources { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.source-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--radius-full); font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.source-chip:hover { color: var(--text); }

/* Behind the answer */
details.behind { width: 100%; min-width: min(480px, 80vw); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--border) inset; background: var(--surface); }
details.behind > summary { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; padding: 6px 10px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 550; color: var(--text-2); border-radius: var(--radius); }
details.behind > summary::-webkit-details-marker { display: none; }
details.behind > summary::after { content: "▸"; margin-left: auto; font-size: 11px; transition: transform 0.15s; }
details.behind[open] > summary::after { transform: rotate(90deg); }
details.behind > summary:hover { color: var(--text); background: var(--surface-hover); }
.behind-body { padding: var(--s3); border-top: 1px solid var(--border); }
.tool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.tool-call { display: flex; flex-direction: column; gap: 6px; }
.tool-index { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.tool-call code { font-family: var(--mono); font-size: 12px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
@media (max-width: 640px) { .tool-grid { grid-template-columns: minmax(0, 1fr); } details.behind { min-width: 0; } .msg { max-width: 100%; } }
.tool-label { display: block; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 2px; }
.json-block { margin: 0; padding: var(--s2); border-radius: var(--radius-sm); background: var(--code-bg); color: var(--code-text); font-family: var(--mono); font-size: 12px; line-height: 16px; overflow-x: auto; max-height: 220px; white-space: pre; }
.tool-result { margin: 0; font-size: 13px; overflow-wrap: anywhere; }

/* ── Playground ─────────────────────────────────────────────────────────── */
.pg-scroll { min-height: 280px; max-height: min(60vh, 560px); overflow-y: auto; display: flex; flex-direction: column; }
.pg-scroll:focus-visible { outline-offset: -2px; }
.pg-quick { padding-top: 0; }
.pg-form { align-items: flex-start; gap: var(--s2); }
.pg-form .field { min-width: 0; }
.pg-form .textarea { resize: vertical; min-height: 44px; }
.typing { display: inline-flex; gap: 4px; align-items: center; min-height: 40px; }
.typing .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: typing 1.2s infinite ease-in-out; }
.typing .dot:nth-child(3) { animation-delay: .15s; }
.typing .dot:nth-child(4) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing .dot { animation: none; opacity: .7; } }

/* ── Settings ───────────────────────────────────────────────────────────── */
.radio-cards { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.radio-card { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3); border-radius: var(--radius); cursor: pointer; box-shadow: 0 0 0 1px var(--border-strong) inset; background: var(--surface); }
.radio-card:hover { background: var(--surface-hover); }
.radio-card.is-selected { box-shadow: 0 0 0 2px var(--text) inset; background: var(--surface-2); }
.radio-card input { margin: 3px 0 0; accent-color: var(--btn-primary); flex: 0 0 auto; }
.radio-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.color-pair { display: flex; gap: var(--s2); align-items: center; }
.color-swatch { width: 44px; height: 36px; padding: 2px; border-radius: var(--radius); border: 1px solid var(--border-input); background: var(--surface); cursor: pointer; }
.input-hex { max-width: 120px; font-family: var(--mono); }
.qr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.qr-row { display: flex; gap: var(--s2); align-items: center; }
.qr-row .input { flex: 1; min-width: 0; }
.lock-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; background: var(--info-bg); color: var(--info-text); text-decoration: none; }
.lock-badge:hover { text-decoration: underline; }
.counter-text { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Billing ────────────────────────────────────────────────────────────── */
.cap-group { max-width: 280px; }
.input-prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-input); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface-2); color: var(--text-2); }
.cap-group .input { border-radius: 0; max-width: none; flex: 1; min-width: 0; }
/* Setup steps: on phones the button drops under the text instead of squeezing it. */
@media (max-width: 520px) {
  .checklist-item { flex-wrap: wrap; }
  .checklist-item > .grow { flex: 1 1 200px; }
  .checklist-item > .btn { margin-left: 34px; }
}

/* ══ v2 ═══════════════════════════════════════════════════════════════════ */
/* Tokens: two chart hues (one per chart — each chart is a single series) and the
   internal-note yellow. Redefined for dark like every other token. */
:root { --chart-1: #2b6fd6; --chart-2: #0e8f7e; --note-bg: #fff7d1; --note-border: #e3c24a; --note-text: #4f4300; --live: #1f9d55; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --chart-1: #6ea8ff; --chart-2: #3ccab4; --note-bg: #3a3212; --note-border: #8d7a25; --note-text: #f3e2a0; --live: #3fd17f; }
}
:root[data-theme="dark"] { --chart-1: #6ea8ff; --chart-2: #3ccab4; --note-bg: #3a3212; --note-border: #8d7a25; --note-text: #f3e2a0; --live: #3fd17f; }

/* Nav badge */
.nav-link .nav-count.is-waiting, .tabbar .tab-badge.is-waiting { background: var(--critical-strong); color: #fff; }
.nav-link .nav-count:not(.is-waiting) { background: var(--neutral-bg); color: var(--neutral-text); }
.tabbar a { position: relative; }

/* Home */
.kpi-row.kpi-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .kpi-row.kpi-row-3 { grid-template-columns: minmax(0, 1fr); } }

/* Messages from the team, events, channel marks */
.msg.is-agent { align-self: flex-start; align-items: flex-start; }
.msg.is-agent .bubble { background: var(--info-bg); color: var(--info-text); border-bottom-left-radius: 4px; box-shadow: 0 0 0 1px var(--border) inset; }
.msg-head .badge { padding: 0 6px; }
.msg-via { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); }
.msg-via .icon { width: 14px; height: 14px; }
.msg-event { align-self: center; display: flex; align-items: flex-start; gap: 6px; max-width: min(560px, 100%); text-align: left; padding: 2px 10px; border-radius: var(--radius-full); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }
.msg-event .icon { margin-top: 0; flex: 0 0 auto; }
.msg-event.is-created { border-radius: var(--radius); }
.action-chip.is-offer { background: var(--banner-success); }

/* ── Support ────────────────────────────────────────────────────────────── */
.support-page .page-header { margin-bottom: var(--s4); }
.support-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.support-list-pane { position: sticky; top: calc(var(--topbar-h) + var(--s4)); max-height: calc(100vh - var(--topbar-h) - 32px); display: flex; flex-direction: column; overflow: hidden; }
#sp-list { overflow-y: auto; min-height: 120px; flex: 1 1 auto; }
@media (max-width: 960px) {
  .support-layout { grid-template-columns: minmax(0, 1fr); }
  .support-list-pane { position: static; max-height: none; overflow: visible; }
  .support-layout.has-selection .support-list-pane { display: none; }
  .support-layout:not(.has-selection) .support-detail-pane { display: none; }
}
.live-strip { padding: var(--s3) var(--s3) var(--s2); border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.live-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: 0 var(--s1); }
.live-head .lock-badge { margin-left: auto; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-input); flex: 0 0 auto; display: inline-block; }
.live-dot.is-on { background: var(--live); box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); animation: live-pulse 2s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot.is-on { animation: none; } }
.live-list { list-style: none; margin: var(--s2) 0 0; padding: 2px 2px var(--s1); display: flex; gap: var(--s2); overflow-x: auto; scroll-snap-type: x proximity; }
.live-card { flex: 0 0 248px; scroll-snap-align: start; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px var(--s2); padding: var(--s2); border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--border) inset; }
.live-card.is-waiting { box-shadow: 0 0 0 1.5px var(--critical-strong) inset; }
.live-card .conv-avatar { width: 28px; height: 28px; font-size: 11px; }
.live-card > .btn { grid-column: 1 / -1; justify-self: start; }
.live-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.live-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.live-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.live-pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; color: var(--success-text); background: var(--success-bg); white-space: nowrap; }
.live-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.sp-tabs { padding: var(--s2) var(--s2) 0; border-bottom: 0; }
.tab .tab-count { margin-left: 2px; }
.sp-filters { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--border); }
.sp-filter-row { display: flex; gap: var(--s2); }
.sp-filter-row .search-field { flex: 1 1 auto; min-width: 0; }
.sp-filter-row .field { flex: 0 0 132px; }
.seg-count { font-size: 11px; color: var(--text-3); font-weight: 600; }
.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-list > li + li { border-top: 1px solid var(--border); }
.ticket-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2); padding: var(--s3); color: var(--text); text-decoration: none; position: relative; }
.ticket-row:hover { background: var(--surface-hover); text-decoration: none; }
.ticket-row:focus-visible { outline-offset: -2px; }
.ticket-row.is-selected { background: var(--surface-selected); box-shadow: inset 3px 0 0 var(--text); }
.ticket-row.is-waiting:not(.is-selected) { box-shadow: inset 3px 0 0 var(--critical-strong); }
.ticket-kind { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.ticket-kind.kind-problem { background: var(--critical-bg); color: var(--critical-text); }
.ticket-kind.kind-handoff { background: var(--attention-bg); color: var(--attention-text); }
.ticket-kind.kind-return { background: var(--info-bg); color: var(--info-text); }
.ticket-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ticket-top { display: flex; gap: var(--s2); justify-content: space-between; align-items: baseline; min-width: 0; }
.ticket-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ticket-assignee { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }

.support-detail-pane { min-width: 0; }
.detail-empty { min-height: 320px; display: grid; place-items: center; }
.detail-back { padding: var(--s2) var(--s3) 0; }
.ticket-detail { display: flex; flex-direction: column; }
.ticket-head { padding: var(--s4); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s3); }
.ticket-head .detail-back { padding: 0; margin: calc(-1 * var(--s2)) 0 0 calc(-1 * var(--s2)); }
.ticket-title { display: flex; gap: var(--s3); align-items: flex-start; }
.ticket-title h2 { overflow-wrap: anywhere; }
.ticket-title h2:focus { outline: none; }
.ticket-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); align-items: end; }
.ticket-controls .field-label { font-size: 12px; color: var(--text-2); }
.assignee-line { min-height: 32px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.takeover-field .btn { justify-content: flex-start; }
.ticket-context { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ctx-block { min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.ctx-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; margin: 0; }
details.ctx-block > summary { cursor: pointer; list-style: none; }
details.ctx-block > summary::-webkit-details-marker { display: none; }
details.ctx-block > summary::after { content: "▸"; font-size: 11px; color: var(--text-3); transition: transform .15s; }
details.ctx-block[open] > summary::after { transform: rotate(90deg); }
.att-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.att-thumb { width: 112px; display: flex; flex-direction: column; gap: 2px; padding: 4px; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong) inset; cursor: zoom-in; text-align: left; }
.att-thumb:hover { box-shadow: 0 0 0 1.5px var(--text-2) inset; }
.att-img { width: 100%; aspect-ratio: 4 / 3; border-radius: calc(var(--radius) - 3px); overflow: hidden; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-name { max-width: 100%; }
.order-view { font-size: 13px; }
.order-items, .order-shipments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.order-items li { display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.order-thumb { width: 32px; height: 32px; }
.ticket-timeline { padding: var(--s4); max-height: min(62vh, 640px); min-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.ticket-timeline:focus-visible { outline-offset: -3px; }
.ticket-transcript { gap: var(--s3); }
.note-card { align-self: stretch; padding: var(--s2) var(--s3); border-radius: var(--radius); background: var(--note-bg); color: var(--note-text); box-shadow: 0 0 0 1px var(--note-border) inset; display: flex; flex-direction: column; gap: 4px; }
.note-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-time { margin-left: auto; opacity: .8; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ticket-composer { border-top: 1px solid var(--border); padding: var(--s3) var(--s4) var(--s4); display: flex; flex-direction: column; gap: var(--s2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); transition: background .15s; }
.ticket-composer.is-note { background: var(--note-bg); box-shadow: inset 0 1px 0 var(--note-border); }
.ticket-composer.is-note .composer-text { border-color: var(--note-border); }
.composer-top, .composer-foot { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.composer-top .spacer, .composer-foot .spacer { flex: 1; }
.composer-text { min-height: 84px; }
.delivery-hint { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.ticket-composer.is-note .delivery-hint { color: var(--note-text); font-weight: 550; }
@media (max-width: 640px) { .composer-kbd { display: none; } .ticket-timeline { max-height: none; } }
.macro-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s1); max-height: 50vh; overflow-y: auto; }
.macro-item { width: 100%; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: var(--s2) var(--s3); border: 0; border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; cursor: pointer; }
.macro-item:hover { background: var(--surface-hover); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.macro-preview { overflow-wrap: anywhere; }
.lightbox { margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.lightbox img { max-width: 100%; max-height: 66vh; border-radius: var(--radius); background: var(--surface-3); }
.modal-footer .spacer { flex: 1; }

/* ── Knowledge ──────────────────────────────────────────────────────────── */
.answers-table td { vertical-align: top; }
.answers-table .cell-title { display: block; min-width: 180px; }
.answer-cell { display: block; color: var(--text-2); max-width: 460px; overflow-wrap: anywhere; }
.answers-table tr.is-off .cell-title, .answers-table tr.is-off .answer-cell { opacity: .55; }
@media (max-width: 640px) { .answer-cell { text-align: left; } .answers-table td[data-label="Answer"] { display: block; } .answers-table td[data-label="Answer"]::before { display: block; margin-bottom: 2px; } }
.gap-list { list-style: none; margin: 0; padding: 0; }
.gap-row { padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.gap-row + .gap-row { border-top: 1px solid var(--border); }
.gap-main { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.gap-main > .grow { flex: 1 1 260px; }
.gap-count { font-size: 18px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.gap-form { padding: var(--s3); border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }

/* ── Insights ───────────────────────────────────────────────────────────── */
.kpi-row.kpi-insights { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi-insights .kpi-value { font-size: 24px; line-height: 30px; }
.chart-pair { position: relative; display: flex; flex-direction: column; gap: var(--s3); border-radius: var(--radius); }
.chart-pair:focus-visible { outline-offset: 4px; }
.chart { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.chart-cap { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.chart-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.chart-key.key-1 { background: var(--chart-1); }
.chart-key.key-2 { background: var(--chart-2); }
.chart-svg { display: block; max-width: 100%; overflow: visible; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .grid.base { stroke: var(--border-strong); }
.chart-svg .tick { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart-svg .bar { fill: var(--chart-1); opacity: .85; }
.chart-svg .bar.is-hot { opacity: 1; }
.chart-svg .area { fill: color-mix(in srgb, var(--chart-2) 18%, transparent); }
.chart-svg .line { fill: none; stroke: var(--chart-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart-svg .dot { fill: var(--chart-2); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart-tip { position: absolute; top: 24px; z-index: 5; display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop); font-size: 12px; pointer-events: none; white-space: nowrap; }
.chart-tip span { display: inline-flex; align-items: center; gap: 6px; }
.bar-list, .funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.bar-list li, .funnel li { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bar-track { display: block; height: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--chart-1); }
.funnel .bar-fill { background: var(--chart-2); }
.funnel-card .card-section { height: 100%; }

/* ── Settings: list editors ─────────────────────────────────────────────── */
.settings-field.is-stacked { grid-template-columns: minmax(0, 1fr); }
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.item-card { padding: var(--s3); border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.item-card.is-off > .item-grid { opacity: .6; }
.item-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.item-head > .grow { flex: 1 1 160px; }
.item-index { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong) inset; color: var(--text-2); flex: 0 0 auto; }
.item-tools { gap: 2px; }
.item-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.item-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .item-grid { grid-template-columns: minmax(0, 1fr); } }
.input-affix { display: flex; align-items: stretch; max-width: 260px; }
.input-affix .input { flex: 1 1 auto; min-width: 0; max-width: none; }
.input-affix .affix { display: grid; place-items: center; padding: 0 10px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-input); white-space: nowrap; font-size: 12px; }
.input-affix .affix:first-child { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-affix .affix:last-child { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-affix .affix:first-child + .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-affix .input:has(+ .affix) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-code { font-family: var(--mono); text-transform: uppercase; letter-spacing: .02em; }
.option-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.option-row { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) auto; gap: var(--s2); align-items: start; padding: var(--s2); border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--border) inset; }
.option-row .option-remove { margin-top: 22px; }
@media (max-width: 640px) { .option-row { grid-template-columns: minmax(0, 1fr) auto; } .option-row .chips-field { grid-column: 1 / -1; grid-row: 2; } .option-row .option-remove { grid-column: 2; grid-row: 1; } }
.chip-input { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 32px; padding: 3px 6px; border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--surface); }
.chip-input:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.chip-kw { padding: 1px 2px 1px 8px; color: var(--text); }
.chip-x { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; }
.chip-x:hover { background: var(--surface-hover); color: var(--text); }
.chip-x .icon { width: 12px; height: 12px; }
.chip-text { flex: 1 1 90px; min-width: 60px; border: 0; background: transparent; font: inherit; color: var(--text); padding: 2px 4px; }
.chip-text:focus { outline: none; }
.secret-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.secret-row .input { flex: 1 1 200px; min-width: 0; }
.macro-admin { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.macro-admin-row { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) 0; border-top: 1px solid var(--border); }
.macro-admin-row:first-child { border-top: 0; padding-top: 0; }
.macro-admin .macro-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ctx-order > summary { flex-wrap: wrap; }
.ctx-order[open] > summary .ctx-sum { display: none; }
.ctx-order[open] .order-view > .between:first-child .text-heading-sm { display: none; }
.ticket-controls .btn { white-space: normal; max-width: 100%; text-align: left; }
@media (max-width: 640px) { .takeover-field { grid-column: 1 / -1; } }
.itable .cell-title + .cell-sub { display: block; }
.answers-table .col-actions .btn-group { flex-wrap: nowrap; gap: 2px; }
.macro-admin-row .btn-group { flex-wrap: nowrap; gap: 2px; }
.takeover-field { grid-column: 1 / -1; }
.takeover-field .btn { align-self: flex-start; white-space: nowrap; }

/* ── Integrations ───────────────────────────────────────────────────────── */
.integration-card { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); height: 100%; text-align: left; border: 0; font: inherit; color: inherit; width: 100%; position: relative; }
.integration-card.is-clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.integration-card.is-soon { opacity: 0.72; }
.integration-head { display: flex; gap: var(--s3); align-items: flex-start; }
.region-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-2); }
.cap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cap-chips .chip-flat .icon { width: 14px; height: 14px; }
.unlocks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
.unlocks li { display: flex; gap: 6px; align-items: flex-start; }
.unlocks .icon { width: 16px; height: 16px; color: var(--success-strong); margin-top: 2px; }
.test-result { display: flex; gap: var(--s2); padding: var(--s3); border-radius: var(--radius); align-items: flex-start; }
.test-result.is-ok { background: var(--banner-success); } .test-result.is-ok > .icon { color: var(--success-strong); }
.test-result.is-fail { background: var(--banner-critical); } .test-result.is-fail > .icon { color: var(--critical-strong); }
.webhook-box { padding: var(--s3); border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }
.webhook-row { display: flex; width: 100%; }
.webhook-row .input { flex: 1 1 auto; min-width: 0; }
#parcels { scroll-margin-top: calc(var(--topbar-h) + 16px); }
#parcels.is-flash { box-shadow: 0 0 0 3px var(--focus), var(--shadow-card); transition: box-shadow .3s; }
.parcels-table .parcel-reason { max-width: 280px; }
.ticket-kind.kind-delivery { background: var(--warning-bg); color: var(--warning-text); }
.deliveries-card .funnel li.tone-success .bar-fill { background: var(--success-strong); }
.deliveries-card .funnel li.tone-warning .bar-fill { background: var(--warning-strong); }
.deliveries-card .funnel li.tone-critical .bar-fill { background: var(--critical-strong); }

/* ── v4: support-team experience ────────────────────────────────────────── */
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border-strong) inset, 0 1px 0 var(--border-strong); font-size: 12px; line-height: 18px; text-align: center; color: var(--text); }

/* "?" tips */
.tip-wrap { position: relative; display: inline-flex; vertical-align: middle; }
.tip-btn { width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0; display: inline-grid; place-items: center; font: 700 11px/1 var(--font); color: var(--text-2); background: var(--surface-3); box-shadow: 0 0 0 1px var(--border) inset; cursor: help; }
.tip-btn:hover, .tip-btn:focus-visible { color: var(--text); background: var(--surface-hover); }
.tip-pop { position: absolute; z-index: 40; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: min(260px, 70vw); padding: 8px 10px; border-radius: var(--radius); background: var(--surface-inverse); color: var(--text-inverse); font-size: 12.5px; line-height: 17px; font-weight: 450; text-align: left; box-shadow: var(--shadow-pop); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s; white-space: normal; }
.tip-wrap:hover .tip-pop, .tip-btn:focus-visible + .tip-pop, .tip-btn:focus + .tip-pop { opacity: 1; visibility: visible; }
@media (max-width: 640px) { .tip-pop { left: auto; right: -8px; transform: none; } }

/* Plain upgrade lines instead of padlocks */
.upgrade-line { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px var(--s2); font-size: 13px; color: var(--text-2); }
.upgrade-line.is-compact { display: flex; width: 100%; margin-top: 2px; font-weight: 450; }
.upgrade-line .upgrade-btn { padding-block: 2px; min-height: 26px; }
.live-upgrade { padding: var(--s2) var(--s1) 0; }

/* Alerts */
.alerts-btn { position: relative; }
.alerts-btn.is-on { color: var(--link); }
.alerts-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical-strong); box-shadow: 0 0 0 2px var(--surface); }
.alert-row { gap: var(--s3); align-items: flex-start; }

/* Team strip */
.team-strip-wrap:empty { display: none; }
.team-strip { margin-bottom: var(--s3); }
.team-strip ul { list-style: none; margin: 0; padding: 2px; display: flex; gap: var(--s2); flex-wrap: wrap; }
.team-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 0; border-radius: var(--radius-full); background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong) inset; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.team-chip:hover { background: var(--surface-hover); }
.team-chip.is-on { box-shadow: 0 0 0 2px var(--text) inset; background: var(--surface-selected); }
.team-chip .avatar { width: 24px; height: 24px; }
.team-chip .avatar.is-empty { color: var(--text-2); }
.team-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.team-waiting { font-size: 11.5px; font-weight: 650; color: var(--critical-text); background: var(--critical-bg); border-radius: var(--radius-full); padding: 0 6px; }

/* Waiting time */
.wait-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px 1px 6px; border-radius: var(--radius-full); font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--info-bg); color: var(--info-text); }
.wait-badge.tone-warning { background: var(--warning-bg); color: var(--warning-text); }
.wait-badge.tone-critical { background: var(--critical-bg); color: var(--critical-text); }
.wait-badge .icon { width: 13px; height: 13px; }
.ticket-row.is-waiting.wait-info:not(.is-selected) { box-shadow: inset 3px 0 0 var(--info-strong); }
.ticket-row.is-waiting.wait-warning:not(.is-selected) { box-shadow: inset 3px 0 0 var(--warning-strong); }

/* List: selection and bulk */
.sp-filter-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.sp-filter-row .field { flex: none; min-width: 0; }
.sp-filter-row .field-label { font-size: 11.5px; color: var(--text-2); }
.sp-filter-row .select { min-width: 0; width: 100%; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ticket-li { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: start; }
.ticket-li.is-picked { background: var(--surface-selected); }
.row-pick { display: grid; place-items: center; padding-top: calc(var(--s3) + 5px); padding-left: var(--s2); }
.ticket-li .ticket-row { padding-left: var(--s2); }
.sp-bulk { position: sticky; top: 0; z-index: 2; gap: var(--s2); padding: var(--s2) var(--s3); }
.sp-bulk .field { margin: 0; }
.sp-bulk .select { min-height: 30px; padding-top: 2px; padding-bottom: 2px; font-size: 13px; }

/* Ticket header */
.ticket-summary { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; font-size: 13.5px; line-height: 19px; padding: 6px 10px; border-radius: var(--radius); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }
.ticket-summary > .icon { margin-top: 2px; color: var(--text-2); flex: none; }
.ticket-summary > span:first-of-type { flex: 1 1 200px; min-width: 0; }
.mood-chip { font-size: 11.5px; font-weight: 700; padding: 0 8px; border-radius: var(--radius-full); line-height: 18px; }
.mood-chip.tone-success { background: var(--success-bg); color: var(--success-text); }
.mood-chip.tone-warning { background: var(--warning-bg); color: var(--warning-text); }
.mood-chip.tone-critical { background: var(--critical-bg); color: var(--critical-text); }
.takeover-field .upgrade-line { font-size: 12.5px; }

/* Ticket body: context beside the conversation when the pane is wide enough */
.ticket-wrap { container-type: inline-size; min-width: 0; }
.ticket-side:empty { display: none; }
.ctx-block.span-all { grid-column: 1 / -1; }
@container (min-width: 820px) {
  .ticket-detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "head head" "tl side" "comp side"; }
  .ticket-head { grid-area: head; }
  .ticket-timeline { grid-area: tl; }
  .ticket-composer { grid-area: comp; border-radius: 0 0 0 var(--radius-lg); }
  .ticket-side { grid-area: side; border-left: 1px solid var(--border); min-width: 0; }
  .ticket-side .ticket-context { grid-template-columns: minmax(0, 1fr); border-bottom: 0; height: 100%; align-content: start; border-radius: 0 0 var(--radius-lg) 0; }
}
.ctx-handoff { padding: var(--s2) var(--s3); border-radius: var(--radius); background: var(--attention-bg); color: var(--text); box-shadow: 0 0 0 1px color-mix(in srgb, var(--attention-strong) 30%, transparent) inset; }
.tried-list { margin: 2px 0 0; padding-left: 18px; }
.next-step { display: flex; gap: 6px; align-items: flex-start; }
.next-step .icon { margin-top: 2px; flex: none; }
.fact-chips { flex-wrap: wrap; }
.ship-card { display: flex; flex-direction: column; gap: 6px; padding: var(--s2) var(--s3); border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.ship-card.is-failed { box-shadow: 0 0 0 1.5px var(--critical-strong) inset; }
.ship-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s2); flex-wrap: wrap; }
.kv.kv-tight { grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--s3); }
.kv.kv-tight dd { margin: 0; }
@media (max-width: 640px) { .kv.kv-tight { grid-template-columns: auto minmax(0, 1fr); } .kv.kv-tight dd { margin-bottom: 0; } }
.ship-actions { flex-wrap: wrap; }
.shopper-stats { display: flex; gap: var(--s4); font-size: 13px; }
.mini-links { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-links a { display: flex; justify-content: space-between; gap: var(--s2); min-width: 0; }
.mini-links .truncate { min-width: 0; }

/* Timeline extras */
.timeline-tools { display: flex; justify-content: flex-end; margin: calc(-1 * var(--s2)) 0 var(--s2); position: sticky; top: calc(-1 * var(--s4)); z-index: 1; }
.timeline-tools .btn { background: var(--surface); box-shadow: 0 0 0 1px var(--border) inset; }
.msg-tools { display: flex; justify-content: flex-end; }
.msg.is-agent .msg-tools { justify-content: flex-end; }

/* Composer: split send button and "/" picker */
.composer-field { position: relative; }
.split-btn { position: relative; display: inline-flex; }
.split-btn > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn .split-toggle { border-top-left-radius: 0; border-bottom-left-radius: 0; padding-inline: 8px; margin-left: 1px; }
.split-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; list-style: none; margin: 0; padding: 4px; min-width: 250px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop), 0 0 0 1px var(--border) inset; }
.split-menu[hidden] { display: none; }
.split-menu button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: calc(var(--radius) - 2px); background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.split-menu button:hover, .split-menu button:focus-visible { background: var(--surface-hover); }
.slash-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 25; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop), 0 0 0 1px var(--border) inset; overflow: hidden; }
.slash-list { list-style: none; margin: 0; padding: 4px; max-height: 240px; overflow-y: auto; }
.slash-item { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; border-radius: calc(var(--radius) - 2px); cursor: pointer; min-width: 0; }
.slash-item.is-active, .slash-item:hover { background: var(--surface-selected); }
.slash-empty { padding: 8px 10px; }
.slash-hint { padding: 4px 12px 6px; border-top: 1px solid var(--border); }
.kbd-table { width: 100%; border-collapse: collapse; margin-bottom: var(--s3); }
.kbd-table th, .kbd-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 450; }
.kbd-table th { width: 46%; }

/* Live strip: cards wrap instead of being cut off at the edge */
.live-list { flex-wrap: wrap; overflow: visible; scroll-snap-type: none; }
.live-card { flex: 1 1 220px; min-width: 0; }
.live-more { margin: var(--s1) var(--s1) 0; font-weight: 600; }

/* Phones: the floating tab bar steps aside while a ticket is open (it has its own Back) */
@media (max-width: 768px) {
  [data-view="support-detail"] .tabbar { display: none !important; }
  [data-view="support-detail"] .page { padding-bottom: 24px !important; }
  [data-view="support-detail"] .toast-region { bottom: 16px !important; }
}
@media (max-width: 640px) {
  .sp-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-filter-row .field:last-child { grid-column: 1 / -1; }
  .split-menu { right: 0; min-width: 220px; }
  .timeline-tools { position: static; }
}

/* Home: start here and merged numbers */
.intro-line { font-size: 15px; line-height: 22px; max-width: 720px; }
.kpi-label .tip-wrap { margin-left: 4px; }
.kpi .tip-btn { width: 16px; height: 16px; font-size: 10px; }

/* Insights: team and trend */
.trend-delta { font-size: 12px; font-weight: 650; }
.trend-delta.is-good { color: var(--success-text); }
.trend-delta.is-bad { color: var(--critical-text); }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li + li { border-top: 1px solid var(--border); }
.review-list a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: var(--s2) var(--s4); color: var(--text); text-decoration: none; }
.review-list a:hover { background: var(--surface-hover); }

/* Knowledge: chats behind a question */
.gap-chats { display: inline-flex; flex-wrap: wrap; gap: 2px 6px; }

/* Settings: four pages */
.settings-pages { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: var(--s4); padding: 4px; border-radius: var(--radius-lg); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border) inset; }
.settings-pages button { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: var(--radius); background: none; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.settings-pages button:hover { color: var(--text); background: var(--surface-hover); }
.settings-pages button[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow-btn); }
.settings-pages .dirty-dot { margin-left: 2px; }
@media (max-width: 640px) { .settings-pages { flex-wrap: nowrap; overflow-x: auto; } .settings-pages button { flex: none; } }
.hours-grid { display: grid; grid-template-columns: 56px auto minmax(0, 1fr); gap: 6px var(--s2); align-items: center; }
.hours-grid .hours-times { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hours-grid input[type="time"] { width: 132px; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: var(--s2); align-items: start; }
@media (max-width: 640px) { .member-row { grid-template-columns: minmax(0, 1fr) auto; } .member-row .member-email { grid-column: 1 / -1; grid-row: 2; } }
/* v4 refinements */
.sp-filter-row .select { font-size: 13px; padding-left: 8px; padding-right: 22px; }
@media (min-width: 961px) {
  .support-list-pane { overflow-y: auto; overscroll-behavior: contain; }
  #sp-list { overflow: visible; flex: none; }
}
.live-card { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; padding: 6px var(--s2); }
.live-card > .btn { grid-column: auto; justify-self: end; }
.live-card .live-preview { -webkit-line-clamp: 1; }
.support-list-pane .live-card { flex-basis: 100%; }
.support-list-pane .live-card > .btn { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 768px) {
  .team-strip ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .team-chip { flex: none; }
  [data-view="support-detail"] .team-strip-wrap, [data-view="support-detail"] .support-page .page-header { display: none; }
}
.kpi-linked { position: relative; }
.kpi-cover { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.kpi-cover:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.kpi-linked .tip-wrap { z-index: 1; }
.kpi-linked .kpi-label { position: relative; }
.sf-info .inline-tight, .radio-card .inline-tight { flex-wrap: wrap; }
.dirty-dot.is-error { background: var(--critical-strong); }
.member-row { list-style: none; }
.member-row + .member-row { margin-top: var(--s2); }
.team-chip { white-space: nowrap; }
.sp-tabs { flex-wrap: wrap; }
.sp-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-filter-row .field:last-child { grid-column: 1 / -1; }

/* Multi-choice field (integration events): a fieldset of checkboxes with the sent name under each. */
.check-group { border: 0; margin: 0; padding: 0; }
.check-group > legend { padding: 0; margin-bottom: var(--s1); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check-list .checkbox { align-items: flex-start; }
.check-list .checkbox input { margin-top: 2px; }
