/* ═══════════════════════════════════════════════════════════════
   PLOTZY—OPS v6.0 — Design System
   Dark ops console · Shopee-orange accent · Plus Jakarta Sans /
   JetBrains Mono · Hairline surfaces, precision type, no decoration
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces — near-black, layered */
  --bg: #0A0B0E;
  --bg-canvas: #0A0B0E;
  --bg-surface: #101216;
  --bg-panel: #101216;
  --bg-raised: #14161B;
  --bg-hover: #17191F;
  --bg-subtle: #121419;
  --bg-input: #0C0D10;
  --bg-sidebar: #0C0D10;

  /* Hairlines */
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);
  --border-faint: rgba(255,255,255,0.045);

  /* Accent — Shopee orange, committed & sparing */
  --accent: #EE4D2D;
  --accent-hover: #F65A3B;
  --accent-press: #D63F21;
  --accent-subtle: rgba(238,77,45,0.11);
  --border-focus: #EE4D2D;

  /* --primary aliases kept: app.js inline styles reference var(--primary) */
  --primary: #EE4D2D;
  --primary-hover: #D63F21;
  --primary-subtle: rgba(238,77,45,0.11);

  /* Semantics — profit / boncos */
  --success: #2FBF71;
  --emerald: #2FBF71; /* legacy alias referenced by API badge colors */
  --success-subtle: rgba(47,191,113,0.11);
  --success-border: rgba(47,191,113,0.28);
  --warning: #E8A33D;
  --warning-subtle: rgba(232,163,61,0.11);
  --danger: #F04438;
  --danger-subtle: rgba(240,68,56,0.11);

  /* Type */
  --text: #F4F4F5;
  --text-secondary: #A7AAB3;
  --text-muted: #6E727C;
  --text-light: #484C54;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-size-base: 14px;
  --font-size-sm: 13px;
  --font-size-xs: 12px;

  --sidebar-w: 232px;
  --header-h: 57px;
  --radius: 10px;
  --radius-sm: 7px;

  --ease: cubic-bezier(0.25, 0.6, 0.3, 1);
  --ring: 0 0 0 1px var(--bg), 0 0 0 3px rgba(238,77,45,0.55);
}

::selection { background: rgba(238,77,45,0.32); color: #fff; }

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--font-size-base);
  line-height: 1.5; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #23252C; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #30323A; }
* { scrollbar-width: thin; scrollbar-color: #23252C transparent; }

/* ─── App Layout ────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; }
.app-layout.sidebar-open .sidebar { transform: translateX(0); }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
}
.sidebar-header {
  height: var(--header-h); padding: 0 18px; flex-shrink: 0;
  display: flex; align-items: center; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.brand-mark {
  width: 9px; height: 9px; border-radius: 2px; background: var(--accent);
  align-self: center; flex-shrink: 0;
}
.brand-name {
  font-size: 15.5px; font-weight: 800; color: var(--text);
  letter-spacing: 0.055em; line-height: 1; white-space: nowrap;
}
.brand-name .brand-accent { color: var(--accent); }
.brand-sub {
  font-size: 9px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.18em; text-transform: uppercase; white-space: nowrap;
  margin-top: 4px;
}

.nav-eyebrow {
  padding: 16px 18px 7px; font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-light);
}
.sidebar-nav { flex: 1; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7.5px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-subtle); color: var(--text); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 2px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-icon { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.7; fill: none; flex-shrink: 0; }
.nav-item.active .nav-icon { stroke: var(--accent); }
.nav-label { white-space: nowrap; }

.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  background: var(--accent-subtle); color: var(--accent);
  border: 1px solid rgba(238,77,45,0.25);
  font-weight: 700; font-size: 12px; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .btn { padding: 5px 7px; }
.user-sub { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Main Content ──────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--bg); min-width: 0; }
.top-bar {
  height: var(--header-h); padding: 0 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.top-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; white-space: nowrap; }
.top-bar-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.content-area { flex: 1; padding: 26px 30px 40px; overflow-y: auto; overflow-x: hidden; }
.view-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.view-title { font-size: 21px; font-weight: 800; color: var(--text); letter-spacing: -0.022em; line-height: 1.15; margin-bottom: 5px; }
.view-subtitle { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.01em; }
.view-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7.5px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.005em;
  transition: background 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
  white-space: nowrap; border: 1px solid transparent;
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--bg-raised); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.btn-success { background: var(--success); color: #07130C; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 5.5px 10.5px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-field { margin-bottom: 13px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.02em; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 11px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.form-select {
  appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236E727C' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238,77,45,0.18);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-light); }
.form-input-sm { padding: 6px 10px; font-size: 12px; }
.form-select-sm { padding: 5.5px 26px 5.5px 9px; font-size: 12px; }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.required { color: var(--danger); }
input[type="number"] { font-family: var(--font-mono); font-size: 12.5px; }
input[type="radio"] { accent-color: var(--accent); }
.radio-group { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--text-secondary); }
.radio-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.csv-meta { display: flex; gap: 20px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); }
.mapping-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ─── Alerts / status bar ───────────────────────────────────── */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 15px; border-radius: var(--radius); margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--bg-surface);
  border-left: 2px solid var(--accent);
}
.alert-info { color: var(--text); }
.alert-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); margin-top: 1px; }
.alert-content { flex: 1; font-size: 13px; color: var(--text-secondary); }
.alert-content > span:first-child { color: var(--text); font-weight: 500; }
.alert-sub { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); }
.alert a { color: var(--accent); font-weight: 600; text-decoration: none; border-bottom: 1px solid rgba(238,77,45,0.4); }
.alert a:hover { border-bottom-color: var(--accent); }

/* ─── KPI Strip — one continuous hairline-divided band ─────── */
.kpi-grid {
  display: grid; grid-template-columns: 1.28fr 1.08fr 0.95fr 0.85fr 1.12fr; gap: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 14px;
}
.kpi-card {
  padding: 17px 19px 15px; background: transparent;
  border-right: 1px solid var(--border-faint);
  transition: background 0.14s var(--ease); min-width: 0;
}
.kpi-card:last-child { border-right: none; }
.kpi-card:hover { background: rgba(255,255,255,0.016); }
.kpi-card.kpi-featured {
  background: rgba(238,77,45,0.045);
  box-shadow: inset 0 0 0 1px rgba(238,77,45,0.22);
}
.kpi-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.kpi-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.kpi-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--bg-hover); color: var(--text-secondary);
  font-weight: 600; font-family: var(--font-mono); white-space: nowrap;
}
.kpi-value {
  font-size: 25px; font-weight: 600; color: var(--text);
  font-family: var(--font-mono); letter-spacing: -0.02em; line-height: 1.05;
  margin-bottom: 5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kpi-positive { color: var(--success); }
.kpi-subtext { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Secondary metric strip ────────────────────────────────── */
.secondary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.metric-card { padding: 14px 19px; border-right: 1px solid var(--border-faint); min-width: 0; }
.metric-card:last-child { border-right: none; }
.metric-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.13em; margin-bottom: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.metric-value {
  font-size: 17px; font-weight: 600; color: var(--text);
  font-family: var(--font-mono); letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.metric-subtext { font-size: 11px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Panels ────────────────────────────────────────────────── */
.panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; flex-wrap: wrap; gap: 12px; }
.panel-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.012em; margin-bottom: 3px; }
.panel-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; max-width: 640px; }
.panel-desc code { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-secondary); }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.012em; }
.section-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.panel .table-wrapper { scrollbar-width: thin; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  padding: 8px 12px; text-align: left; white-space: nowrap;
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.11em;
  border-bottom: 1px solid var(--border-strong); background: var(--bg-surface);
  position: sticky; top: 0; z-index: 2;
}
.data-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border-faint);
  color: var(--text-secondary); font-variant-numeric: tabular-nums; vertical-align: middle;
}
.data-table td:first-child { color: var(--text); }
.data-table tbody tr { transition: background 0.12s var(--ease); }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.022); }
.data-table tr:last-child td { border-bottom: none; }
.action-col, .eval-col { text-align: left; }
.empty-state { text-align: center; padding: 38px 20px; color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }
.empty-state .spinner { display: inline-block; }

/* ─── Tabs ──────────────────────────────────────────────────── */
.tab-nav { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-btn { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.14s var(--ease), border-color 0.14s var(--ease); }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panels { display: flex; flex-direction: column; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Segmented controls: date pills & import tabs ─────────── */
.date-pills {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 9px;
}
.date-pill {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  color: var(--text-muted); transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.date-pill:hover { color: var(--text); }
.date-pill.active { background: var(--bg-hover); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border-strong); }

.import-tabs { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; margin-bottom: 16px; }
.import-tab-btn { padding: 6px 13px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-muted); transition: background 0.14s var(--ease), color 0.14s var(--ease); }
.import-tab-btn:hover { color: var(--text); }
.import-tab-btn.active { background: var(--bg-hover); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border-strong); }
.import-panel { display: none; }
.import-panel.active { display: block; }

/* ─── PPN switch ────────────────────────────────────────────── */
.ppn-pill { display: inline-flex; align-items: center; }
.ppn-btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 7px; border-radius: 9px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  border: 1px solid var(--border); background: var(--bg-surface);
  transition: color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.ppn-btn:hover { color: var(--text); }
.ppn-btn.active { color: var(--text); border-color: var(--border-strong); }
.ppn-dot {
  width: 27px; height: 16px; border-radius: 999px; flex-shrink: 0;
  background: #26282F; position: relative;
  transition: background 0.16s var(--ease);
}
.ppn-dot::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: #83878F;
  transition: left 0.16s var(--ease), background 0.16s var(--ease);
}
.ppn-btn.active .ppn-dot { background: rgba(238,77,45,0.38); }
.ppn-btn.active .ppn-dot::after { left: 13px; background: var(--accent); }

/* legacy checkbox switch (kept for compatibility) */
.ppn-toggle { display: inline-flex; align-items: center; gap: 8px; }
.ppn-toggle input { display: none; }
.ppn-toggle-track { width: 36px; height: 20px; background: var(--bg-hover); border-radius: 10px; position: relative; cursor: pointer; border: 1px solid var(--border); }
.ppn-toggle-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); position: absolute; top: 1px; left: 1px; transition: all 0.2s var(--ease); }
.ppn-toggle input:checked + .ppn-toggle-track .ppn-toggle-thumb { left: 17px; background: var(--accent); }
.ppn-toggle input:checked + .ppn-toggle-track { background: var(--accent-subtle); border-color: var(--accent); }
.ppn-toggle-label { font-size: 12px; color: var(--text-secondary); }

/* ─── Import layout ─────────────────────────────────────────── */
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.import-history { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-faint); }

/* ─── Dropzone ──────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed rgba(255,255,255,0.15); border-radius: var(--radius);
  padding: 30px 24px; text-align: center; cursor: pointer;
  background: var(--bg-input);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.dropzone:hover, .dropzone:focus-visible { border-color: rgba(238,77,45,0.55); background: rgba(238,77,45,0.04); }
.dropzone-icon { width: 30px; height: 30px; stroke: var(--text-light); margin: 0 auto 11px; }
.dropzone:hover .dropzone-icon { stroke: var(--accent); }
.dropzone-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.dropzone-desc { font-size: 11.5px; color: var(--text-muted); }
.upload-status { margin-top: 12px; font-size: 12.5px; line-height: 1.55; }

/* ─── Tags & batches ────────────────────────────────────────── */
.tags-list { max-height: 420px; overflow-y: auto; }
.tag-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm); margin-bottom: 7px; background: var(--bg-raised);
  transition: border-color 0.14s var(--ease);
}
.tag-item:hover { border-color: var(--border); }
.tag-name { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--text); }
.tag-url { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; margin-top: 1px; }
.tag-url a { color: var(--accent); text-decoration: none; }
.tag-url a:hover { text-decoration: underline; }
.inline-form { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.inline-form.hidden { display: none; }

.batch-list { max-height: 220px; overflow-y: auto; }
.batch-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--bg-raised);
}
.batch-info { flex: 1; min-width: 0; }
.batch-name { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 1px; }
.batch-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ─── Recommendations ───────────────────────────────────────── */
.rec-filters { margin-bottom: 18px; }
.rec-filters > .search-wrapper { position: relative; margin-bottom: 12px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--text-light); pointer-events: none; }
.search-wrapper .form-input { padding-left: 36px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  padding: 5.5px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); color: var(--text-secondary); background: transparent;
  transition: border-color 0.14s var(--ease), color 0.14s var(--ease), background 0.14s var(--ease);
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.active { background: var(--accent-subtle); border-color: rgba(238,77,45,0.45); color: var(--accent); font-weight: 600; }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.rec-stats { margin-bottom: 12px; font-size: 12.5px; color: var(--text-muted); font-family: var(--font-mono); }

/* product cards (rendered by app.js reusing .kpi-card) */
.products-grid .kpi-card {
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-raised);
  transition: border-color 0.16s var(--ease), transform 0.16s var(--ease);
}
.products-grid .kpi-card:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--bg-raised); }

/* ─── Fanpage video cards ───────────────────────────────────── */
.insights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.insight-card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  transition: border-color 0.16s var(--ease);
}
.insight-card:hover { border-color: var(--border-strong); }
.insight-card img { display: block; width: 100%; border-radius: 8px; background: var(--bg-hover); }
.insight-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.insight-title { font-size: 13px; font-weight: 700; color: var(--text); }
.insight-badge { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 700; letter-spacing: 0.05em; }
.insight-body { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }

/* ─── Chart / trend bars ────────────────────────────────────── */
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.chart-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.012em; }
.chart-controls { display: flex; gap: 8px; align-items: center; }
.chart-wrapper { position: relative; }
.chart-legend { display: flex; gap: 20px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.legend-dot.spend-dot { background: var(--accent); }
.legend-dot.commission-dot { background: var(--success); }

.trend-chart { display: flex; flex-direction: column; gap: 12px; }
.trend-legend-row { display: flex; gap: 20px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--border-faint); font-size: 11.5px; color: var(--text-muted); }
.trend-rows { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.trend-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 12px; align-items: center; }
.trend-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-bars { display: flex; flex-direction: column; gap: 3px; }
.trend-bar { height: 8px; border-radius: 2px; min-width: 2px; transition: width 0.3s var(--ease); }
.trend-bar.spend-bar { background: var(--accent); }
.trend-bar.comm-bar { background: var(--success); }
.trend-value { font-size: 12px; font-weight: 600; text-align: right; color: var(--text); font-family: var(--font-mono); }

/* ─── Badges — square chips with dot ────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5.5px;
  padding: 2.5px 7.5px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.055em; text-transform: uppercase;
  background: var(--bg-hover); color: var(--text-secondary); white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-success, .badge-active { background: var(--success-subtle); color: var(--success); }
.badge-warning, .badge-paused { background: var(--warning-subtle); color: var(--warning); }
.badge-danger, .badge-boncos { background: var(--danger-subtle); color: var(--danger); }

/* ─── Auth Overlay ──────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0; background: #07080A;
  display: flex; align-items: center; justify-content: center; z-index: 999; padding: 20px;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 36px 34px 30px; width: 372px; max-width: 92vw;
  text-align: center; box-shadow: 0 28px 70px rgba(0,0,0,0.55);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent);
}
.auth-icon {
  width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 10px;
  background: var(--accent-subtle); border: 1px solid rgba(238,77,45,0.25);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
}
.auth-icon svg { width: 21px; height: 21px; }
.auth-card h2 { font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.015em; margin-bottom: 6px; }
.auth-desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.55; }
.auth-card .form-input { text-align: center; font-family: var(--font-mono); letter-spacing: 0.22em; font-size: 15px; padding: 11px; }
.auth-error { font-size: 12.5px; color: var(--danger); margin-top: 13px; }

/* ─── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,5,7,0.72);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 22px;
}
.modal-card {
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: 12px; width: 100%; max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; box-shadow: 0 28px 70px rgba(0,0,0,0.55);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.modal-body { padding: 20px; flex: 1; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-card .table-wrapper { margin: 0; padding: 0; }

/* ─── Toasts ────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, 90vw); }
.toast {
  padding: 11px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  color: var(--text); background: #14161B;
  border: 1px solid var(--border-strong); border-left: 3px solid var(--text-muted);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); animation: slideIn 0.18s var(--ease);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Settings ──────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.setting-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.setting-title { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin-bottom: 6px; }
.setting-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 13px; line-height: 1.55; }
.setting-card .form-field:last-of-type { margin-bottom: 14px; }
.setting-card code.mono { word-break: break-all; }

/* ─── Loading ───────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12); border-top-color: var(--accent);
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  border-radius: 6px;
  background: linear-gradient(100deg, var(--bg-raised) 40%, var(--bg-hover) 50%, var(--bg-raised) 60%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -20% 0; } }

/* ─── Utilities ─────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--accent) !important; }
.text-muted { color: var(--text-muted) !important; }
.mobile-menu-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-card { border-bottom: 1px solid var(--border-faint); }
  .secondary-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { border-bottom: 1px solid var(--border-faint); }
}
@media (max-width: 1024px) {
  .import-grid { grid-template-columns: 1fr; }
}
/* Icon rail */
@media (max-width: 1100px) and (min-width: 861px) {
  :root { --sidebar-w: 62px; }
  .sidebar-header { padding: 0; justify-content: center; }
  .brand-info, .nav-label, .nav-eyebrow, .user-info { display: none; }
  .sidebar-nav { padding: 14px 9px; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-item.active::before { left: -9px; }
  .sidebar-footer { padding: 12px 0; }
  .user-card { justify-content: center; }
  .user-card .btn { display: none; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 248px; min-width: 248px;
    transform: translateX(-102%); transition: transform 0.24s var(--ease); z-index: 300;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 70px rgba(0,0,0,0.65); }
  .mobile-menu-btn { display: inline-flex !important; }
  .content-area { padding: 18px 14px 32px; }
  .top-bar { padding: 0 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .secondary-grid { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px 14px; }
  .table-wrapper { margin: 0 -14px; padding: 0 14px; }
  .top-bar-right .btn span { display: none; }
  .top-bar-right .btn { padding: 6px 9px; }
  .view-title { font-size: 18px; }
  .view-controls { width: 100%; }
  .date-pills { flex-wrap: wrap; }
  .trend-row { grid-template-columns: 92px 1fr 48px; gap: 8px; }
  .tag-url { max-width: 150px; }
  .auth-card { padding: 28px 20px 24px; }
  .modal-overlay { padding: 10px; }
  .products-grid { grid-template-columns: 1fr !important; }
  .mapping-grid { grid-template-columns: 1fr; }
  /* sticky first column while tables scroll horizontally */
  .data-table th:first-child, .data-table td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--bg-surface);
    box-shadow: 1px 0 0 var(--border-faint);
  }
  .data-table th:first-child { z-index: 3; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { border-right: none; }
  .secondary-grid { grid-template-columns: 1fr 1fr; }
  .insights-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   Recommendations v2 — Plotzy Score rows (calm, dense, no cards)
   ═══════════════════════════════════════════════════════════════ */
.rec-list { display: flex; flex-direction: column; }
.rec-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); margin: 20px 0 8px;
}
.rec-section-label:first-child { margin-top: 4px; }
.rec-row {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-surface); margin-bottom: 8px; overflow: hidden;
}
.rec-row-featured { border-color: rgba(238,77,45,0.38); background: var(--bg-raised); }
.rec-row-main {
  display: flex; align-items: center; gap: 14px; width: 100%;
  text-align: left; padding: 13px 16px; color: inherit;
  transition: background 0.14s var(--ease);
}
.rec-row-main:hover { background: var(--bg-hover); }
.rec-rank { font-size: 19px; font-weight: 700; color: var(--text-muted); min-width: 30px; line-height: 1; }
.rec-row-featured .rec-rank { color: var(--accent); }
.rec-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rec-title { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-meta { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 74px; flex-shrink: 0; }
.rec-score-num { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1; }
.rec-bar { width: 74px; height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; display: block; }
.rec-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.rec-chevron { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.16s var(--ease); }
.rec-row.open .rec-chevron { transform: rotate(180deg); }
.rec-detail { border-top: 1px solid var(--border-faint); padding: 14px 16px 16px; background: var(--bg-subtle); }
.rec-detail-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
.rec-detail-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.rec-hook { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 14px; }
.rec-angles { display: flex; flex-wrap: wrap; gap: 5px; }
.rec-angle-chip { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.rec-breakdown-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-bottom: 5px; }
.rec-breakdown-row .lbl { width: 112px; color: var(--text-muted); flex-shrink: 0; }
.rec-breakdown-row .val { font-family: var(--font-mono); color: var(--text-secondary); width: 46px; text-align: right; flex-shrink: 0; }
.rec-mini-bar { flex: 1; height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; display: block; }
.rec-mini-bar > span { display: block; height: 100%; background: var(--text-muted); }
.rec-evidence { font-size: 11.5px; color: var(--text-muted); line-height: 1.55; margin: 10px 0; }
.rec-subid { font-size: 11.5px; color: var(--text-muted); margin-bottom: 10px; }
.rec-subid code { color: var(--accent); font-family: var(--font-mono); }
.rec-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 700px) {
  .rec-detail-grid { grid-template-columns: 1fr; }
  .rec-score { min-width: 56px; }
  .rec-bar { width: 56px; }
  .rec-rank { font-size: 16px; min-width: 24px; }
  .rec-row-main { gap: 10px; padding: 12px; }
  .rec-title, .rec-meta { white-space: normal; }
}

/* ─── TikTok Downloader ─────────────────────────────────────── */
.dl-options { display: flex; flex-wrap: wrap; gap: 22px; margin: 14px 0 2px; }
.dl-results { margin-top: 18px; }
.dl-summary { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 10px; }
.dl-result-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--bg-subtle); font-size: 12.5px; }
.dl-status { font-weight: 800; width: 16px; text-align: center; flex-shrink: 0; }
.dl-status.ok { color: var(--success); }
.dl-status.fail { color: var(--danger); }
.dl-filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-error { color: var(--danger); font-size: 11.5px; }
