:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e4e6ec;
  --border-strong: #cfd3dc;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #3730a3;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #a16207;
  --warn-soft: #fefce8;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --side-bg: #1e1b4b;
  --side-text: #c7d2fe;
  --side-active: #312e81;
  --meesho: #d14b8f;
  --flipkart: #2a78d6;
  --amazon: #eb8a12;
  --grid: #eceef2;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 20px 40px rgba(16, 24, 40, 0.18);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #1a1b1e;
    --surface-2: #212226;
    --border: #2e3036;
    --border-strong: #3d4048;
    --text: #f0f1f3;
    --text-2: #c4c7ce;
    --muted: #9599a3;
    --primary: #6d68f0;
    --primary-hover: #8580f5;
    --primary-soft: #26254a;
    --primary-text: #c7c5ff;
    --ok: #34d399;
    --ok-soft: #10261d;
    --warn: #facc15;
    --warn-soft: #2a2410;
    --bad: #f87171;
    --bad-soft: #2d1515;
    --info: #60a5fa;
    --info-soft: #14213a;
    --side-bg: #15142e;
    --side-text: #b4b8e8;
    --side-active: #2a2865;
    --meesho: #e0609f;
    --flipkart: #3987e5;
    --amazon: #c47812;
    --grid: #26282d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #1a1b1e; --surface-2: #212226; --border: #2e3036; --border-strong: #3d4048;
  --text: #f0f1f3; --text-2: #c4c7ce; --muted: #9599a3; --primary: #6d68f0; --primary-hover: #8580f5;
  --primary-soft: #26254a; --primary-text: #c7c5ff; --ok: #34d399; --ok-soft: #10261d; --warn: #facc15;
  --warn-soft: #2a2410; --bad: #f87171; --bad-soft: #2d1515; --info: #60a5fa; --info-soft: #14213a;
  --side-bg: #15142e; --side-text: #b4b8e8; --side-active: #2a2865; --meesho: #e0609f; --flipkart: #3987e5;
  --amazon: #c47812; --grid: #26282d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Malayalam", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 6px; font-size: 12.5px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 16px 12px; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: #fff; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 11px; color: var(--side-text); text-transform: uppercase; letter-spacing: .06em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 10px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-group { display: flex; align-items: center; gap: 10px; padding: 9px 10px 3px; color: var(--side-text); font-weight: 500; }
.nav-group svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a.sub { padding: 7px 10px 7px 38px; font-size: 13.5px; }
.nav .count { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.userbox { border-top: 1px solid rgba(255,255,255,.1); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.userbox .who { flex: 1; min-width: 0; }
.userbox .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox .who span { font-size: 11px; text-transform: capitalize; }
.userbox button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 6px; border-radius: 6px; }
.userbox button:hover { background: rgba(255,255,255,.08); color: #fff; }
.userbox button svg { width: 18px; height: 18px; display: block; }
.logout-wide { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 8px 0; padding: 9px 12px; width: calc(100% - 16px); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.logout-wide:hover { background: rgba(255,255,255,.16); }
.logout-wide svg { width: 18px; height: 18px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }
.topbar { display: none; }
.page { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  body.nav-open .scrim { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: var(--text); padding: 6px; cursor: pointer; }
  .page { padding: 16px 16px 40px; }
}

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid > *, .stack > *, .main, .page, .card { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.bad .value { color: var(--bad); } .kpi.warn .value { color: var(--warn); } .kpi.ok .value { color: var(--ok); }

/* dashboard: sales, best sellers, one-click sync */
.sales-card { margin-bottom: 16px; }
.sales-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sales-cell { padding: 14px 18px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--border); }
.sales-cell:last-child { border-right: 0; }
.sales-cell .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.sales-cell .value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.sales-cell .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.sales-cell .sub { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sales-cell .sub.lost { color: var(--warn); }
.sales-cell .sub:last-child { color: var(--muted); font-size: 12px; }
.sales-cell .sub.lost:last-child { color: var(--warn); }
.est { margin-left: 2px; color: var(--muted); cursor: help; }
.tone-bad { color: var(--bad); } .tone-warn { color: var(--warn); }
.top-table td.rank { width: 36px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-table tbody tr:nth-child(-n+3) td.rank { color: var(--primary); }
.top-table .ptag { margin-right: 6px; font-variant-numeric: tabular-nums; }
.sync-box { margin-bottom: 16px; border-color: var(--primary); }
.sync-box.all-ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.sync-box.has-error { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.sync-box .card-pad span { color: var(--text-2); }
.sync-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; padding: 14px 18px; }
.sync-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.sync-step .dot { margin-top: 5px; }
.sync-step .mark { font-weight: 700; color: var(--muted); }
.sync-step.done { background: var(--ok-soft); border-color: transparent; } .sync-step.done .mark { color: var(--ok); }
.sync-step.error { background: var(--bad-soft); border-color: transparent; } .sync-step.error .mark, .sync-step.error .cell-sub { color: var(--bad); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
@media (max-width: 700px) {
  .sales-grid { grid-template-columns: 1fr; }
  .sales-cell { border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 14px; }
  .sales-cell:last-child { border-bottom: 0; }
  .sales-cell .value { font-size: 20px; }
  .sync-steps { padding: 12px 14px; }
}

.plat-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.plat-card .top { display: flex; align-items: center; gap: 8px; }
.plat-card .top h3 { flex: 1; font-size: 15px; }
.plat-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plat-stats div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.plat-stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.plat-stats span { font-size: 11.5px; color: var(--muted); }

/* ---------- Dashboard (wc-19): sync boxes, sale tiles, profit table, best sellers, out of stock, orders to ship ---------- */
.tone-ok { color: var(--ok); } .tone-info { color: var(--info); }
.dash-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 2px 10px; }
.dash-section-head h2 { font-size: 16px; }
.dash-section-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.dash-card { margin-bottom: 16px; }
.sync-cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 20px; }
.sync-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; border-top: 3px solid var(--border); }
.sync-card.ok { border-top-color: var(--ok); } .sync-card.warn { border-top-color: var(--warn); } .sync-card.bad { border-top-color: var(--bad); }
.sync-card .top { display: flex; align-items: center; gap: 8px; }
.sync-card .top h3 { flex: 1; font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.sync-card .top a.badge:hover { text-decoration: none; filter: brightness(.97); }
.sync-card .sync-btn { width: 100%; justify-content: center; }
.sync-last { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.sync-last .muted { font-size: 12px; }
.sdot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.sdot.ok, .sk.ok i { background: var(--ok); } .sdot.warn, .sk.warn i { background: var(--warn); } .sdot.bad, .sk.bad i { background: var(--bad); }
.sync-kinds { display: flex; flex-wrap: wrap; gap: 5px; }
.sk { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.sk b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.sk i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.sale-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.sale-tile { padding: 14px 18px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.sale-tile.total { background: var(--primary-soft); }
.sale-tile .label { color: var(--muted); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.sale-tile.total .label { color: var(--primary-text); }
.sale-tile .value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.sale-tile .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.sale-tile .sub { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sale-tile .sub.lost { color: var(--warn); }
.sale-tile .sub.quiet { color: var(--muted); font-size: 12px; }
.profit-wrap { display: flex; flex-wrap: wrap; align-items: flex-start; }
.profit-wrap > .table-wrap { flex: 1 1 560px; min-width: 0; order: -1; } /* wide: table left, summary right; phone: summary on top */
.profit-sum { flex: 0 1 300px; display: grid; gap: 10px; padding: 14px 18px; margin-left: auto; }
.profit-sum > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.profit-sum > div.hl { background: var(--ok-soft); border-color: transparent; }
.profit-sum .label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.profit-sum .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.profit-sum .sub { font-size: 12px; color: var(--muted); }
.profit-table { width: 100%; }
.profit-table th[scope="row"] { font-weight: 550; color: var(--text); min-width: 220px; }
.profit-table td.num, .profit-table th.num { min-width: 140px; }
.profit-table th[scope="row"] .cell-sub { font-weight: 400; }
.profit-table td, .profit-table th { vertical-align: top; }
.profit-table th.tot, .profit-table td.tot { background: var(--surface-2); }
.profit-table tr.minus td { color: var(--bad); } .profit-table tr.plus td { color: var(--ok); }
.profit-table tr.minus td .muted, .profit-table tr.plus td .muted { color: var(--muted); }
.profit-table tr.result th, .profit-table tr.result td { border-top: 2px solid var(--border-strong); }
.profit-table tr.result td b { font-size: 15px; }
.profit-table tr.final td b { font-size: 17px; }
.profit-table tr.next th, .profit-table tr.next td { color: var(--muted); }
.top-table .pcell, .dash-card .pcell { min-width: 200px; }
.top-table .ptag { margin: 0 6px 2px 0; }
.top-table .ptag b { font-variant-numeric: tabular-nums; }
.stage-table tr.total td { background: var(--surface-2); font-weight: 600; }
.stage-table th .cell-sub { font-weight: 400; text-transform: none; letter-spacing: 0; }
@media (max-width: 700px) {
  .sync-cards { grid-template-columns: 1fr; gap: 10px; }
  .sale-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-tile { padding: 12px 14px; }
  .sale-tile .value { font-size: 18px; }
  .dash-section-head.with-chips { align-items: stretch; }
  .profit-wrap > .table-wrap { order: 0; }
  table.rtable.top-table td.rank { display: none; }
  .profit-sum { flex: 1 1 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 14px; }
  .profit-sum .value { font-size: 18px; }
}
/* ---------- end Dashboard (wc-19) ---------- */

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.meesho { background: var(--meesho); } .dot.flipkart { background: var(--flipkart); } .dot.amazon { background: var(--amazon); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { color: var(--ok); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .hint.bad-text { color: var(--bad); }
.img-prev { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; border-radius: 4px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; }
.check b { display: block; font-weight: 550; }
.check small { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg label { padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--border-strong); font-weight: 500; }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--primary-soft); color: var(--primary-text); }
.section-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0 -4px; grid-column: 1 / -1; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.toolbar input[type="search"] { max-width: 280px; }
.toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.chip .n { font-size: 11.5px; background: var(--surface-2); border-radius: 999px; padding: 0 6px; color: var(--text-2); }
.chip.active .n { background: var(--surface); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 10px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a { border-bottom: 2px solid transparent; padding: 12px 10px; font-weight: 550; color: var(--muted); white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.cell-title { font-weight: 550; }
.cell-sub { font-size: 12px; color: var(--muted); }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.table-foot { padding: 10px 18px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.ptag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.skutag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin: 1px 2px 1px 0; }

/* Product List: stock on each platform account */
.pstocks { display: flex; flex-wrap: wrap; gap: 4px; min-width: 170px; max-width: 330px; }
.pstock { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px 8px; white-space: nowrap; max-width: 100%; }
.pstock-name { overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.pstock b { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.pstock small { font-size: 10.5px; color: var(--muted); }
.pstock.ok { background: var(--ok-soft); border-color: transparent; }
.pstock.ok b { color: var(--ok); }
.pstock.warn { background: var(--warn-soft); border-color: transparent; }
.pstock.warn b { color: var(--warn); }
.pstock.bad { background: var(--bad-soft); border-color: transparent; }
.pstock.bad b { color: var(--bad); }
.pstock.dim { opacity: .6; }
.stock-sync { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.stock-sync > span { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.stock-sync .stock-key { gap: 4px; }
.stock-key .pstock { font-size: 11px; }
.stock-key .pstock.ok { color: var(--ok); }
.stock-key .pstock.bad { color: var(--bad); }
.stock-key .pstock.warn { color: var(--warn); }
@media (max-width: 700px) {
  table.rtable td:has(.pstocks) { grid-column: 1 / -1; }
  .pstocks { max-width: none; }
  .stock-sync { padding: 8px 12px; }
}

/* stock-check cells */
.sc { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.sc b { font-variant-numeric: tabular-nums; }

/* ---------- alerts list ---------- */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; }
.alert-icon.high { background: var(--bad-soft); color: var(--bad); }
.alert-icon.medium { background: var(--warn-soft); color: var(--warn); }
.alert-icon.low { background: var(--info-soft); color: var(--info); }
.alert-body { flex: 1; min-width: 0; }
.alert-body b { font-weight: 600; }
.alert-body .cell-sub { margin-top: 1px; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner p { margin: 0; flex: 1; min-width: 200px; }

/* ---------- chart ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars { position: relative; height: 200px; display: flex; align-items: stretch; gap: 0; padding: 8px 0 0 34px; margin-top: 10px; }
.bars .gridline { position: absolute; left: 34px; right: 0; border-top: 1px solid var(--grid); font-size: 11px; color: var(--muted); }
.bars .gridline span { position: absolute; left: -34px; top: -8px; width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; cursor: default; min-width: 0; }
.bars .stack { width: min(60%, 26px); display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; justify-content: flex-start; }
.bars .seg-bar { width: 100%; flex: none; }
.bars .seg-bar.top { border-radius: 4px 4px 0 0; }
.bars .col:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); border-radius: 6px; }
.bars-x { display: flex; padding-left: 34px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.bars-x span { flex: 1; display: flex; justify-content: center; white-space: nowrap; min-width: 0; }
.bars-x span:last-child { justify-content: flex-end; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; min-width: 140px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .t-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 17, 26, .5); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { min-width: 0; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal .error { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; animation: fade .15s; }
.toast.err { background: #991b1b; }
.toast.ok { background: #065f46; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--side-bg), #312e81 60%, #4f46e5); }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card .brand { color: var(--text); padding: 0 0 18px; }
.login-card .brand span { color: var(--muted); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.keybox { display: flex; gap: 8px; }
.ptabs-wrap { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 14px; background: var(--surface-2); }
.ptabs { padding: 0; margin-bottom: 14px; }
.ptabs button { display: inline-flex; align-items: center; gap: 6px; }
.ptab-mark { color: var(--ok); font-weight: 700; }
.skutag.dim { opacity: .55; }
table.pdetail th[scope="row"] { width: 120px; white-space: nowrap; }
.ext-vers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ext-vers > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.ext-vers small { display: block; color: var(--text-2); font-size: 12px; margin-bottom: 2px; }
.ext-vers b { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ext-clients .alert-item { padding: 8px 0; }
@media (max-width: 420px) { .ext-vers { grid-template-columns: 1fr; } }
.keybox input { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* =====================================================================
   Phones & small tablets
   ===================================================================== */
.top-biz { display: none; }
@media (max-width: 900px) {
  .topbar #top-title { flex: 1; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .top-biz { display: block; font-size: 12px; color: var(--muted); max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar svg { width: 22px; height: 22px; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .page { padding: 14px 14px calc(32px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-head p { font-size: 13px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > a.btn, .page-head .actions > select { flex: 1 1 auto; }

  .grid { gap: 12px; }
  .stack { gap: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .kpi .label, .kpi .sub { font-size: 12px; }
  .card-head { padding: 12px 14px; }
  .card-pad { padding: 14px; }
  .plat-card { padding: 14px; }
  .plat-stats b { font-size: 15px; }
  .banner { padding: 10px 12px; gap: 8px; }

  /* toolbars: search on its own row, filters side by side, chips scroll sideways */
  .toolbar { padding: 10px 12px; gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; order: -1; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .toolbar .check { flex: 1 1 auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .tabs { padding: 0 4px; }
  .tabs button, .tabs a { padding: 11px 9px; }

  /* tables become cards: label above value, two columns */
  table.rtable, table.rtable tbody { display: block; width: 100%; }
  table.rtable thead { display: none; }
  table.rtable tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.rtable tbody tr:last-child { border-bottom: 0; }
  table.rtable tbody tr:hover { background: transparent; }
  table.rtable td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; overflow-wrap: anywhere; }
  table.rtable td.num { text-align: left; }
  table.rtable td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
  table.rtable td.nolabel::before, table.rtable td.full::before, table.rtable td:not([data-label])::before { display: none; }
  table.rtable td.full, table.rtable td.nolabel, table.rtable td:has(.cell-title), table.rtable td:has(.btn-row) { grid-column: 1 / -1; }
  table.rtable td.nolabel:empty, table.rtable td:empty { display: none; }
  table.rtable td .sc { align-items: flex-start; flex-direction: row; gap: 6px; }
  table.rtable td .btn-row { justify-content: flex-start !important; }
  table.rtable td .btn-row .btn { flex: 1 1 auto; }
  table.rtable td.right { text-align: left; }
  table.rtable td:has(> input[type="checkbox"]) { grid-column: auto; }
  table.rtable .empty { padding: 20px 4px; }
  /* the product / person name becomes the card heading */
  table.rtable td:has(.cell-title) { order: -1; }
  table.rtable td:has(.cell-title)::before { display: none; }
  table.rtable td:has(.cell-title) .cell-title { font-size: 15px; }
  table.rtable .btn.ghost { border-color: var(--border-strong); }
  .card-pad.btn-row > .btn { flex: 1 1 100%; justify-content: flex-start; }
  /* stock-check sync status: three small boxes in one row */
  .sync-strip { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px; margin-bottom: 12px !important; }
  .sync-strip > .card { padding: 10px !important; flex-direction: column; align-items: flex-start !important; gap: 4px !important; }
  .sync-strip .small { font-size: 11px; }
  .sync-strip .btn { min-height: 30px; padding: 4px 8px; }
  .table-foot { padding: 10px 14px; }
  .table-wrap[style*="max-height"] { max-height: none !important; }

  /* lists */
  .alert-item { padding: 10px 14px; gap: 10px; }
  .alert-item .btn-row { width: 100%; padding-left: 36px; }
  .alert-item:has(.btn-row) { flex-wrap: wrap; }
  .hbar { grid-template-columns: minmax(70px, 120px) 1fr 40px; gap: 8px; }

  /* forms: 16px text stops iPhone zooming into fields; bigger tap targets */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; padding: 9px 10px; }
  input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; flex: none; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; padding: 6px 10px; }
  .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border-strong); width: 100%; }
  .seg label { border-right: 0; background: var(--surface); text-align: center; padding: 9px 8px; }
  .seg label:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kv { grid-template-columns: 110px 1fr; }
  .keybox { flex-wrap: wrap; }
  .keybox input { flex: 1 1 100%; }
  .keybox .btn { flex: 1 1 auto; }

  /* pop-ups slide up from the bottom and use the full width */
  .modal-back { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { max-width: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 94vh; border-bottom: 0; }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }

  /* chart */
  .bars { height: 170px; }
  .bars-x { font-size: 10px; }

  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .login-card { padding: 22px; }
  .userbox button { padding: 8px; }
}

@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi .value { font-size: 18px; }
  .plat-stats { gap: 6px; }
  .plat-stats div { padding: 6px 8px; }
}

/* Labels page */
.lab-card { margin-bottom: 16px; }
th.chk, td.chk { width: 36px; padding-right: 0; }
td.chk input, th.chk input { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--primary); }
tr.selected td { background: var(--primary-soft); }
.lab-name { font-weight: 550; word-break: break-word; }
.sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); z-index: 2; }
.sel-bar .spacer { flex: 1; }
@media (max-width: 700px) {
  table.rtable td.chk { grid-column: 1 / -1; }
  table.rtable tbody tr.selected { background: var(--primary-soft); }
  table.rtable tr.selected td { background: transparent; }
  .sel-bar .btn { flex: 1 1 auto; justify-content: center; }
}

/* staff portal: Today's work (Dashboard) and Returns → To receive */
.tasks-card { margin-bottom: 16px; }
.alert-icon.ok { background: var(--ok-soft); color: var(--ok); }
.task { align-items: center; }
.task.done b { color: var(--muted); font-weight: 500; }
.scan-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.scan-bar label { font-weight: 600; }
.scan-bar input { flex: 1 1 260px; max-width: 420px; font-size: 15px; }
.scan-bar .hint { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.recv-info { margin-bottom: 14px; }
@media (max-width: 700px) {
  .scan-bar { padding: 12px; }
  .scan-bar input { max-width: none; }
}
.tabs .count { margin-left: 6px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }

/* Product List: picture + name cell; Product page */
.pcell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.pcell-text { min-width: 0; }
.pcell-text .cell-title { color: var(--text); }
.pcell-text a.cell-title:hover { color: var(--primary); }
.thumb, .pimg { flex: none; object-fit: contain; border: 1px solid var(--border); background: #fff; }
.thumb { width: 44px; height: 44px; border-radius: 8px; }
.thumb.none, .pimg.none { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.thumb.none svg { width: 18px; height: 18px; }
.thumb.broken, .pimg.broken { background: var(--surface-2); }
.btn.disabled { opacity: .45; pointer-events: none; }
.toolbar.filters select { max-width: 220px; }

.prod-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.prod-grid .ptag { white-space: normal; }
@media (max-width: 1100px) { .prod-grid { grid-template-columns: 1fr; } }
table.pdetail.keep th[scope="row"] { position: sticky; left: 0; background: var(--surface-2); }
.prod-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.prod-steps { align-items: center; }
.prod-hero { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 12px 20px; padding: 18px; margin-bottom: 16px; align-items: start; }
.prod-pic { display: block; grid-row: span 2; }
.pimg { width: 168px; height: 168px; border-radius: 12px; }
.pimg.none svg { width: 42px; height: 42px; }
.prod-main h1 { margin: 4px 0 8px; font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.prod-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.prod-actions { grid-column: 2; }
@media (max-width: 700px) {
  .pcell { min-width: 0; }
  .thumb { width: 52px; height: 52px; }
  .prod-hero { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .pimg { width: 96px; height: 96px; }
  .pimg.none svg { width: 28px; height: 28px; }
  .prod-main h1 { font-size: 18px; }
  .prod-pic { grid-row: auto; }
  .prod-actions { grid-column: 1 / -1; }
  .prod-actions .btn { flex: 1 1 auto; }
  .toolbar.filters select { max-width: none; }
}

/* Product List: bulk edit pop-up (Edit selected) */
.bulk-grid { display: grid; gap: 10px; }
.bulk-row { display: grid; grid-template-columns: 150px minmax(0, 200px) minmax(0, 1fr); gap: 10px; align-items: center; }
.bulk-label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.bulk-row input:disabled { opacity: .45; }
table.bulk-prev td, table.bulk-prev th { padding: 7px 10px; }
@media (max-width: 600px) {
  .bulk-row { grid-template-columns: 1fr 1fr; gap: 6px 8px; }
  .bulk-label { grid-column: 1 / -1; }
}
