/* ============================================================
   BITLANSYS Product Tracker — Design System
   Premium, minimal, data-focused SaaS UI.
   ============================================================ */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #fbfbfc;
  --border: #e6e8eb;
  --border-strong: #d9dce1;
  --text: #1a1d21;
  --text-secondary: #5c636b;
  --text-muted: #8a919a;
  --text-faint: #aeb4bb;
  --primary: #2563eb;
  --primary-hover: #1d4fd8;
  --primary-soft: #eef3fe;
  --primary-text: #1d4fd8;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warning: #d97706;
  --warning-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #2563eb;
  --info-soft: #eef3fe;
  --new: #7c3aed;
  --new-soft: #f1ebfd;
  --sidebar-width: 230px;
  --topbar-height: 60px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, 0.16);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #16191f;
  --surface-subtle: #1a1e25;
  --border: #262b33;
  --border-strong: #333a44;
  --text: #e6e9ee;
  --text-secondary: #aab2bd;
  --text-muted: #7d8590;
  --text-faint: #5c646e;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: #1a2744;
  --primary-text: #8ab4ff;
  --success: #22c55e;
  --success-soft: #13291b;
  --warning: #f59e0b;
  --warning-soft: #2a2110;
  --danger: #ef4444;
  --danger-soft: #2c1616;
  --info: #3b82f6;
  --info-soft: #1a2744;
  --new: #a78bfa;
  --new-soft: #241c3d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: rgba(37, 99, 235, 0.14); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #d5d9de; border-radius: 6px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #c2c7cd; border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #2e343d; border-radius: 6px;
  border: 3px solid transparent; background-clip: content-box;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #3a414c; border: 3px solid transparent; background-clip: content-box;
}

/* ============================================================
   Layout shell
   ============================================================ */
.app { min-height: 100vh; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px 12px;
  z-index: 40;
}

/* Brand — constrained so the logo can never balloon */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
}
.brand-logo {
  width: auto;
  height: 26px;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.icon-btn .icon-sun,
.icon-btn .icon-moon {
  width: 18px;
  height: 18px;
  display: block;
}
[data-theme="dark"] .icon-btn .icon-sun { display: none; }
[data-theme="dark"] .icon-btn .icon-moon { display: block; }
.icon-btn .icon-moon { display: none; }
.brand-mark {
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  max-height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4fd8, #2563eb 60%, #4f8dff);
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 32px;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex: 0 0 18px;
  display: block;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.brand-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  font-weight: 500;
  white-space: nowrap;
}

/* Navigation */
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.nav-group {
  margin-bottom: 22px;
}
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px;
  margin: 0 0 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 0 10px;
  margin: 1px 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}

/* Navigation icons — explicit dimensions, never oversized */
.nav-item svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  max-width: 18px;
  max-height: 18px;
  flex: 0 0 18px;
  display: block;
  stroke-width: 1.75;
}
.nav-item.active svg {
  color: var(--primary-text);
}

/* Active indicator bar (subtle) */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}

/* Sidebar footer / status */
.sidebar-foot {
  margin-top: auto;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
}
.status-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
  flex-shrink: 0;
}

/* Main column offset by the fixed sidebar */
.main {
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}


/* ============================================================
   Main column & Top bar
   ============================================================ */
/* .main is defined in the Sidebar section (fixed-sidebar offset). */

.topbar {
  height: var(--topbar-height); flex-shrink: 0; position: sticky; top: 0;
  z-index: 30; background: rgba(247, 248, 250, 0.86);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-7);
}
.topbar-title { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.search-box {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0 var(--space-3); height: 36px;
  width: 300px; color: var(--text-muted);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.search-box svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-box input {
  border: none; outline: none; background: transparent;
  font-size: var(--text-sm); color: var(--text); flex: 1; min-width: 0;
}
.search-box input::placeholder { color: var(--text-faint); }
.kbd {
  font-family: var(--font); font-size: 11px; color: var(--text-muted);
  background: var(--surface-subtle); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
  white-space: nowrap; flex-shrink: 0;
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-md); border: 1px solid transparent;
  background: transparent; color: var(--text-secondary);
  transition: background 0.12s ease, color 0.12s ease; position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 18px; height: 18px; }
.badge-dot {
  position: absolute; top: 8px; right: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--warning);
  box-shadow: 0 0 0 2px var(--bg);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #1f2937, #4b5563); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 650;
  margin-left: var(--space-2); cursor: pointer; border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.menu-btn { display: none; }

/* ============================================================
   Content & views
   ============================================================ */
.content { padding: var(--space-7); max-width: 1280px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-7);
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.page-head .sub { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.page-head .actions { display: flex; gap: var(--space-3); align-items: center; }
.page-head .count { font-size: var(--text-sm); color: var(--text-muted); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 550;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.28); }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-subtle); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 var(--space-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   Panels & links
   ============================================================ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.panel-hd {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.panel-hd h2 { margin: 0; font-size: var(--text-md); font-weight: 650; letter-spacing: -0.01em; }
.panel-hd .muted { font-size: var(--text-sm); color: var(--text-muted); }
.panel-bd { padding: var(--space-5); }
.link {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-sm); color: var(--primary-text); font-weight: 550;
  transition: color 0.12s ease;
}
.link:hover { color: var(--primary-hover); }
.link svg { width: 14px; height: 14px; }


/* ============================================================
   Summary metrics
   ============================================================ */
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: var(--space-6);
}
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-5);
  display: flex; flex-direction: column; justify-content: center;
  min-height: 108px;
}
.metric .num {
  font-size: 30px; font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums;
}
.metric .lbl {
  margin-top: var(--space-2); font-size: 13px; font-weight: 600;
  color: var(--text-secondary); letter-spacing: -0.005em;
}
.metric .sub {
  margin-top: 2px; font-size: 11.5px; color: var(--text-faint); font-weight: 450;
}

/* ============================================================
   Two-column main content (Overview)
   ============================================================ */
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--space-6); margin-bottom: var(--space-6); }

.chart { width: 100%; height: 220px; display: block; }
.chart-legend {
  display: flex; align-items: center; gap: var(--space-5);
  margin-top: var(--space-4); font-size: var(--text-sm); color: var(--text-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.attention { display: flex; flex-direction: column; }
.att-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-3) 0;
}
.att-row + .att-row { border-top: 1px solid var(--border); }
.att-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.att-count { font-size: var(--text-xl); font-weight: 680; letter-spacing: -0.02em; min-width: 34px; }
.att-desc { font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-view {
  display: inline-flex; align-items: center; gap: 2px; font-size: var(--text-sm);
  color: var(--primary-text); font-weight: 550; background: none; border: none;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
  transition: background 0.12s ease; white-space: nowrap;
}
.att-view:hover { background: var(--primary-soft); }
.att-view svg { width: 14px; height: 14px; }
.att-icon { width: 28px; height: 28px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.att-icon svg { width: 15px; height: 15px; }
.att-icon.new { background: var(--new-soft); color: var(--new); }
.att-icon.warn { background: var(--warning-soft); color: var(--warning); }
.att-icon.review { background: var(--info-soft); color: var(--info); }

/* ============================================================
   Recent products table
   ============================================================ */
.recent-table { width: 100%; border-collapse: collapse; }
.recent-table th, .recent-table td {
  text-align: left; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: middle;
}
.recent-table thead th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding-top: var(--space-3); padding-bottom: var(--space-3);
}
.recent-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.recent-table tbody tr:hover { background: var(--surface-subtle); }
.recent-table tbody tr:last-child td { border-bottom: none; }

.p-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.thumb {
  width: 36px; height: 36px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-subtle); display: grid; place-items: center;
  color: var(--text-muted); flex-shrink: 0; overflow: hidden;
}
.thumb svg { width: 18px; height: 18px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.p-name { font-weight: 560; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-name:hover { color: var(--primary-text); }
.p-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { font-weight: 600; color: var(--text); white-space: nowrap; }
.price.na { color: var(--text-faint); }
.time { color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   Status badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-available { color: var(--success); background: var(--success-soft); }
.badge-reviewing { color: var(--warning); background: var(--warning-soft); }
.badge-reserved { color: var(--info); background: var(--info-soft); }
.badge-sold { color: var(--text-muted); background: #eef0f2; }
[data-theme="dark"] .badge-sold { background: var(--surface-subtle); border: 1px solid var(--border); }
.badge-new { color: var(--new); background: var(--new-soft); }
.badge-missing { color: var(--warning); background: var(--warning-soft); }
.badge-unknown { color: var(--text-muted); background: #eef0f2; }
[data-theme="dark"] .badge-unknown { background: var(--surface-subtle); border: 1px solid var(--border); }
.badge-plain { color: var(--text-secondary); background: var(--surface-subtle); border: 1px solid var(--border); }


/* ============================================================
   Products page — toolbar + table
   ============================================================ */
.toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap; margin-bottom: var(--space-4);
}
.toolbar .search-box { width: 260px; }
.filter-select {
  height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface);
  color: var(--text-secondary); font-size: var(--text-sm); outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.sort-wrap { position: relative; margin-left: auto; }
.sort-btn {
  height: 36px; display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500;
}
.sort-btn:hover { color: var(--text); border-color: var(--border-strong); }
.sort-btn svg { width: 15px; height: 15px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th, .data-table td {
  text-align: left; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: middle; white-space: nowrap;
}
.data-table thead th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); background: var(--surface-subtle); border-bottom: 1px solid var(--border);
}
.data-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.data-table tbody tr:hover { background: var(--surface-subtle); }
.data-table tbody tr.selected { background: var(--primary-soft); }
.data-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.data-table tbody tr:last-child td { border-bottom: none; }

.table-empty { padding: var(--space-9) var(--space-5); text-align: center; }
.empty-ico {
  width: 44px; height: 44px; margin: 0 auto var(--space-4);
  border-radius: var(--radius-lg); background: var(--surface-subtle);
  border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-faint);
}
.empty-ico svg { width: 20px; height: 20px; }
.empty-title { font-weight: 600; color: var(--text); }
.empty-desc { color: var(--text-muted); font-size: var(--text-sm); margin: var(--space-2) 0 var(--space-5); max-width: 360px; margin-left: auto; margin-right: auto; }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-4); border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-secondary); padding: 0;
}
.page-btn:hover { background: var(--surface-subtle); color: var(--text); }
.page-btn.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: var(--text-sm); color: var(--text-muted); margin: 0 var(--space-3); }


/* ============================================================
   Incoming pipeline
   ============================================================ */
.pipeline { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-6); }
.pipe-col-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.pipe-col-hd .t {
  display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary);
}
.pipe-col-hd .count { font-size: var(--text-sm); color: var(--text-muted); }
.pipe-arrow { display: grid; place-items: center; color: var(--text-faint); }
.pipe-arrow svg { width: 20px; height: 20px; }
.pipe-list { display: flex; flex-direction: column; gap: var(--space-3); }
.pipe-item {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.pipe-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.pipe-item .thumb { width: 34px; height: 34px; }
.pipe-main { flex: 1; min-width: 0; }
.pipe-name { font-weight: 560; font-size: var(--text-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-state {
  display: inline-flex; align-items: center; gap: var(--space-1); font-size: 11px;
  font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-muted); flex-shrink: 0;
}
.pipe-state .dot { width: 6px; height: 6px; border-radius: 50%; }
.pipe-state.new { color: var(--new); }
.pipe-state.new .dot { background: var(--new); }
.pipe-state.reviewing { color: var(--warning); }
.pipe-state.reviewing .dot { background: var(--warning); }
.pipe-state.ready { color: var(--success); }
.pipe-state.ready .dot { background: var(--success); }

/* ============================================================
   Activity page
   ============================================================ */
.activity-list { display: flex; flex-direction: column; }
.activity-item { display: flex; gap: var(--space-4); padding: var(--space-4) 0; }
.activity-item + .activity-item { border-top: 1px solid var(--border); }
.activity-ico {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-subtle);
  border: 1px solid var(--border); display: grid; place-items: center;
  color: var(--text-secondary); flex-shrink: 0; margin-top: 2px;
}
.activity-ico svg { width: 14px; height: 14px; }
.activity-body .t { font-size: var(--text-sm); font-weight: 560; color: var(--text); }
.activity-body .d { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.activity-body .when { font-size: 12px; color: var(--text-faint); margin-top: var(--space-1); }

/* ============================================================
   Reports / Settings
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); margin-bottom: var(--space-6); }
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-size: var(--text-sm); font-weight: 550; color: var(--text-secondary); margin-bottom: var(--space-2); }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.input {
  width: 100%; height: 38px; padding: 0 var(--space-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface); font-size: var(--text-sm);
  color: var(--text); outline: none; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
textarea.input { height: auto; padding: var(--space-3); resize: vertical; min-height: 80px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) 0; }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row .t { font-weight: 550; color: var(--text); }
.setting-row .d { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: 999px; transition: background 0.15s ease; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }


/* ============================================================
   Drawer
   ============================================================ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15, 18, 22, 0.32); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 100vw;
  background: var(--surface); z-index: 61; transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.drawer.open { transform: translateX(0); }
.drawer-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-hd .t { font-size: var(--text-md); font-weight: 650; }
.drawer-bd { flex: 1; overflow-y: auto; padding: var(--space-5); }
.drawer-ft {
  display: flex; gap: var(--space-3); padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.drawer-ft .grow { flex: 1; }

.detail-hero { display: flex; gap: var(--space-4); padding-bottom: var(--space-5); border-bottom: 1px solid var(--border); }
.detail-hero .thumb { width: 64px; height: 64px; border-radius: var(--radius-lg); }
.detail-hero .thumb svg { width: 28px; height: 28px; }
.detail-hero .nm { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
.detail-hero .sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.detail-hero .badges { margin-top: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.price-hero { margin-top: var(--space-4); font-size: var(--text-md); font-weight: 600; }

.detail-section { padding: var(--space-5) 0; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.detail-section .sec-t {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); margin-bottom: var(--space-3);
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-3) var(--space-4); font-size: var(--text-sm); padding: var(--space-2) 0; }
.kv .k { color: var(--text-muted); }
.kv .v { color: var(--text); font-weight: 500; }
.kv .v.na { color: var(--text-faint); font-weight: 400; }

/* ============================================================
   Modal (Add product)
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 18, 22, 0.32); z-index: 70;
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-8) var(--space-4); opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease; overflow-y: auto;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 680px; max-width: 100%;
  box-shadow: var(--shadow-lg); transform: translateY(8px);
  transition: transform 0.18s ease; overflow: hidden;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); }
.modal-hd .t { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.modal-hd .sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.modal-bd { padding: var(--space-6); max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-ft { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); background: var(--surface-subtle); }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-4); }
.form-full { grid-column: 1 / -1; }
.field-err {
  display: none; margin-top: 6px; font-size: 12px; line-height: 1.45;
  color: var(--danger); background: var(--danger-soft);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.field-err.show { display: block; }
.form-section { margin-bottom: var(--space-6); }
.form-section .sec-t {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: var(--space-4); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border);
}

/* View button */
.btn-view {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  color: var(--primary-text); background: var(--primary-soft);
  border: 1px solid transparent; transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn-view:hover { border-color: var(--primary); }

/* Media viewer */
.media-overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 13, 0.72); z-index: 85;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5); opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.media-overlay.open { opacity: 1; pointer-events: auto; }
.media-modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 720px; max-width: 100%;
  box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column;
  max-height: 92vh; transform: translateY(8px); transition: transform 0.18s ease;
}
.media-overlay.open .media-modal { transform: translateY(0); }
.media-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.media-hd .t { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.media-hd .sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.media-bd {
  flex: 1; min-height: 0; display: grid; place-items: center;
  background: #0a0c10; padding: var(--space-4); overflow: hidden;
}
.media-bd img, .media-bd video {
  max-width: 100%; max-height: calc(92vh - 140px); border-radius: var(--radius-md);
  object-fit: contain;
}
.media-bd video { width: 100%; background: #000; }
.media-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-8) 0;
  text-align: center;
}
.media-empty svg { width: 40px; height: 40px; opacity: 0.5; }
.media-nav {
  display: flex; justify-content: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border);
}
.media-nav-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-subtle); color: var(--text-secondary); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.media-nav-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.media-nav-btn svg { width: 18px; height: 18px; }

/* toast */
.toast {
  position: fixed; bottom: var(--space-6); left: 50%;
  transform: translateX(-50%) translateY(16px); background: var(--text); color: #fff;
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-md);
  font-size: var(--text-sm); box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 90;
  display: flex; align-items: center; gap: var(--space-2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; }

/* auth loading screen — shown while the session is checked */
.auth-loading {
  position: fixed; inset: 0; z-index: 200;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); background: var(--bg);
}
.auth-loading.show { display: flex; }
.auth-loading-mark { animation: authPulse 1.1s ease-in-out infinite; }
.auth-loading-text { font-size: var(--text-sm); color: var(--text-muted); }
@keyframes authPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.96); }
}


/* ============================================================
   Command palette
   ============================================================ */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(15, 18, 22, 0.32); z-index: 80;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.cmd-overlay.open { opacity: 1; pointer-events: auto; }
.cmd { width: 520px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.cmd-input { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.cmd-input svg { width: 18px; height: 18px; color: var(--text-muted); }
.cmd-input input { border: none; outline: none; flex: 1; font-size: var(--text-md); background: transparent; color: var(--text); }
.cmd-list { max-height: 360px; overflow-y: auto; padding: var(--space-2); }
.cmd-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3); border-radius: var(--radius-md); cursor: pointer; font-size: var(--text-sm); color: var(--text-secondary); }
.cmd-item:hover, .cmd-item.hl { background: var(--primary-soft); color: var(--primary-text); }
.cmd-item svg { width: 16px; height: 16px; }
.cmd-empty { padding: var(--space-6); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }

/* ============================================================
   Search results dropdown
   ============================================================ */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; display: none; z-index: 50;
}
.search-results.show { display: block; }
.sr-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); cursor: pointer; font-size: var(--text-sm); }
.sr-item:hover { background: var(--primary-soft); }
.sr-item .thumb { width: 30px; height: 30px; }
.sr-item .nm { font-weight: 550; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-item .meta { font-size: 12px; color: var(--text-muted); }
.sr-empty { padding: var(--space-4); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }

/* ============================================================
   Login
   ============================================================ */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); background: var(--bg); }
.login-card {
  width: 380px; max-width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-7) var(--space-6); box-shadow: var(--shadow-md);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-6); }
.login-brand .brand-mark { width: 44px; height: 44px; min-width: 44px; max-width: 44px; margin-bottom: var(--space-1); }
.login-brand .brand-mark img { border-radius: 10px; }
.theme-toggle-float {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.theme-toggle-float:hover { color: var(--text); border-color: var(--border-strong); }
.login-title { font-size: var(--text-xl); font-weight: 680; letter-spacing: -0.02em; margin: 0; }
.login-sub { color: var(--text-muted); font-size: var(--text-sm); margin: var(--space-1) 0 0; }
.login-form .field { margin-bottom: var(--space-4); }
.login-submit { width: 100%; margin-top: var(--space-2); }
.login-error { background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); display: none; }
.login-error.show { display: block; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  .main { margin-left: 0; width: 100%; }
  .topbar { padding: 0 var(--space-4); gap: var(--space-3); }
  .content { padding: var(--space-5) var(--space-4); }
  .topbar-search { display: none; }
  .topbar-actions { margin-left: auto; }
  .topbar-title { display: none; }
  .pipeline { grid-template-columns: 1fr; }
  .pipe-arrow { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 96px; padding: var(--space-4); }
  .form-2col { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .content { padding: var(--space-4) var(--space-3); }
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .toolbar .search-box { width: 100%; }
  .sort-wrap { margin-left: 0; }
}

