/* AlertBridge dashboard stylesheet.
   One file, design tokens on :root, a dark theme that follows the OS. The
   top bar stays dark in both themes so the mode colour always reads the same. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f5;
  --border: #e3e7ed;
  --border-strong: #cfd5de;
  --text: #0f1729;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef4ff;
  --accent-text: #1d4ed8;
  --ai: #7c3aed;
  --ai-2: #4f46e5;
  --ai-soft: #f5f1ff;
  --ai-text: #6d28d9;
  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: #fef3f2;
  --danger-text: #b42318;
  --success: #079455;
  --success-soft: #ecfdf3;
  --success-text: #067647;
  --warn: #dc6803;
  --warn-soft: #fffaeb;
  --warn-text: #b54708;

  --t-blue-bg: #eef4ff;   --t-blue-fg: #1d4ed8;
  --t-green-bg: #ecfdf3;  --t-green-fg: #067647;
  --t-red-bg: #fef3f2;    --t-red-fg: #b42318;
  --t-amber-bg: #fffaeb;  --t-amber-fg: #b54708;
  --t-orange-bg: #fff4ed; --t-orange-fg: #c4320a;
  --t-violet-bg: #f5f1ff; --t-violet-fg: #6d28d9;
  --t-cyan-bg: #ecfdff;   --t-cyan-fg: #0e7090;
  --t-gray-bg: #f2f4f7;   --t-gray-fg: #475467;

  --topbar: #0c1322;
  --topbar-2: #16203a;
  --topbar-text: #c6cfdd;
  --topbar-muted: #8391a7;

  --mode-off: #64748b;
  --mode-dry_run: #d97706;
  --mode-semi_auto: #0891b2;
  --mode-auto: #16a34a;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .20);
  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(37, 99, 235, .25);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f18;
    --surface: #111827;
    --surface-2: #0e1521;
    --surface-3: #1a2334;
    --border: #1f2a3b;
    --border-strong: #334155;
    --text: #e7ebf1;
    --text-2: #c4cbd6;
    --muted: #8d97a8;
    --faint: #5f6b7d;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, .14);
    --accent-text: #93c5fd;
    --ai: #8b5cf6;
    --ai-2: #6366f1;
    --ai-soft: rgba(139, 92, 246, .14);
    --ai-text: #c4b5fd;
    --danger: #f04438;
    --danger-hover: #f97066;
    --danger-soft: rgba(240, 68, 56, .13);
    --danger-text: #fda29b;
    --success: #17b26a;
    --success-soft: rgba(23, 178, 106, .13);
    --success-text: #75e0a7;
    --warn: #f79009;
    --warn-soft: rgba(247, 144, 9, .13);
    --warn-text: #fec84b;

    --t-blue-bg: rgba(59, 130, 246, .15);   --t-blue-fg: #93c5fd;
    --t-green-bg: rgba(23, 178, 106, .15);  --t-green-fg: #75e0a7;
    --t-red-bg: rgba(240, 68, 56, .15);     --t-red-fg: #fda29b;
    --t-amber-bg: rgba(247, 144, 9, .15);   --t-amber-fg: #fec84b;
    --t-orange-bg: rgba(251, 101, 20, .15); --t-orange-fg: #fdba74;
    --t-violet-bg: rgba(139, 92, 246, .17); --t-violet-fg: #c4b5fd;
    --t-cyan-bg: rgba(6, 174, 212, .15);    --t-cyan-fg: #67e3f9;
    --t-gray-bg: rgba(148, 163, 184, .13);  --t-gray-fg: #b3bdcc;

    --topbar: #060a12;
    --topbar-2: #111a2c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    --focus: 0 0 0 3px rgba(59, 130, 246, .35);
    color-scheme: dark;
  }
}

/* ---- base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.mono.box { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ic.sm { width: 14px; height: 14px; vertical-align: -2px; }
.ic.lg { width: 20px; height: 20px; }
.ic.xl { width: 28px; height: 28px; stroke-width: 1.6; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.mt { margin-top: 12px; } .mt-lg { margin-top: 20px; } .mb { margin-bottom: 12px; } .mb-0 { margin-bottom: 0; }

/* ---- top bar ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 200;
  background: var(--topbar); color: var(--topbar-text);
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 20px;
  border-bottom: 3px solid var(--mode-color, var(--mode-dry_run));
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .45);
}
.brand-mark .ic { width: 16px; height: 16px; stroke-width: 2.4; }
.nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.nav-link, .nav-menu > summary {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 8px;
  color: var(--topbar-text); font-size: 13.5px; font-weight: 500;
  cursor: pointer; list-style: none; white-space: nowrap;
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-link:hover, .nav-menu > summary:hover, .nav-menu[open] > summary { background: var(--topbar-2); color: #fff; text-decoration: none; }
.nav-link.active, .nav-menu.active > summary { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-link .ic, .nav-menu > summary .ic { opacity: .85; }
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.nav-badge.soft { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* dropdown menus (details-based, no JS needed to open) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 300;
  min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.menu-pop.right { left: auto; right: 0; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 7px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item .ic { color: var(--muted); }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger-text); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; background: none; }
.menu-item small { display: block; color: var(--muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.menu-pop form { margin: 0; }
.mobile-only { display: none; }

/* mode switch */
.mode-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 11px 6px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  color: #fff; font-size: 13px; font-weight: 600;
}
.mode-btn:hover { background: rgba(255, 255, 255, .12); }
.mode-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mode-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-color) 30%, transparent); }
.mode-opt { align-items: flex-start; }
.mode-opt .mode-dot { margin-top: 5px; }
.mode-opt.current { background: var(--surface-3); }
.mode-off { --mode-color: var(--mode-off); }
.mode-dry_run { --mode-color: var(--mode-dry_run); }
.mode-semi_auto { --mode-color: var(--mode-semi_auto); }
.mode-auto { --mode-color: var(--mode-auto); }
.user-btn { display: flex; align-items: center; gap: 7px; color: var(--topbar-text); font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.user-btn:hover { background: var(--topbar-2); color: #fff; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #334155; color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; }

/* ---- page layout -------------------------------------------------------- */
.page { max-width: 1360px; margin: 0 auto; padding: 22px 24px 64px; }
.page.narrow { max-width: 980px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .titles { flex: 1; min-width: 260px; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--text); }

.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-editor { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
.sticky { position: sticky; top: 76px; }

/* ---- cards ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { flex: 1; display: flex; align-items: center; gap: 8px; }
.card-head .ic { color: var(--muted); }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card + .card { margin-top: 16px; }
.section-title { font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin: 0 0 8px; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13.5px; font-weight: 550; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-sm); text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.btn:focus-visible, .input:focus, .select:focus, .textarea:focus { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-danger-soft { color: var(--danger-text); }
.btn-danger-soft:hover { background: var(--danger-soft); color: var(--danger-text); }
.btn-ai { background: linear-gradient(135deg, var(--ai), var(--ai-2)); border-color: transparent; color: #fff; }
.btn-ai:hover { filter: brightness(1.08); color: #fff; background: linear-gradient(135deg, var(--ai), var(--ai-2)); }
.btn-ai-soft { background: var(--ai-soft); border-color: transparent; color: var(--ai-text); box-shadow: none; }
.btn-ai-soft:hover { background: var(--ai-soft); filter: brightness(.97); color: var(--ai-text); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 4px; }
.btn-icon { width: 30px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-block { width: 100%; }
.btn .spin { display: none; }
.btn.busy .spin { display: inline-block; }
.btn.busy { pointer-events: none; opacity: .85; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
form.inline { display: inline; margin: 0; }

.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---- badges --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--t-gray-bg); color: var(--t-gray-fg);
}
.badge .ic { width: 13px; height: 13px; }
.badge.round { border-radius: 999px; }
.badge.sm { height: 19px; padding: 0 6px; font-size: 11px; }
.t-blue { background: var(--t-blue-bg); color: var(--t-blue-fg); }
.t-green { background: var(--t-green-bg); color: var(--t-green-fg); }
.t-red { background: var(--t-red-bg); color: var(--t-red-fg); }
.t-amber { background: var(--t-amber-bg); color: var(--t-amber-fg); }
.t-orange { background: var(--t-orange-bg); color: var(--t-orange-fg); }
.t-violet { background: var(--t-violet-bg); color: var(--t-violet-fg); }
.t-cyan { background: var(--t-cyan-bg); color: var(--t-cyan-fg); }
.t-gray { background: var(--t-gray-bg); color: var(--t-gray-fg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.t-blue { background: var(--accent); } .dot.t-green { background: var(--success); } .dot.t-red { background: var(--danger); }
.dot.t-amber { background: var(--warn); } .dot.t-gray { background: var(--faint); } .dot.t-violet { background: var(--ai); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 2px 8px; border-radius: 6px; font-size: 12px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
button.chip { font: inherit; font-size: 12px; cursor: pointer; }
button.chip:hover { border-color: var(--border-strong); color: var(--text); }
.kbd { font: 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); }

/* ---- tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 550; font-size: 13.5px; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }
.tab.active .count { background: var(--accent-soft); color: var(--accent-text); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border); }
.seg label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 550; color: var(--muted); cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg label:has(input:focus-visible) { box-shadow: var(--focus); }

/* ---- forms ---------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.label .opt { font-weight: 400; color: var(--faint); }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.select { padding-right: 28px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input.sm, .select.sm { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.select.sm { padding-right: 26px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input-icon .input { padding-left: 32px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; cursor: pointer; }
.check .hint { margin-top: 1px; }
input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field { margin: 0; }
.inline-fields { display: flex; gap: 8px; align-items: center; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
details.more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 550; color: var(--muted); user-select: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary .ic { transition: transform .15s; }
details.more[open] > summary .ic { transform: rotate(90deg); }
details.more > summary:hover { color: var(--text); }
details.more > .more-body { margin-top: 12px; }

/* outcome choice cards */
.choices { display: grid; gap: 8px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .box {
  display: flex; flex-direction: column; gap: 6px; height: 100%;
  padding: 11px 11px 10px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.choice .box:hover { border-color: var(--border-strong); background: var(--surface-2); }
.choice .box .t { font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 7px; color: var(--text); }
.choice .box .d { font-size: 12px; color: var(--muted); line-height: 1.35; }
.choice .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.choice input:checked + .box { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice input:focus-visible + .box { box-shadow: var(--focus); }
.opt-panel { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }

/* ---- tables ----------------------------------------------------------------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13.5px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .08s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: var(--accent-soft); }
.table .sel { width: 36px; padding-right: 0; }
.table .sel input { width: 15px; height: 15px; margin: 0; vertical-align: middle; }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .1s; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }
.cell-title { font-weight: 550; color: var(--text); display: block; max-width: 560px; }
.cell-title:hover { color: var(--accent-text); }
.is-new .cell-title { font-weight: 650; }
.cell-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.cell-sub .sep { color: var(--faint); }
.table.compact td { padding: 7px 12px; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--muted); }

.cp2 { color: var(--warn-text); font-weight: 600; }
.cp3 { color: var(--t-orange-fg); font-weight: 700; }
.cp4 { color: var(--danger-text); font-weight: 750; }
.cp5 { color: #fff; background: var(--danger); font-weight: 750; padding: 0 6px; border-radius: 5px; }

/* bulk bar */
.bulkbar {
  position: sticky; top: 64px; z-index: 50;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px 8px 14px; margin-bottom: 10px;
  background: var(--topbar); color: #fff; border-radius: 10px; box-shadow: var(--shadow-md);
}
.bulkbar .count { font-weight: 650; margin-right: 6px; }
.bulkbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.bulkbar .btn:hover { background: rgba(255,255,255,.16); }
.bulkbar .btn-danger { background: var(--danger); border-color: var(--danger); }

/* toolbar */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { width: 300px; max-width: 100%; }

/* ---- callouts / empty states ---------------------------------------------- */
.callout { display: flex; gap: 11px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.callout > .ic { margin-top: 2px; }
.callout .body { flex: 1; min-width: 0; }
.callout .title { font-weight: 650; margin-bottom: 2px; }
.callout.info { background: var(--accent-soft); border-color: transparent; color: var(--text-2); }
.callout.info > .ic { color: var(--accent-text); }
.callout.ai { background: var(--ai-soft); border-color: transparent; }
.callout.ai > .ic, .callout.ai .title { color: var(--ai-text); }
.callout.warn { background: var(--warn-soft); border-color: transparent; }
.callout.warn > .ic { color: var(--warn-text); }
.callout.danger { background: var(--danger-soft); border-color: transparent; }
.callout.danger > .ic { color: var(--danger-text); }
.callout.success { background: var(--success-soft); border-color: transparent; }
.callout.success > .ic { color: var(--success-text); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic.xl { color: var(--faint); margin-bottom: 10px; }
.empty .t { font-size: 15px; font-weight: 650; color: var(--text); margin-bottom: 4px; }
.empty .actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* definition lists */
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* stat tiles */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* code / message body */
pre.code { margin: 0; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; line-height: 1.5; max-height: 360px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.6; max-height: 560px; overflow: auto; color: var(--text-2); }
.msg-frame { width: 100%; height: 560px; border: 0; border-radius: 8px; background: #fff; }

/* list rows (cards with rows) */
.list { margin: 0; padding: 0; list-style: none; }
.list > li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list.compact > li { padding: 7px 14px; }

/* plan steps */
.plan { list-style: none; margin: 0; padding: 0; }
.plan li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.plan li:last-child { border-bottom: 0; }
.plan .step-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }

/* suggestion cards */
.sugg-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.sugg { display: flex; flex-direction: column; }
.sugg .card-body { flex: 1; }
.sugg .sender { font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.samples { margin: 10px 0 0; padding: 0; list-style: none; }
.samples li { display: flex; gap: 7px; align-items: baseline; font-size: 13px; color: var(--text-2); padding: 3px 0; }
.samples li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); flex: none; transform: translateY(-2px); }
.ai-line { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: var(--ai-soft); font-size: 13px; }
.ai-line .ic { color: var(--ai-text); margin-top: 1px; }

/* rule list */
.rule-name { font-weight: 650; color: var(--text); }
.rule-name:hover { color: var(--accent-text); }
.order-btns { display: inline-flex; flex-direction: column; gap: 1px; }
.order-btns button { width: 22px; height: 16px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--faint); cursor: pointer; display: grid; place-items: center; }
.order-btns button:hover { background: var(--surface-3); color: var(--text); }
.order-btns .ic { width: 13px; height: 13px; }
tr.disabled-rule td { opacity: .55; }

/* preview panel */
.preview-list { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow: auto; }
.preview-list li { padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.preview-list li:last-child { border-bottom: 0; }
.verdict { display: inline-flex; width: 20px; height: 20px; border-radius: 6px; place-items: center; flex: none; }
.verdict.yes { background: var(--success-soft); color: var(--success-text); }
.verdict.no { background: var(--surface-3); color: var(--faint); }

/* toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 500; display: flex; flex-direction: column-reverse; gap: 8px; max-width: min(440px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px 11px 14px;
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .2s ease-out;
}
.toast.ok { border-left-color: var(--success); }
.toast.ok > .ic { color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.err > .ic { color: var(--danger); }
.toast .msg { flex: 1; overflow-wrap: anywhere; }
.toast .x { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 0; }
.toast .x:hover { color: var(--text); }
.toast.leaving { opacity: 0; transform: translateX(10px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 400; display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; background: rgba(8, 12, 22, .55); backdrop-filter: blur(2px); }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 640px; max-height: 84vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-box.wide { max-width: 820px; }
.modal-box > form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.pv-head { margin-bottom: 12px; }
.pv-subj { font-weight: 650; font-size: 15px; }
.pv-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.pv-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.6; border-top: 1px solid var(--border); padding-top: 12px; color: var(--text-2); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.25), transparent), radial-gradient(900px 500px at 110% 110%, rgba(59,130,246,.2), transparent), var(--topbar); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }

.stepnum { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.ai-ink { color: var(--ai-text); }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }

/* ---- responsive ------------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-editor { grid-template-columns: minmax(0, 1fr); }
  .grid-editor .sticky { position: static; }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .nav-link span.lbl, .nav-menu > summary span.lbl { display: none; }
  .hide-md { display: none; }
}
@media (max-width: 760px) {
  .page { padding: 16px 14px 48px; }
  .topbar { gap: 6px; padding: 0 10px; }
  .nav-menu { display: none; }
  .mobile-only { display: block; }
  .nav-link { padding: 7px 8px; gap: 5px; }
  .mode-btn { padding: 6px 8px; }
  .brand span { display: none; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
  .sugg-grid { grid-template-columns: minmax(0, 1fr); }
  .mode-btn .lbl { display: none; }
  .toolbar .search { width: 100%; }
}
