/* ============ Design tokens ============ */
:root {
  --bg: #ffffff;
  --bg-page: #edf0f5;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --border: #dde3ec;
  --border-strong: #c8d0dc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --success: #15803d; --success-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --danger: #b91c1c;  --danger-soft: #fee2e2;
  --info: #1d4ed8;    --info-soft: #dbeafe;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }

/* ============ App shell ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
}
.sb-brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15.5px; color: var(--text);
}
.sb-logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sb-group { margin-bottom: 22px; }
.sb-group + .sb-group { padding-top: 18px; border-top: 1px solid var(--border); }
.sb-label {
  padding: 0 10px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.sb-link .icon { color: var(--muted); }
.sb-link:hover { background: var(--bg-hover); color: var(--text); }
.sb-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sb-link.active .icon { color: var(--accent); }
.sb-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--bg-hover); color: var(--muted);
  padding: 1px 8px; border-radius: 99px;
}
.sb-link.active .sb-badge { background: #fff; color: var(--accent); }
.sb-foot { padding: 12px; border-top: 1px solid var(--border); }
.quota { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); margin-bottom: 10px; }
.quota-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none;
}
.user-row .who { line-height: 1.25; min-width: 0; flex: 1; }
.user-row .who b { display: block; font-size: 13px; }
.user-row .who span { font-size: 12px; color: var(--muted); }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px; position: sticky; top: 0; z-index: 30;
}
.btn.tb-menu { display: none; }
.tb-search { position: relative; flex: 0 1 380px; }
.tb-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.tb-search input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); font: inherit;
}
.tb-search input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.content { padding: 32px 40px 72px; max-width: 1320px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }

/* Sections: clear groups of related content, each with its own heading */
.section { margin-top: 40px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
.section-title { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--accent); }
.section-sub { font-size: 13px; color: var(--muted); margin-top: 3px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.section-link { font-size: 13px; font-weight: 500; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* ============ Layout helpers ============ */
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt { margin-top: 20px; }
.mt-sm { margin-top: 10px; }

/* ============ Cards ============ */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); background: #f8fafd; border-radius: 12px 12px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg-subtle); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.stat { padding: 18px 20px; }

/* KPI tiles */
.kpi { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi, var(--accent)); }
.kpi-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--kpi-soft, var(--accent-soft)); color: var(--kpi, var(--accent)); }
.kpi-body { min-width: 0; }
.kpi .stat-label { font-size: 12.5px; }
.kpi .stat-value { font-size: 28px; margin: 4px 0 2px; line-height: 1.1; }
.kpi.t-indigo { --kpi: #4f46e5; --kpi-soft: #eef2ff; }
.kpi.t-green { --kpi: #16a34a; --kpi-soft: #dcfce7; }
.kpi.t-amber { --kpi: #d97706; --kpi-soft: #fef3c7; }
.kpi.t-blue { --kpi: #2563eb; --kpi-soft: #dbeafe; }

/* Attention strip */
.attention { border-left: 4px solid var(--warn-bar, #f59e0b); }
.attention.has-danger { --warn-bar: #ef4444; }
.attn-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 18px; font-size: 13.5px; }
.attn-item + .attn-item { border-top: 1px solid var(--border); }
.attn-item .icon { margin-top: 2px; }
.attn-item.warn .icon { color: #d97706; } .attn-item.danger .icon { color: #dc2626; }
.attn-item a { margin-left: auto; white-space: nowrap; font-weight: 500; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 4px; }
.stat-foot { font-size: 12.5px; color: var(--muted); }
.delta { font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; font: inherit; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: #fff; color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.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 { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.icon-only { padding: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: var(--bg-hover); color: var(--muted); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 20px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-subtle); }
.cell-main { font-weight: 600; color: var(--text); display: block; }
.cell-sub { font-size: 12.5px; color: var(--muted); display: block; }
.score-pill { font-weight: 700; font-variant-numeric: tabular-nums; }
.table-toolbar { display: flex; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.pager { display: flex; gap: 4px; }

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label { font-weight: 500; font-size: 13px; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 8px 12px; font: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); }
.textarea { min-height: 84px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.field-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:first-child { padding-top: 0; }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row .t { font-weight: 500; }
.setting-row .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); background: var(--bg-subtle); }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ Progress / charts ============ */
.progress { height: 6px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress.success > i { background: #22c55e; }
.progress.warn > i { background: #f59e0b; }
.progress.danger > i { background: #ef4444; }
.progress.info > i { background: #3b82f6; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 34px; background: #c7d2fe; border-radius: 5px 5px 0 0; position: relative; min-height: 3px; transition: background .12s; }
.bar:hover, .bar.hl { background: var(--accent); }
.bar-col span { font-size: 11px; color: var(--faint); }
.bar-col b { font-size: 11px; color: var(--muted); font-weight: 600; }
.hbar-row { display: grid; grid-template-columns: 120px 1fr 56px; gap: 12px; align-items: center; margin-bottom: 14px; }
.hbar-row:last-child { margin-bottom: 0; }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-val { position: absolute; text-align: center; line-height: 1.1; }
.ring .ring-val b { font-size: 28px; display: block; letter-spacing: -0.02em; }
.ring .ring-val span { font-size: 11px; color: var(--muted); font-weight: 500; }

/* ============ Misc components ============ */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.pc { margin: 0; padding-left: 18px; }
.pc li { margin-bottom: 8px; }
.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13px; }
.alert.info { background: var(--info-soft); border-color: #bfdbfe; color: #1e3a8a; }
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.alert.danger { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.code {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; overflow-x: auto; white-space: pre; margin: 0;
}
.code .c { color: #94a3b8; }
.code .s { color: #86efac; }
.code .k { color: #93c5fd; }
.platform { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.p-ig { background: linear-gradient(135deg, #f58529, #dd2a7b 55%, #8134af); }
.p-fb { background: #1877f2; }
.p-li { background: #0a66c2; }
.p-yt { background: #ef0000; }
.p-x { background: #111827; }
.p-apify { background: #2563eb; }
.p-ai { background: #c2410c; }
.p-g { background: #16a34a; }
.metric { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.metric .l { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check .ic { margin-top: 2px; }
.ic-info { color: #64748b; } .ic-pass { color: #16a34a; } .ic-warn { color: #d97706; } .ic-fail { color: #dc2626; }
.reco { padding: 16px 0; border-bottom: 1px solid var(--border); }
.reco:last-child { border-bottom: 0; padding-bottom: 0; }
.reco:first-child { padding-top: 0; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--bg-hover); color: var(--text-2); margin-right: 6px; }
.log { font-family: var(--mono); font-size: 12.5px; }
.log div { padding: 6px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 14px; }
.log div:last-child { border-bottom: 0; }
.log .t { color: var(--faint); flex: none; }
.log .lv-error { color: var(--danger); } .log .lv-warn { color: var(--warn); } .log .lv-info { color: var(--muted); }
.settings-note { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.preview-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.preview-cover { padding: 28px 24px; color: #fff; }
.preview-cover b { display: block; font-size: 18px; margin-bottom: 4px; }
.preview-body { padding: 18px 24px; }
.sticky-save { position: sticky; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; margin-top: 20px; box-shadow: var(--shadow-md); }

/* ============ Dashboard & readability ============ */
.topbar { box-shadow: 0 1px 0 rgba(15, 23, 42, .03); }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px; border-radius: 99px; background: #e0e7ff; color: #3730a3; font-weight: 600; font-size: 12.5px; }
.live-pill:hover { background: #c7d2fe; color: #312e81; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #4f46e5; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .5); } 50% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); } }
.table th { background: #f4f6fa; padding: 11px 20px; }
.table td { padding: 15px 20px; }
.table tbody tr { transition: background .1s; }
.chart { padding: 6px 4px 0; }
.chart .bars { height: 190px; gap: 6px; background: none; border-bottom: 1px solid var(--border-strong); position: relative; }
.chart .bars::before { content: ""; position: absolute; inset: 0 0 0 0; background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #edf0f5 calc(25% - 1px), #edf0f5 25%); pointer-events: none; }
.chart .bar-col { position: relative; z-index: 1; }
.chart .bar { background: #c7d2fe; border-radius: 6px 6px 0 0; }
.chart .bar.zero { background: transparent; min-height: 0; }
.chart .bar:hover { background: #818cf8; }
.chart .bar.hl { background: var(--accent); }
.chart-axis { display: flex; gap: 6px; padding: 8px 0 0; }
.chart-axis span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.chart-foot { display: flex; gap: 22px; padding-top: 14px; margin-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chart-foot b { color: var(--text); font-size: 15px; margin-right: 4px; }
.dist-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; margin-bottom: 16px; }
.dist-row:last-child { margin-bottom: 0; }
.dist-row .progress { grid-column: 1 / -1; height: 8px; }
.dist-row .dist-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.dot-sm { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.status-row + .status-row { border-top: 1px solid var(--border); }
.status-row .grow { flex: 1; min-width: 0; font-weight: 500; }
.mini-metrics { display: grid; grid-template-columns: repeat(3, 1fr); }
.mini-metrics > div { padding: 16px 20px; text-align: center; }
.mini-metrics > div + div { border-left: 1px solid var(--border); }
.mini-metrics .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.mini-metrics .l { font-size: 12.5px; color: var(--muted); }
.empty-chart { text-align: center; padding: 56px 20px; color: var(--muted); }
.stack > .section-head { margin: 10px 0 -6px; }
.stack > .section-head:first-child { margin-top: 0; }
.page-head + .stack, .page-head + .grid { margin-top: 28px; }
.mt > .section-head, .content > .section-head { margin-top: 28px; }

/* ============ Polish ============ */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
.empty { text-align: center; padding: 48px 20px; }
.empty-ic { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; background: var(--bg-hover); color: var(--muted); display: grid; place-items: center; }
.bars { background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #f1f5f9 calc(25% - 1px), #f1f5f9 25%); }
.table td .btn + .btn { margin-left: 4px; }
.tab .sb-badge { margin-left: 6px; }
.card-head .card-title + .card-sub { margin-top: 2px; }
html { scroll-behavior: smooth; }
::selection { background: var(--accent-soft); }
@media (max-width: 700px) {
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .hbar-row { grid-template-columns: 90px 1fr 48px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sticky-save { flex-direction: column; align-items: stretch; gap: 10px; }
  .table th, .table td { padding-left: 14px; padding-right: 14px; }
  .tb-right .badge { display: none; }
}

.est-box { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); }
.est-big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.est-side { text-align: right; min-width: 150px; }
details > summary { list-style: none; } details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--muted); } details[open] > summary::before { content: "▾ "; }

/* ============ Modal & toast ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 20px 50px rgba(15,23,42,.25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: 13px; display: flex; gap: 10px; align-items: center; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ Login ============ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg-subtle); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: var(--shadow-md); }
.login-card .sb-logo { width: 40px; height: 40px; margin-bottom: 18px; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g-main { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-md); }
  .main { margin-left: 0; }
  .btn.tb-menu { display: inline-flex; }
  .topbar { padding-left: 16px; padding-right: 16px; }
  .content { padding: 24px 16px 56px; }
  .section { margin-top: 32px; }
  .g2, .g3, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .tb-search { display: none; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
}

/* ============ Findings list ============ */
.finding { border-top: 1px solid var(--border); }
.finding:first-child { border-top: 0; }
.finding summary { display: flex; align-items: center; gap: 12px; padding: 13px 20px; cursor: pointer; list-style: none; }
.finding summary::-webkit-details-marker { display: none; }
.finding summary::before { content: "▸"; color: var(--muted); font-size: 12px; }
.finding[open] summary::before { content: "▾"; }
.finding summary:hover { background: var(--bg-subtle); }
.finding summary b { flex: 1; font-weight: 600; }
.finding .f-count { white-space: nowrap; }
.finding-body { padding: 4px 20px 20px 46px; font-size: 13.5px; }
.finding-body .label { margin-bottom: 3px; }
