:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #111827;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --dark: #111827;
  --dark-2: #1f2937;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --purple: #7e22ce;
  --purple-soft: #faf5ff;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 12px rgba(15, 23, 42, .04);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, .18);
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.no-wrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.full-width { width: 100%; }

/* ---------- Authentication ---------- */
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 44px clamp(32px, 6vw, 92px);
  color: #fff;
  background:
    radial-gradient(circle at 80% 16%, rgba(37, 99, 235, .42), transparent 32%),
    radial-gradient(circle at 12% 85%, rgba(16, 185, 129, .18), transparent 30%),
    linear-gradient(145deg, #0b1120, #111827 54%, #172554);
}
.auth-visual::before,
.auth-visual::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 999px;
}
.auth-visual::before { width: 520px; height: 520px; right: -230px; bottom: -180px; }
.auth-visual::after { width: 320px; height: 320px; right: -120px; bottom: -80px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--dark);
  background: #fff;
  font-weight: 900;
  letter-spacing: -.04em;
}
.brand strong { display: block; font-size: 16px; line-height: 1.15; }
.brand small { display: block; margin-top: 3px; color: inherit; opacity: .62; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.brand-large .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.brand-large strong { font-size: 18px; }
.auth-copy { position: relative; z-index: 1; max-width: 700px; margin-top: clamp(80px, 13vh, 150px); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  color: #bfdbfe;
  background: rgba(255,255,255,.05);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.auth-copy h1 { max-width: 680px; margin: 22px 0 18px; font-size: clamp(38px, 5.1vw, 68px); line-height: 1.03; letter-spacing: -.045em; }
.auth-copy > p { max-width: 640px; color: #cbd5e1; font-size: 17px; line-height: 1.72; }
.auth-points { display: grid; gap: 16px; margin-top: 42px; }
.auth-points > div { display: grid; grid-template-columns: 42px 1fr; gap: 14px; align-items: start; }
.auth-points span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; color: #93c5fd; font-size: 11px; font-weight: 800; }
.auth-points p { margin: 0; color: #94a3b8; font-size: 13px; line-height: 1.6; }
.auth-points strong { color: #f8fafc; font-size: 14px; }
.auth-panel { display: grid; place-items: center; padding: 28px; background: #fff; }
.auth-card { width: min(100%, 430px); }
.mobile-brand { display: none; color: var(--text); margin-bottom: 36px; }
.auth-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.035em; }
.auth-card .lead { margin: 0 0 30px; color: var(--muted); line-height: 1.6; }
.auth-footnote { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: #cbd5e1;
  background: var(--dark);
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-brand { height: 86px; padding: 0 24px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-brand .brand-mark { width: 38px; height: 38px; }
.nav-list { display: grid; gap: 6px; padding: 20px 14px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 11px;
  color: #94a3b8;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  transition: .18s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, rgba(37,99,235,.32), rgba(37,99,235,.14)); box-shadow: inset 0 0 0 1px rgba(96,165,250,.18); }
.nav-glyph { display: inline-grid; place-items: center; width: 22px; height: 22px; color: #94a3b8; font-size: 16px; }
.nav-item.active .nav-glyph { color: #93c5fd; }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; color: #fff; background: var(--primary); font-size: 10px; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.user-mini { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 11px; color: #dbeafe; background: #1e3a8a; font-size: 13px; font-weight: 800; }
.user-mini div { min-width: 0; }
.user-mini strong, .user-mini small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mini strong { color: #f8fafc; font-size: 12px; }
.user-mini small { margin-top: 3px; color: #64748b; font-size: 10px; }
.sidebar .icon-btn { color: #94a3b8; }
.sidebar .icon-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.main-area { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px clamp(20px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(16px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.mobile-menu { display: none !important; }
.global-filters { display: flex; align-items: end; justify-content: flex-end; gap: 10px; }
.select-compact { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.select-compact select { min-width: 122px; height: 38px; padding: 0 32px 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: #fff; font-size: 12px; font-weight: 650; text-transform: none; letter-spacing: 0; }
.page-content { min-width: 0; padding: 26px clamp(18px, 3vw, 40px) 48px; }
.sidebar-backdrop { display: none; }

/* ---------- Components ---------- */
.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  transition: .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-primary { color: #fff; background: var(--dark); box-shadow: 0 8px 18px rgba(15,23,42,.12); }
.btn-primary:hover { background: #020617; }
.btn-blue { color: #fff; background: var(--primary); }
.btn-blue:hover { background: #1d4ed8; }
.btn-success { color: #fff; background: var(--success); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-outline { color: var(--text); border-color: var(--line); background: #fff; }
.btn-outline:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-soft { color: var(--primary); background: var(--primary-soft); }
.btn-sm { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 11px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 17px; }
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.link-btn { border: 0; padding: 0; color: var(--primary); background: transparent; font-weight: 750; }
.link-btn:hover { text-decoration: underline; }

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 20px 14px; }
.card-head h2, .card-head h3 { margin: 0; letter-spacing: -.02em; }
.card-head h2 { font-size: 16px; }
.card-head h3 { font-size: 14px; }
.card-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.card-body { padding: 0 20px 20px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 30px 0 13px; }
.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.toolbar-filters { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 9px; }
.search-box { position: relative; min-width: 260px; flex: 1 1 280px; }
.search-box input { padding-left: 36px; }
.search-box::before { content: "⌕"; position: absolute; z-index: 1; left: 13px; top: 50%; color: var(--muted-2); transform: translateY(-50%); }
.toolbar-select { min-width: 150px; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 13px; }
.stat-value { display: block; margin-top: 13px; overflow: hidden; text-overflow: ellipsis; font-size: clamp(20px, 2.2vw, 28px); line-height: 1; letter-spacing: -.04em; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.stat-foot strong { color: var(--text); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); gap: 16px; margin-top: 16px; }
.dashboard-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }

.data-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 11px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-2); font-size: 9px; font-weight: 850; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table .actions { display: flex; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.table-primary { max-width: 300px; }
.table-primary strong { display: block; line-height: 1.35; }
.table-primary small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.metric-cell strong { display: block; }
.metric-cell small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

.badge { display: inline-flex; min-height: 24px; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .02em; white-space: nowrap; }
.badge-neutral { color: #475569; background: #f1f5f9; }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-purple { color: var(--purple); background: var(--purple-soft); }
.platform-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 800; }
.platform-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #0f172a; }
.platform-badge.shopee::before { background: #f97316; }
.score-pill { display: inline-grid; place-items: center; min-width: 38px; height: 30px; padding: 0 8px; border-radius: 9px; color: #fff; background: var(--dark); font-size: 12px; font-weight: 850; }
.score-pill.high { background: var(--success); }
.score-pill.medium { background: var(--primary); }
.score-pill.low { color: #475569; background: #e2e8f0; }
.confidence { color: var(--muted); font-size: 9px; }

.rank-list { display: grid; }
.rank-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rank-item:last-child { border-bottom: 0; }
.rank-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: var(--muted); background: var(--surface-3); font-size: 10px; font-weight: 850; }
.rank-item:first-child .rank-number { color: #854d0e; background: #fef3c7; }
.rank-copy { min-width: 0; }
.rank-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.rank-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.decision-list { display: grid; gap: 9px; }
.decision-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.decision-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.decision-item strong { display: block; min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.decision-item p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.chart-toolbar { display: flex; gap: 5px; }
.chart-tab { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--muted); background: #fff; font-size: 9px; font-weight: 800; }
.chart-tab.active { color: #fff; border-color: var(--dark); background: var(--dark); }
.trend-chart { width: 100%; min-height: 235px; padding-top: 8px; }
.trend-chart svg { display: block; width: 100%; height: 230px; overflow: visible; }
.chart-grid-line { stroke: #e2e8f0; stroke-width: 1; }
.chart-axis-label { fill: #94a3b8; font-size: 9px; }
.chart-line { fill: none; stroke: #2563eb; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#chartGradient); }
.chart-dot { fill: #fff; stroke: #2563eb; stroke-width: 2; }
.chart-empty { display: grid; min-height: 220px; place-items: center; color: var(--muted); font-size: 12px; }

.progress { height: 7px; overflow: hidden; border-radius: 999px; background: #e9eef5; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.progress.success > span { background: var(--success); }
.funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.funnel-step { position: relative; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.funnel-step span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.funnel-step strong { display: block; margin-top: 6px; font-size: 18px; letter-spacing: -.03em; }
.funnel-step small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }

.empty-state { display: grid; min-height: 220px; place-items: center; padding: 34px; text-align: center; }
.empty-state.compact { min-height: 140px; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 16px; color: var(--primary); background: var(--primary-soft); font-size: 22px; }
.empty-state h3 { margin: 0; font-size: 15px; }
.empty-state p { max-width: 430px; margin: 8px auto 16px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.pagination p { margin: 0; color: var(--muted); font-size: 10px; }
.pagination-actions { display: flex; gap: 5px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { display: grid; align-content: start; gap: 6px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
.form-group label, .field-label { color: #334155; font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.form-group label .required { color: var(--danger); }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #fff;
  font-size: 12px;
  transition: .15s ease;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
input::placeholder, textarea::placeholder { color: #94a3b8; }
.form-help { color: var(--muted); font-size: 9px; line-height: 1.45; }
.form-section { margin: 8px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.form-section strong { font-size: 12px; }
.form-section p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check-row input { width: 16px; height: 16px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; z-index: 1; left: 11px; top: 50%; color: var(--muted); font-size: 11px; transform: translateY(-50%); }
.input-prefix input { padding-left: 31px; }
.preview-box { padding: 13px; border: 1px dashed #bfdbfe; border-radius: 12px; background: var(--primary-soft); }
.preview-box h4 { margin: 0 0 8px; font-size: 11px; }
.preview-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.preview-metrics div { padding: 9px; border-radius: 9px; background: rgba(255,255,255,.72); }
.preview-metrics span { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; }
.preview-metrics strong { display: block; margin-top: 4px; font-size: 13px; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(15, 23, 42, .58); backdrop-filter: blur(4px); }
.modal {
  width: min(100%, 620px);
  max-height: min(900px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: modalIn .16s ease-out;
}
.modal.wide { width: min(100%, 930px); }
.modal.xwide { width: min(100%, 1120px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.modal-body { max-height: calc(100vh - 190px); overflow-y: auto; padding: 20px 22px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-close { margin: -6px -7px 0 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; }
.detail-stack { display: grid; gap: 14px; }
.detail-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.detail-card h3 { margin: 0 0 9px; font-size: 11px; }
.detail-kv { display: grid; grid-template-columns: 115px 1fr; gap: 7px 12px; font-size: 10px; }
.detail-kv dt { color: var(--muted); }
.detail-kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.recommendation-panel { padding: 16px; border-radius: 14px; background: var(--dark); color: #fff; }
.recommendation-panel p { margin: 8px 0 0; color: #cbd5e1; font-size: 10px; line-height: 1.6; }
.recommendation-panel .action-copy { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); color: #bfdbfe; }
.snapshot-list { display: grid; gap: 8px; }
.snapshot-item { display: grid; grid-template-columns: 145px 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; }
.snapshot-item small { color: var(--muted); }
.snapshot-metrics { display: flex; flex-wrap: wrap; gap: 10px; font-size: 10px; }
.snapshot-metrics strong { margin-right: 3px; }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; }
.settings-nav { display: grid; align-content: start; gap: 5px; padding: 8px; }
.settings-tab { width: 100%; border: 0; border-radius: 9px; padding: 10px 11px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; text-align: left; }
.settings-tab.active { color: var(--text); background: var(--surface-3); }
.settings-panel { min-width: 0; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 20px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 11px; }
.setting-row p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }

/* ---------- Toast/loading ---------- */
.toast-root { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; width: min(360px, calc(100vw - 40px)); gap: 8px; }
.toast { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 14px 40px rgba(15,23,42,.16); animation: toastIn .2s ease; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast strong { display: block; font-size: 11px; }
.toast p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.toast button { border: 0; color: var(--muted); background: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.loading-overlay { position: fixed; inset: 0; z-index: 300; display: grid; place-content: center; gap: 12px; color: #fff; background: rgba(15,23,42,.52); backdrop-filter: blur(2px); font-size: 11px; font-weight: 700; text-align: center; }
.spinner { width: 34px; height: 34px; margin: auto; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
  :root { --sidebar-width: 226px; }
  .global-filters .select-compact:first-child { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 24px; }
  .mobile-brand { display: flex; }
  .sidebar { width: min(82vw, 290px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 50px rgba(15,23,42,.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(15,23,42,.42); }
  .sidebar-backdrop.show { display: block; }
  .main-area { margin-left: 0; }
  .mobile-menu { display: inline-grid !important; }
  .topbar { min-height: 74px; padding: 12px 16px; }
  .topbar p { display: none; }
  .global-filters .select-compact { display: none; }
  .global-filters .btn { min-width: 40px; padding: 10px; }
  .global-filters .btn span + * { display: none; }
  #quick-add-video { font-size: 0; }
  #quick-add-video span { font-size: 18px; }
  .page-content { padding: 18px 14px 36px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-split { grid-template-columns: 1fr; }
  .page-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-filters { width: 100%; }
  .search-box { min-width: 0; width: 100%; flex-basis: 100%; }
  .toolbar-select { min-width: calc(50% - 5px); flex: 1; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-group.span-2, .form-group.span-3 { grid-column: span 1; }
  .modal-root { align-items: end; padding: 0; }
  .modal, .modal.wide, .modal.xwide { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .modal-body { max-height: calc(94vh - 132px); padding: 17px; }
  .modal-head, .modal-foot { padding-left: 17px; padding-right: 17px; }
  .modal-foot { position: sticky; bottom: 0; }
  .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: flex; overflow-x: auto; }
  .settings-tab { width: auto; white-space: nowrap; }
  .setting-row { grid-template-columns: 1fr; gap: 8px; }
  .snapshot-item { grid-template-columns: 1fr auto; }
  .snapshot-metrics { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 21px; }
  .stat-foot { align-items: flex-start; flex-direction: column; gap: 2px; }
  .card-head, .card-body { padding-left: 15px; padding-right: 15px; }
  .card-head { flex-direction: column; }
  .chart-toolbar { width: 100%; overflow-x: auto; }
  .data-table { min-width: 760px; }
  .data-table th, .data-table td { padding: 10px 11px; }
  .auth-card h2 { font-size: 26px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .toast-root { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}
