/* Funnel Compliance — design system after YATFA / GrowthFactory (2026-10).
   Light is the default; dark via [data-theme="dark"] (toggle in the top bar) or the system
   setting until the user picks. Every colour comes from the --app-* tokens below. */

:root,
[data-theme="light"] {
  color-scheme: light;
  --app-background: #fafbfc;
  --app-surface: #ffffff;
  --app-surface-raised: #f1f5f9;
  --app-surface-hover: #edf2f7;
  --app-surface-active: #e2e8f0;
  --app-text: #0f172a;
  --app-text-secondary: #475569;
  --app-text-muted: #596779;
  --app-border: #e4e7ec;
  --app-border-strong: #c3cad5;
  --app-accent-solid: #0b4fd0;
  --app-accent-ink: #095cdf;
  --app-accent-surface: #eaf1ff;
  --app-accent-ambient: #0062fc26;
  --app-success: #0b7648;
  --app-success-surface: #e4faf0;
  --app-warning: #8e5d0f;
  --app-warning-surface: #fdf5e6;
  --app-error: #d11a20;
  --app-error-surface: #fdebec;
  --app-error-solid: #e5131a;
  --app-info: #067282;
  --app-info-surface: #e3f7fa;
  --app-nav-active-bg: rgba(34, 197, 94, 0.1);
  --app-nav-active-text: #0b7648;
  --app-overlay: #0f172a73;
  --app-shadow: inset 0 0 0 1px #ffffffd9, 0 1px 2px #17171f0f, 0 8px 24px -16px #17171f29;
  --app-shadow-2: inset 0 0 0 1px #ffffffe6, 0 2px 6px #17171f12, 0 16px 36px -20px #17171f38;
  --app-shadow-overlay: 0 4px 12px #17171f1a, 0 24px 60px -18px #17171f47;
  --sev-high: #d11a20;
  --sev-high-surface: #fdebec;
  --sev-medium: #a1670b;
  --sev-medium-surface: #fdf5e6;
  --sev-low: #095cdf;
  --sev-low-surface: #eaf1ff;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --app-background: #020617;
  --app-surface: #0f172a;
  --app-surface-raised: #1e293b;
  --app-surface-hover: #1a2438;
  --app-surface-active: #29364d;
  --app-text: #f8fafc;
  --app-text-secondary: #a3b2c6;
  --app-text-muted: #8091a6;
  --app-border: #263041;
  --app-border-strong: #4a5568;
  --app-accent-solid: #2563eb;
  --app-accent-ink: #6aa2f9;
  --app-accent-surface: #0d1f44;
  --app-accent-ambient: #0062fc33;
  --app-success: #0ad17b;
  --app-success-surface: #0e3336;
  --app-warning: #f0a020;
  --app-warning-surface: #312c28;
  --app-error: #f26368;
  --app-error-surface: #311e2f;
  --app-error-solid: #e5131a;
  --app-info: #01bad5;
  --app-info-surface: #0d2f44;
  --app-nav-active-bg: rgba(10, 209, 123, 0.12);
  --app-nav-active-text: #0ad17b;
  --app-overlay: #020617b8;
  --app-shadow: inset 0 0 0 1px #ffffff0e, 0 1px 2px #0006, 0 8px 24px -14px #0000008c;
  --app-shadow-2: inset 0 0 0 1px #ffffff12, 0 2px 6px #0000006b, 0 16px 40px -18px #0009;
  --app-shadow-overlay: 0 4px 12px #00000073, 0 24px 64px -16px #000000b3;
  --sev-high: #f26368;
  --sev-high-surface: #311e2f;
  --sev-medium: #f0a020;
  --sev-medium-surface: #312c28;
  --sev-low: #6aa2f9;
  --sev-low-surface: #0d1f44;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--app-background); color: var(--app-text); }
body {
  font: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--app-accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--app-accent-surface); }
:focus-visible { outline: 2px solid var(--app-accent-ink); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12px; }
code { background: var(--app-surface-raised); padding: 1px 6px; border-radius: 6px; color: var(--app-text-secondary); }
img { max-width: 100%; }
.muted { color: var(--app-text-muted); }
.secondary { color: var(--app-text-secondary); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ── Shell: sidebar 256px / collapsed 68px ─────────────────────────────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: 256px;
  display: flex; flex-direction: column;
  background: var(--app-surface); border-right: 1px solid var(--app-border);
  transition: width .2s ease, transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; flex-shrink: 0; color: var(--app-text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, #0062fc, #7c3aed 55%, #e5131a);
}
.brand-name { display: block; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: var(--app-text-muted); line-height: 1.2; }
.nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.nav-group { margin-bottom: 16px; }
.nav-title { padding: 0 12px; margin: 0 0 4px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--app-text-muted); }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 8px;
  color: var(--app-text); font-size: 14px; transition: background .15s ease;
}
.nav a:hover { background: var(--app-surface-hover); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--app-nav-active-bg); color: var(--app-nav-active-text); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--app-text-muted); }
.sidebar-foot { border-top: 1px solid var(--app-border); padding: 8px; }
.sidebar-foot button { width: 100%; justify-content: flex-start; }
.main { min-height: 100vh; display: flex; flex-direction: column; min-width: 0; transition: margin .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--app-surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--app-border);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--app-text-muted); min-width: 0; }
.crumbs a { color: var(--app-text-muted); }
.crumbs a:hover { color: var(--app-text); text-decoration: none; }
.crumbs .here { color: var(--app-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 24px 32px 64px; flex: 1; }
.content.narrow { max-width: 980px; }
.content.full { max-width: none; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--app-text-secondary); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--app-accent-surface); color: var(--app-accent-ink); font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.mobile-only { display: none !important; }
@media (min-width: 900px) {
  .main { margin-left: 256px; }
  [data-sidebar="collapsed"] .sidebar { width: 68px; }
  [data-sidebar="collapsed"] .main { margin-left: 68px; }
  [data-sidebar="collapsed"] .nav-label, [data-sidebar="collapsed"] .brand-text, [data-sidebar="collapsed"] .nav .count { display: none; }
  [data-sidebar="collapsed"] .nav-title { visibility: hidden; height: 6px; margin: 0; }
  [data-sidebar="collapsed"] .collapse-icon { transform: rotate(180deg); }
}
@media (max-width: 899px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--app-shadow-overlay); }
  [data-nav="open"] .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 40; background: var(--app-overlay); opacity: 0; pointer-events: none; transition: opacity .2s; }
  [data-nav="open"] .scrim { opacity: 1; pointer-events: auto; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .content { padding: 16px 16px 48px; }
  .topbar { padding: 0 12px; }
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--app-text-muted); margin-bottom: 6px; }
.page-head h1 { font-size: 26px; font-weight: 800; line-height: 1.2; }
.page-head .sub { margin-top: 6px; color: var(--app-text-muted); font-size: 14px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font: 500 14px/1 var(--font); white-space: nowrap; cursor: pointer; user-select: none; text-decoration: none !important;
  transition: transform .15s cubic-bezier(.2,0,0,1), box-shadow .15s cubic-bezier(.2,0,0,1), background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; font-weight: 600; }
.btn.icon-only { width: 36px; height: 36px; padding: 0; }
.btn.primary { background: var(--app-accent-solid); color: #fff; }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: inset 0 1px 0 #ffffff3d, 0 12px 28px -10px #0000004d, 0 14px 40px -12px var(--app-accent-ambient); }
.btn.secondary { background: var(--app-surface); color: var(--app-text); border-color: var(--app-border); }
.btn.secondary:hover:not(:disabled) { background: var(--app-surface-hover); }
.btn.ghost { background: transparent; color: var(--app-text); }
.btn.ghost:hover:not(:disabled) { background: var(--app-surface-hover); }
.btn.danger { background: var(--app-error-solid); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .spin { display: none; }
.btn.loading .spin { display: inline-block; animation: spin 0.8s linear infinite; }
.btn.loading .btn-icon { display: none; }

/* ── Panels ────────────────────────────────────────────────────────────── */
.panel { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 16px; box-shadow: var(--app-shadow); padding: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-head .sub { margin-top: 2px; font-size: 13px; color: var(--app-text-muted); }
.panel.flush .panel-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
@media (max-width: 1100px) { .grid.two { grid-template-columns: minmax(0, 1fr); } }

/* ── KPI tiles ─────────────────────────────────────────────────────────── */
.kpi { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 14px; box-shadow: var(--app-shadow); padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--app-text-muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { margin-top: 6px; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .hint { margin-top: 2px; font-size: 12px; color: var(--app-text-muted); }
.kpi.high .value { color: var(--sev-high); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; background: var(--app-surface-raised); color: var(--app-text-secondary); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.accent { background: var(--app-accent-surface); color: var(--app-accent-ink); }
.badge.success { background: var(--app-success-surface); color: var(--app-success); }
.badge.warning { background: var(--app-warning-surface); color: var(--app-warning); }
.badge.error { background: var(--app-error-surface); color: var(--app-error); }
.badge.info { background: var(--app-info-surface); color: var(--app-info); }
.badge.running .dot { animation: pulse 1.2s ease-in-out infinite; }
.sev { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 22px; padding: 0 7px; border-radius: 7px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sev.high { background: var(--sev-high-surface); color: var(--sev-high); }
.sev.medium { background: var(--sev-medium-surface); color: var(--sev-medium); }
.sev.low { background: var(--sev-low-surface); color: var(--sev-low); }
.sev.zero { background: transparent; color: var(--app-text-muted); font-weight: 500; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: block; }
.field + .field { margin-top: 14px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--app-text); margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--app-text-muted); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--app-border); background: var(--app-surface); color: var(--app-text);
  font: 14px/1.4 var(--font); transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--app-text-muted); }
.input:hover:not(:disabled), .select:hover:not(:disabled), .textarea:hover:not(:disabled) { background: var(--app-surface-hover); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--app-accent-ink); box-shadow: 0 0 0 3px var(--app-accent-ambient); background: var(--app-surface); }
.input.lg { min-height: 48px; font-size: 15px; padding: 10px 14px; }
.input.invalid { border-color: var(--app-error); box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-error) 18%, transparent); }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23596779' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.select.sm, .input.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.select.sm { padding-right: 30px; background-position: right 8px center; }
.textarea { resize: vertical; min-height: 44px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--app-text-muted); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--app-border); background: var(--app-surface); font-size: 13px; font-weight: 500; color: var(--app-text-secondary);
  transition: all .15s;
}
.chip span:hover { background: var(--app-surface-hover); }
.chip input:checked + span { background: var(--app-accent-surface); border-color: color-mix(in srgb, var(--app-accent-ink) 40%, transparent); color: var(--app-accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--app-accent-ink); outline-offset: 2px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--app-border); border-radius: 12px; cursor: pointer; transition: all .15s; }
.radio-card:hover { background: var(--app-surface-hover); }
.radio-card:has(input:checked) { border-color: color-mix(in srgb, var(--app-accent-ink) 50%, transparent); background: var(--app-accent-surface); }
.radio-card input { margin-top: 3px; accent-color: var(--app-accent-solid); }
.radio-card b { display: block; font-size: 14px; }
.radio-card span { display: block; font-size: 12.5px; color: var(--app-text-muted); margin-top: 2px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--app-text-secondary); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary .icon { transform: rotate(90deg); }
details.more .more-body { margin-top: 12px; }

/* ── Segmented control ─────────────────────────────────────────────────── */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--app-surface-raised); border: 1px solid var(--app-border); max-width: 100%; overflow-x: auto; }
.segmented button, .segmented a {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border: 0; border-radius: 9px;
  background: transparent; color: var(--app-text-secondary); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.segmented button:hover, .segmented a:hover { color: var(--app-text); text-decoration: none; }
.segmented [aria-selected="true"], .segmented [aria-current="true"] { background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow); font-weight: 600; }
.segmented.sm button { height: 30px; padding: 0 10px; font-size: 13px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; background: var(--app-surface); color: var(--app-text-muted); font-size: 12px; font-weight: 600; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--app-border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--app-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; transition: background .12s; }
.table tbody tr.link:hover { background: var(--app-surface-hover); }
.table .title-cell { font-weight: 600; color: var(--app-text); }
.table .title-cell .xs { font-weight: 400; }
.table td.right, .table th.right { text-align: right; }
.table .chev { color: var(--app-text-muted); width: 28px; }

/* ── Alerts, empty states ──────────────────────────────────────────────── */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; border: 1px solid transparent; }
.alert .icon { margin-top: 1px; }
.alert.info { background: var(--app-info-surface); color: var(--app-text); border-color: color-mix(in srgb, var(--app-info) 25%, transparent); }
.alert.info .icon { color: var(--app-info); }
.alert.warning { background: var(--app-warning-surface); color: var(--app-text); border-color: color-mix(in srgb, var(--app-warning) 25%, transparent); }
.alert.warning .icon { color: var(--app-warning); }
.alert.error { background: var(--app-error-surface); color: var(--app-text); border-color: color-mix(in srgb, var(--app-error) 25%, transparent); }
.alert.error .icon { color: var(--app-error); }
.alert.success { background: var(--app-success-surface); color: var(--app-text); border-color: color-mix(in srgb, var(--app-success) 25%, transparent); }
.alert.success .icon { color: var(--app-success); }
.empty { text-align: center; padding: 48px 20px; color: var(--app-text-muted); }
.empty .icon { width: 36px; height: 36px; color: var(--app-text-muted); margin-bottom: 8px; }
.empty h3 { color: var(--app-text); font-size: 16px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ── Dropzone and screen cards ─────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 170px; padding: 24px; border: 1.5px dashed var(--app-border-strong); border-radius: 14px; cursor: pointer;
  background: var(--app-surface-raised); color: var(--app-text-secondary); transition: all .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--app-accent-ink); background: var(--app-accent-surface); color: var(--app-accent-ink); }
.dropzone .icon { width: 30px; height: 30px; }
.dropzone b { color: var(--app-text); font-size: 15px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.shot-card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--app-shadow); }
.shot-card.dragging { opacity: .4; }
.shot-card.drop-target { outline: 2px solid var(--app-accent-ink); }
.shot-img { position: relative; height: 210px; background: var(--app-surface-raised); overflow: hidden; cursor: zoom-in; }
.shot-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.shot-num { position: absolute; top: 8px; left: 8px; background: color-mix(in srgb, var(--app-text) 78%, transparent); color: var(--app-surface); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.shot-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.shot-card:hover .shot-tools, .shot-card:focus-within .shot-tools { opacity: 1; }
.shot-tools button { width: 28px; height: 28px; border-radius: 8px; border: 0; display: grid; place-items: center; cursor: pointer; background: color-mix(in srgb, var(--app-surface) 92%, transparent); color: var(--app-text); box-shadow: var(--app-shadow); }
.shot-tools button:hover { background: var(--app-surface); }
.shot-body { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.shot-name { font-size: 12px; color: var(--app-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--app-text-secondary); }
.shot-meta .action { color: var(--app-text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── Progress stepper ──────────────────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; color: var(--app-text-muted); }
.steps .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--app-border-strong); flex-shrink: 0; background: var(--app-surface); }
.steps li.done { color: var(--app-text); }
.steps li.done .mark { background: var(--app-success); border-color: var(--app-success); color: #fff; }
.steps li.now { color: var(--app-text); font-weight: 600; }
.steps li.now .mark { border-color: var(--app-accent-ink); color: var(--app-accent-ink); }
.steps li.now .mark .icon { animation: spin 1s linear infinite; }
.steps li.fail .mark { background: var(--app-error); border-color: var(--app-error); color: #fff; }
.steps .detail { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--app-text-muted); text-align: right; }
.progress { height: 6px; border-radius: 999px; background: var(--app-surface-raised); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--app-accent-solid), #7c3aed); border-radius: inherit; transition: width .4s ease; }
.progress.indeterminate > div { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }

/* ── Report frame, tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--app-border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { height: 40px; padding: 0 14px; border: 0; background: none; color: var(--app-text-muted); font: 500 14px var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tabs button:hover { color: var(--app-text); }
.tabs button[aria-selected="true"] { color: var(--app-text); border-bottom-color: var(--app-accent-solid); font-weight: 600; }
.report-frame { width: 100%; height: calc(100vh - 220px); min-height: 640px; border: 1px solid var(--app-border); border-radius: 14px; background: #fff; display: block; }
.priority-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.priority-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }

/* ── Chat ──────────────────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 12px; min-height: 160px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg .who { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.msg.user { flex-direction: row-reverse; }
.msg.user .who { background: var(--app-accent-surface); color: var(--app-accent-ink); }
.msg.assistant .who { background: linear-gradient(135deg, #0062fc, #7c3aed); color: #fff; }
.bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; max-width: min(720px, 88%); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--app-accent-solid); color: #fff; border-top-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--app-surface-raised); color: var(--app-text); border-top-left-radius: 4px; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble h3, .bubble h4 { font-size: 14px; margin: 10px 0 4px; }
.bubble code { background: color-mix(in srgb, var(--app-text) 8%, transparent); }
.bubble pre { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 12.5px; }
.bubble a { color: var(--app-accent-ink); }
.bubble .meta { margin-top: 6px; font-size: 11px; color: var(--app-text-muted); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--app-text-muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.suggestions button { border: 1px solid var(--app-border); background: var(--app-surface); color: var(--app-text-secondary); border-radius: 999px; padding: 6px 12px; font: 13px var(--font); cursor: pointer; text-align: left; }
.suggestions button:hover { background: var(--app-surface-hover); color: var(--app-text); }
.composer { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--app-border); border-radius: 14px; background: var(--app-surface); padding: 6px 6px 6px 12px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--app-accent-ink); box-shadow: 0 0 0 3px var(--app-accent-ambient); }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; background: transparent; color: var(--app-text); font: 14px/1.45 var(--font); padding: 8px 0; max-height: 200px; min-height: 24px; }
.chat-panel { position: sticky; top: 72px; height: calc(100vh - 96px); display: flex; flex-direction: column; }
.chat-page { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; height: calc(100vh - 56px - 48px); }
.chat-page .panel { min-height: 0; }
.chat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; overflow-y: auto; }
.chat-list a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--app-text); font-size: 13.5px; }
.chat-list a:hover { background: var(--app-surface-hover); text-decoration: none; }
.chat-list a[aria-current="true"] { background: var(--app-accent-surface); color: var(--app-accent-ink); font-weight: 600; }
.chat-list .xs { display: block; color: var(--app-text-muted); font-weight: 400; }
@media (max-width: 900px) { .chat-page { grid-template-columns: 1fr; height: auto; } .chat-panel { position: static; height: 560px; } }

/* ── Lightbox, toast ───────────────────────────────────────────────────── */
dialog.lightbox { padding: 0; border: 0; border-radius: 14px; max-width: min(96vw, 560px); max-height: 94vh; overflow: auto; background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow-overlay); }
dialog.lightbox::backdrop { background: var(--app-overlay); }
dialog.lightbox img { display: block; width: 100%; height: auto; }
dialog.lightbox .bar { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: var(--app-surface); border-bottom: 1px solid var(--app-border); font-size: 13px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: var(--app-text); color: var(--app-surface); box-shadow: var(--app-shadow-overlay); font-size: 13.5px; animation: rise .2s ease; }
.toast.error { background: var(--app-error-solid); color: #fff; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, #0062fc 14%, transparent), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #7c3aed 12%, transparent), transparent 60%), var(--app-background); }
.auth .panel { width: 100%; max-width: 400px; padding: 28px; }
.auth h1 { font-size: 22px; font-weight: 800; margin: 18px 0 4px; }

/* ── Motion ────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.skeleton { background: linear-gradient(90deg, var(--app-surface-raised), var(--app-surface-hover), var(--app-surface-raised)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: inline; }
[data-theme="dark"] .theme-moon { display: none; }
