/* =====================================================================
   Muddy's Master App — "Aurora" design system
   A clean, bright, Apple-caliber light theme.
   Same class names as before, so all app behaviour is untouched —
   only the look changes.
   ===================================================================== */

:root {
  /* --- Surfaces --- */
  --bg: #f5f5f7;            /* page background (Apple's signature light grey) */
  --panel: #ffffff;         /* cards, sidebar, tables */
  --panel-2: #f5f5f7;       /* recessed areas, inputs, table headers */
  --panel-3: #ececef;       /* hover fills */
  --line: #e3e3e8;          /* hairline borders */
  --line-strong: #d2d2d7;

  /* --- Text --- */
  --text: #1d1d1f;          /* Apple near-black */
  --muted: #6e6e73;         /* Apple secondary grey */
  --faint: #86868b;

  /* --- Accents --- */
  --primary: #0071e3;       /* Apple blue */
  --primary-hover: #0077ed;
  --primary-soft: rgba(0,113,227,.10);
  --primary-soft-2: rgba(0,113,227,.16);
  --danger: #ff3b30;
  --success: #34c759;
  --warn: #ff9f0a;

  /* --- Shape & depth --- */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --accent-grad: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 12px rgba(0,0,0,.05), 0 12px 40px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.10), 0 30px 80px rgba(0,0,0,.14);
  --ring: 0 0 0 4px rgba(0,113,227,.28);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Inter", "Segoe UI", system-ui, Roboto, sans-serif;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.9rem; }

.screen { min-height: 100vh; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }

/* Headings — Apple-style tight, confident type */
h1, h2, h3, h4 { letter-spacing: -0.022em; font-weight: 700; }
h2 { margin: 0 0 22px; font-size: 1.9rem; line-height: 1.1; }
h3 { margin: 30px 0 14px; font-size: 1.2rem; }

.brand-mark { font-size: 3rem; font-weight: 800; }
.brand-mark.small { font-size: 1.2rem; }
/* Loading screen: same branded monogram tile as the login card */
#loading .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--accent-grad); color: #fff; font-size: 2.1rem;
  box-shadow: 0 10px 30px rgba(10,132,255,.35);
}

/* =========================================================
   Loading / Login
   ========================================================= */
#loading { color: var(--muted); }

#login {
  background:
    radial-gradient(1100px 620px at 15% -10%, rgba(94,92,230,.12), transparent 55%),
    radial-gradient(900px 560px at 105% 115%, rgba(10,132,255,.14), transparent 55%),
    var(--bg);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 44px 38px;
  width: min(400px, 92vw);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-card .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px; border-radius: 22px;
  background: var(--accent-grad); font-size: 2.4rem;
  box-shadow: 0 12px 30px rgba(10,132,255,.35);
  margin-bottom: 10px;
}
.login-card h1 { margin: 10px 0 2px; font-size: 1.7rem; }
.login-card form { margin-top: 22px; text-align: left; display: flex; flex-direction: column; gap: 15px; }
#ltab-pin { margin-top: 22px; text-align: left; display: flex; flex-direction: column; gap: 15px; }

.login-tabs {
  display: flex; gap: 4px; margin-top: 20px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px;
}
.ltab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 10px 10px; border-radius: 9px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all .18s ease;
}
.ltab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

/* =========================================================
   Forms
   ========================================================= */
label { display: flex; flex-direction: column; gap: 7px; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 12px 13px;
  border-radius: 11px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* =========================================================
   Buttons — Apple pill style
   ========================================================= */
.btn {
  border: none; border-radius: 980px;
  padding: 11px 20px; font-size: 0.95rem; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: transform .12s ease, filter .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; padding: 13px 20px; }
.btn-small { padding: 7px 14px; font-size: 0.83rem; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--panel-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; border-radius: 8px; padding: 4px 8px; transition: background .15s, color .15s; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* =========================================================
   App shell
   ========================================================= */
.app { display: grid; grid-template-columns: 206px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 11px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 0 6px;
}
.sidebar-brand .brand-mark.small {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-grad); font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(10,132,255,.3);
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-item {
  background: transparent; border: none; color: var(--text);
  text-align: left; padding: 7px 10px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background .15s ease, color .15s ease;
  display: flex; align-items: center; gap: 10px;
}
.nav-ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .7; }
.nav-item:hover { background: var(--panel-3); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.active .nav-ico { opacity: 1; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 11px; margin-top: 6px; display: flex; flex-direction: column; gap: 7px; }

.content { padding: 34px 40px; overflow-y: auto; max-width: 1240px; animation: viewIn .35s ease; }
.view { animation: viewIn .32s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* =========================================================
   Stat cards
   ========================================================= */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .card-label { color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.card .card-value { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; }
.card.warn .card-value { color: var(--warn); }
.card.success .card-value { color: var(--success); }

/* =========================================================
   Search
   ========================================================= */
.search { margin: 4px 0 18px; max-width: 440px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 18px; }
.filter-bar .search { margin: 0; }
.cat-filter { max-width: 220px; cursor: pointer; }

/* Search bar with a built-in camera button (opens the barcode scanner). */
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap .search { padding-right: 42px; }
.search-cam {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 8px; border: none; padding: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.search-cam:hover { background: var(--primary-soft); color: var(--primary); }
.search-cam svg { width: 19px; height: 19px; }

/* Left cluster (back button + title) in a view header. */
.head-left { display: flex; align-items: center; gap: 12px; }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th {
  color: var(--faint); font-weight: 600; background: var(--panel-2);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: rgba(0,0,0,.015); }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.badge.ok { background: rgba(52,199,89,.14); color: #248a3d; }
.badge.low { background: rgba(255,159,10,.16); color: #b26a00; }
.badge.out { background: rgba(255,59,48,.14); color: #d70015; }
.row-actions { display: flex; gap: 6px; }

/* =========================================================
   Invoice upload
   ========================================================= */
.upload-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.file-drop {
  flex: 1; min-width: 240px; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 26px 18px; text-align: center; color: var(--muted);
  background: var(--panel); transition: border-color .15s, color .15s, background .15s;
}
.file-drop:hover { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.invoice-meta { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 14px; color: var(--muted); font-size: 0.9rem; }
.match-yes { color: var(--success); font-weight: 600; }
.match-new { color: var(--warn); font-weight: 600; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.inv-header { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; margin: 6px 0 16px; box-shadow: var(--shadow-sm); }
.inv-sup-name { font-size: 1.15rem; font-weight: 700; }
.inv-totals { display: flex; flex-direction: column; gap: 3px; min-width: 190px; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 24px; font-size: 0.9rem; color: var(--muted); }
.inv-totals > div b { color: var(--text); font-variant-numeric: tabular-nums; }
.inv-totals .grand { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; font-size: 1rem; }
.inv-totals .grand span, .inv-totals .grand b { color: var(--text); font-weight: 700; }

.badge.tax { background: rgba(94,92,230,.14); color: #5e5ce6; margin-top: 6px; }
.inv-status { margin-top: 4px; }
.cost-flag { font-size: 0.78rem; font-weight: 600; margin-bottom: 4px; }
.cost-flag.up { color: var(--warn); }
.cost-flag.down { color: var(--success); }
.mini { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--muted); }
.mini input { width: 78px; padding: 5px 7px; }
.inv-flag { min-width: 150px; }
.inv-match { width: 100%; min-width: 160px; }

.supplier-costs { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.sc-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
.sc-row b { font-variant-numeric: tabular-nums; }
.lot-history { margin-top: 4px; }
.lot-history .sc-row:first-child { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 2px; }
.lot-preview:not(:empty) { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px; }

.inv-h { background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 0.98rem; }
.inv-h#ih-supplier { font-size: 1.1rem; font-weight: 700; width: 100%; max-width: 420px; }
.inv-h.small { font-size: 0.82rem; padding: 5px 8px; }
.inv-sup-details { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.inv-sup-details input { flex: 1 1 150px; }
.inv-idrow { display: flex; gap: 12px; flex-wrap: wrap; }
.inv-idrow label { flex-direction: row; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; }
.inv-idrow .inv-h { width: 150px; }
.inv-totals input.t { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }

.inv-desc, .inv-upc { width: 100%; margin-bottom: 4px; }
.inv-upc { font-size: 0.82rem; color: var(--muted); }
.inv-qty { width: 60px; }
.inv-cost { width: 82px; }
.inv-price { width: 82px; }
.inv-match { width: 100%; min-width: 150px; }
.tax-cell { text-align: center; }
.inv-tax { width: 18px; height: 18px; accent-color: var(--primary); }

.price-suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.sg-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 3px 8px; font-size: 0.72rem; cursor: pointer; white-space: nowrap; transition: all .12s; }
.sg-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.dup-banner { background: rgba(255,159,10,.12); color: #b26a00; border: 1px solid rgba(255,159,10,.35); border-radius: var(--radius-sm); padding: 12px 15px; margin: 0 0 14px; font-size: 0.9rem; font-weight: 600; }
.inv-h.locked { opacity: .6; cursor: not-allowed; }
.lock-note { font-size: 0.8rem; margin-top: 8px; color: var(--muted); }

/* "Resume unfinished invoice?" banner (auto-saved drafts) */
.draft-resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(10,132,255,.10); color: var(--text); border: 1px solid rgba(10,132,255,.35);
  border-radius: var(--radius-sm); padding: 12px 15px; margin: 0 0 14px; font-size: 0.9rem; }
.draft-resume b { font-weight: 700; }
.draft-resume-actions { display: flex; gap: 8px; flex-shrink: 0; }
#invoice-draft-banner:empty { display: none; }

/* Email-forwarded invoices waiting for review */
#invoice-inbox:empty { display: none; }
.inbox-head { font-size: 0.92rem; margin: 4px 0 10px; }
.inbox-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(48,209,88,.08); border: 1px solid rgba(48,209,88,.35);
  border-radius: var(--radius-sm); padding: 12px 15px; margin: 0 0 10px; }
.inbox-title { font-weight: 700; }
.inbox-actions { display: flex; gap: 8px; flex-shrink: 0; }
.email-body-note { background: rgba(120,120,128,.10); border: 1px solid rgba(120,120,128,.25);
  border-radius: var(--radius-sm); padding: 10px 13px; margin: 4px 0 10px; font-size: 0.85rem; line-height: 1.5; }

/* Units-per-box column + the "= N units" helper under the quantity box */
.inv-upb { width: 62px; }
.inv-units-hint { margin-top: 3px; }

/* Delivery fees / non-product charges */
.fees-section { border-top: 1px dashed var(--line); padding-top: 12px; }
.fee-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.fee-row input { width: 100%; }
.fee-row .fee-remove { padding: 8px 11px; line-height: 1; }

/* Totals reconciliation banner — green when balanced, red when it won't submit */
.reconcile-banner { border-radius: var(--radius-sm); padding: 12px 15px; margin: 14px 0 0; font-size: 0.9rem; font-weight: 600; line-height: 1.45; }
.reconcile-banner:empty { display: none; }
.reconcile-banner.ok { background: rgba(48,209,88,.12); color: #1a7f37; border: 1px solid rgba(48,209,88,.35); }
.reconcile-banner.bad { background: rgba(255,69,58,.12); color: #c11414; border: 1px solid rgba(255,69,58,.4); }
.reconcile-banner.warn { background: rgba(255,159,10,.12); color: #b26a00; border: 1px solid rgba(255,159,10,.35); }
:root[data-theme="dark"] .reconcile-banner.ok { color: #4cd97b; }
:root[data-theme="dark"] .reconcile-banner.bad { color: #ff6b61; background: rgba(255,69,58,.15); }
:root[data-theme="dark"] .reconcile-banner.warn { color: #ffd60a; background: rgba(255,214,10,.12); }

/* =========================================================
   Lists
   ========================================================= */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease;
}
.list-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* =========================================================
   Modal
   ========================================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.32);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  width: min(560px, 96vw); max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.15rem; }
#modal-form { padding: 22px; display: flex; flex-direction: column; gap: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* Sizes / options (variants) editor inside the product form */
.variants-section { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.variant-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; background: var(--panel-2); }
.variant-row input { width: 100%; }
.vr-main { display: grid; grid-template-columns: 1.6fr 0.7fr 0.8fr 0.8fr auto; gap: 8px; align-items: center; }
.vr-main .v-label { font-weight: 600; }
.vr-main .v-remove { padding: 8px 11px; line-height: 1; }
.vr-more { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.vr-f { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; color: var(--muted); }
.vr-f input { font-size: 0.85rem; }
@media (max-width: 640px) {
  .vr-main { grid-template-columns: 1fr 1fr auto; }
  .vr-more { grid-template-columns: 1fr 1fr; }
}

/* Products header can hold more than one button */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Spreadsheet import modal */
.import-summary { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 4px; }
.import-summary .is-big { font-size: 1.05rem; }
.import-summary .is-big b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.import-summary .is-sub { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
.import-summary hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.import-summary .is-row { display: flex; align-items: center; gap: 9px; margin-top: 7px; font-size: 0.92rem; }
.import-bar { height: 12px; border-radius: 99px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); margin-top: 10px; }
.import-bar span { display: block; height: 100%; background: var(--accent-grad, #2f6fe0); transition: width 0.2s ease; }

/* Merge-duplicates preview */
.dup-preview { max-height: 320px; overflow-y: auto; margin: 6px 0 4px; }
.dup-group { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.dup-group-head { font-size: 0.92rem; margin-bottom: 4px; }
.dup-list { margin: 4px 0 0; padding-left: 20px; }
.dup-list li { font-size: 0.88rem; margin: 2px 0; }

/* =========================================================
   My Shift
   ========================================================= */
.shift-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; max-width: 400px; display: flex; flex-direction: column; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.shift-status { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.shift-status.in { color: var(--success); }
.shift-status.out { color: var(--muted); }
hr.soft { border: none; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }
body[data-role="staff"] #products-table .row-actions { display: none; }

/* =========================================================
   Team — sub-tabs, roster
   ========================================================= */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
/* Sub-panel header: intro text on the left, an action button on the right. */
.subpanel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.subpanel-head p { margin: 0 0 8px; }
.subtab { background: none; border: none; color: var(--muted); font: inherit; font-weight: 600; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--primary); border-bottom-color: var(--primary); }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--primary-soft); }
.row-muted { opacity: 0.5; }
.section-row td { background: var(--panel-2); color: var(--faint); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 8px 16px; }
.chip { display: inline-block; padding: 4px 11px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 0.8rem; font-weight: 600; }
.chip-danger { background: rgba(255,59,48,.14); color: #d70015; border-color: transparent; }

/* =========================================================
   Employee profile
   ========================================================= */
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--accent-grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; flex: 0 0 auto; box-shadow: 0 6px 16px rgba(10,132,255,.3); }
.profile-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.mini-stat.danger { border-color: rgba(255,59,48,.4); background: rgba(255,59,48,.07); }
.mini-val { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.mini-label { color: var(--muted); font-size: 0.74rem; margin-top: 3px; }
.flag-banner { background: rgba(255,59,48,.08); border: 1px solid rgba(255,59,48,.4); color: #d70015; border-radius: var(--radius-sm); padding: 11px 14px; font-size: 0.9rem; }
#modal-form h4 { margin: 6px 0 0; font-size: 0.95rem; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv { display: flex; flex-direction: column; }
.kv-k { color: var(--muted); font-size: 0.74rem; }
.kv-v { font-weight: 500; }

/* =========================================================
   Profit dashboard
   ========================================================= */
.profit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 4px; }
.profit-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.profit-box h3 { margin: 0 0 12px; font-size: 1rem; }
.pline { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; color: var(--muted); }
.pline strong { color: var(--text); }
.pline.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 11px; font-size: 1.05rem; }
.pline .pos { color: var(--success); }
.pline .neg { color: var(--warn); }

/* =========================================================
   Strict clock-in
   ========================================================= */
.onsite-note { background: var(--primary-soft); border: 1px solid rgba(0,113,227,.25); color: #0058b0; border-radius: 10px; padding: 9px 12px; font-size: 0.85rem; }
.desk-code-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.desk-code-field input { letter-spacing: .3em; text-align: center; font-size: 1.2rem; }
.store-setup { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.store-setup label { display: flex; flex-direction: column; gap: 4px; }

/* =========================================================
   Front Desk kiosk
   ========================================================= */
.kiosk-grid { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 26px; align-items: start; }
.kiosk-card { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px; text-align: center; box-shadow: var(--shadow-lg); }
.kiosk-label { color: var(--muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 4px 0; }
.kiosk-qr { display: flex; justify-content: center; }
.kiosk-qr svg { width: 220px; height: 220px; }
.kiosk-code { font-size: 3rem; font-weight: 800; letter-spacing: .22em; color: var(--text); }
.kiosk-side h3 { margin-top: 0; }
.kiosk-side ol { padding-left: 18px; line-height: 1.8; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-weight: 500; color: var(--text); }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--primary); }

/* =========================================================
   Schedule
   ========================================================= */
.sched-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.week-nav { display: flex; align-items: center; gap: 10px; }
.sched-actions { display: flex; align-items: center; gap: 10px; }
.hours-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.swap-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.swap-box h3 { margin: 0 0 8px; }
.swap-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.swap-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.board { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 10px; overflow-x: auto; }
.day-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; min-height: 130px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.day-col.blackout { background: repeating-linear-gradient(45deg, var(--panel), var(--panel) 8px, var(--panel-2) 8px, var(--panel-2) 16px); }
.day-head { font-weight: 700; font-size: 0.9rem; display: flex; flex-direction: column; gap: 2px; }
.bo-tag { color: var(--danger); font-size: 0.72rem; font-weight: 600; }
.shift-chip { background: var(--accent-grad); color: #fff; border-radius: 9px; padding: 7px 9px; cursor: pointer; font-size: 0.82rem; box-shadow: 0 3px 8px rgba(10,132,255,.25); transition: transform .12s; }
.shift-chip:hover { transform: translateY(-1px); }
.shift-chip.swap { background: linear-gradient(135deg, #ff9f0a, #ff3b30); box-shadow: 0 3px 8px rgba(255,90,40,.3); }
.sc-name { font-weight: 700; }
.sc-time { opacity: .92; font-size: 0.76rem; }
.sc-swap { font-size: 0.72rem; margin-top: 2px; }
.add-shift-btn { margin-top: auto; background: none; border: 1px dashed var(--line-strong); color: var(--muted); border-radius: 8px; padding: 6px; cursor: pointer; font-size: 0.8rem; transition: all .15s; }
.add-shift-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.blackout-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-top: 18px; box-shadow: var(--shadow-sm); }
.blackout-box h3 { margin: 0 0 4px; }
.blackout-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.blackout-add input { flex: 1 1 auto; }
.blackout-list { display: flex; flex-wrap: wrap; gap: 8px; }
.bo-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; font-size: 0.85rem; }
.bo-del { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 700; }
.avail-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; box-shadow: var(--shadow-sm); }

/* =========================================================
   Hours / availability editors
   ========================================================= */
.hours-row, .avail-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr 0.7fr; gap: 8px; align-items: center; }
.avail-row { grid-template-columns: 1.4fr 1.3fr 1fr 1fr; }
.hours-head { color: var(--muted); font-size: 0.75rem; }
.hours-day, .avail-day { font-weight: 600; font-size: 0.9rem; }
.inline-check { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; color: var(--muted); }
.inline-check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* =========================================================
   POS & Integrations roadmap card
   ========================================================= */
.integrations-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-sm); margin: 24px 0 8px; max-width: 580px;
}
.int-head { display: flex; align-items: flex-start; gap: 13px; }
.int-head h3 { margin: 0; font-size: 1.15rem; }
.int-head p { margin: 3px 0 0; }
.int-ico { width: 26px; height: 26px; color: var(--primary); flex: 0 0 auto; margin-top: 2px; }
.int-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 0; border-top: 1px solid var(--line); font-weight: 500;
}
.int-row:first-of-type { margin-top: 10px; }
.badge.progress { background: rgba(255,159,10,.16); color: #b26a00; }
.badge.planned { background: var(--panel-3); color: var(--muted); }
:root[data-theme="dark"] .badge.progress { background: rgba(255,214,10,.16); color: #ffd60a; }

/* =========================================================
   Store info card (address, phone, hours + Open/Closed)
   ========================================================= */
.store-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow-sm); margin: 24px 0 8px; max-width: 580px;
}
.store-head { display: flex; align-items: flex-start; gap: 13px; }
.store-head .store-title, .store-head > div { min-width: 0; }
.store-head h3 { margin: 0; font-size: 1.15rem; }
.store-head p { margin: 3px 0 0; }
.store-pill {
  margin-left: auto; flex: 0 0 auto; align-self: flex-start;
  font-size: .8rem; font-weight: 600; padding: 4px 11px; border-radius: 980px; white-space: nowrap;
}
.store-pill.open { background: rgba(52,199,89,.16); color: #1a7f37; }
.store-pill.closed { background: var(--panel-3); color: var(--muted); }
:root[data-theme="dark"] .store-pill.open { background: rgba(48,209,88,.18); color: #30d158; }
.store-body { margin-top: 14px; }
.store-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.store-link {
  color: var(--primary); text-decoration: none; font-weight: 500; font-size: .95rem;
}
.store-link:hover { text-decoration: underline; }
.store-today { flex-basis: 100%; color: var(--muted); font-size: .95rem; }
.store-today strong { color: var(--text); }
.store-hours { margin-top: 14px; }
.store-hours summary { cursor: pointer; color: var(--primary); font-weight: 500; font-size: .95rem; }
.hours-grid { margin-top: 10px; border-top: 1px solid var(--line); }
.hours-row {
  display: flex; justify-content: space-between; padding: 8px 2px;
  border-bottom: 1px solid var(--line); font-size: .95rem;
}
.hours-row.is-today { font-weight: 600; }
.hours-row.is-today span:first-child::after { content: " · today"; color: var(--primary); font-weight: 500; }
.store-actions { margin-top: 16px; }
.empty-store { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
/* Store details editor — per-day hours rows */
.si-hours { margin-top: 6px; }
.si-day {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.si-day-name { width: 42px; font-weight: 600; }
.si-closed { display: inline-flex; align-items: center; gap: 5px; font-size: .9rem; color: var(--muted); }
.si-day input[type="time"] { width: auto; flex: 0 0 auto; }

/* =========================================================
   Light / dark toggle button
   ========================================================= */
.theme-toggle {
  position: fixed; bottom: 18px; right: 18px; z-index: 45;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel);
  box-shadow: var(--shadow); cursor: pointer; font-size: 1.15rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.theme-toggle:hover { transform: scale(1.09); box-shadow: var(--shadow-lg); }
.theme-toggle:active { transform: scale(.96); }

/* =========================================================
   DARK THEME — a premium near-black "Aurora Dark"
   (activated by data-theme="dark" on <html>)
   ========================================================= */
:root[data-theme="dark"] {
  --bg: #0a0a0c;
  --panel: #1c1c1e;
  --panel-2: #2c2c2e;
  --panel-3: #3a3a3c;
  --line: #38383a;
  --line-strong: #48484a;
  --text: #f5f5f7;
  --muted: #9a9aa0;
  --faint: #8e8e93;
  --primary: #0a84ff;
  --primary-hover: #409cff;
  --primary-soft: rgba(10,132,255,.18);
  --primary-soft-2: rgba(10,132,255,.26);
  --danger: #ff453a;
  --success: #30d158;
  --warn: #ffd60a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 4px 14px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  --ring: 0 0 0 4px rgba(10,132,255,.35);
}
:root[data-theme="dark"] #login {
  background:
    radial-gradient(1100px 620px at 15% -10%, rgba(94,92,230,.20), transparent 55%),
    radial-gradient(900px 560px at 105% 115%, rgba(10,132,255,.22), transparent 55%),
    var(--bg);
}
:root[data-theme="dark"] .sidebar { background: rgba(28,28,30,.72); }
:root[data-theme="dark"] tbody tr:hover td { background: rgba(255,255,255,.035); }
:root[data-theme="dark"] .clickable-row:hover td { background: var(--primary-soft); }
:root[data-theme="dark"] .badge.ok { background: rgba(48,209,88,.18); color: #4cd97b; }
:root[data-theme="dark"] .badge.low { background: rgba(255,214,10,.16); color: #ffd60a; }
:root[data-theme="dark"] .badge.out { background: rgba(255,69,58,.18); color: #ff6961; }
:root[data-theme="dark"] .badge.tax { background: rgba(94,92,230,.24); color: #a5a3ff; }
:root[data-theme="dark"] .chip-danger { color: #ff6961; }
:root[data-theme="dark"] .flag-banner { color: #ff6961; background: rgba(255,69,58,.12); }
:root[data-theme="dark"] .mini-stat.danger { color: #ff6961; }
:root[data-theme="dark"] .onsite-note { color: #7fbfff; }
:root[data-theme="dark"] .dup-banner { color: #ffd60a; background: rgba(255,214,10,.12); }
:root[data-theme="dark"] .cost-flag.up,
:root[data-theme="dark"] .match-new { color: #ffd60a; }
:root[data-theme="dark"] .cost-flag.down,
:root[data-theme="dark"] .match-yes { color: #4cd97b; }

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 720px) {
  h2 { font-size: 1.5rem; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .kv-grid { grid-template-columns: 1fr; }
  .kiosk-grid { grid-template-columns: 1fr; }
  .board { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 78%; }
  .profit-grid { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-brand { margin-bottom: 0; width: 100%; }
  .content { padding: 22px 16px; }
}

/* ===== Barcode price tags ===== */
.tag-preview { display: flex; justify-content: center; margin: 6px 0 14px; }
.tag-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0 14px; }
.tag-label {
  width: 220px; min-height: 120px; background: #fff; color: #111;
  border: 1px solid var(--border, #d2d2d7); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center;
}
.tag-label.big { width: 260px; }
.tag-name { font-size: 13px; font-weight: 700; line-height: 1.15; }
.tag-price { font-size: 24px; font-weight: 800; margin: 2px 0; }
.tag-bc svg { max-width: 100%; height: auto; }
.tag-nocode { font-size: 11px; color: #999; padding: 8px 4px; }
.tag-more { display: flex; align-items: center; justify-content: center; width: 120px; color: var(--muted, #86868b); font-weight: 600; }

/* ===== Barcode scanner ===== */
.scan-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 820px) { .scan-grid { grid-template-columns: 1fr; } }

.scan-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000;
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
#scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-reticle { position: absolute; inset: 16% 12%; pointer-events: none; }
.scan-reticle span {
  position: absolute; width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.9);
  border-radius: 6px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
.scan-reticle span:nth-child(1) { top: 0; left: 0; border-right: none; border-bottom: none; }
.scan-reticle span:nth-child(2) { top: 0; right: 0; border-left: none; border-bottom: none; }
.scan-reticle span:nth-child(3) { bottom: 0; left: 0; border-right: none; border-top: none; }
.scan-reticle span:nth-child(4) { bottom: 0; right: 0; border-left: none; border-top: none; }
/* A scan line that sweeps while the camera is live. */
.scan-reticle::after {
  content: ""; position: absolute; left: 6%; right: 6%; height: 2px;
  background: linear-gradient(90deg, transparent, #34c759, transparent);
  box-shadow: 0 0 8px #34c759; opacity: 0; top: 50%;
}
body.scanning .scan-reticle::after { opacity: .9; animation: scanSweep 2s ease-in-out infinite; }
@keyframes scanSweep { 0% { top: 8%; } 50% { top: 92%; } 100% { top: 8%; } }

.scan-hint {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff;
  font-size: .85rem; text-align: center;
}
.scan-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.scan-controls .btn { width: 100%; }
.scan-manual { display: flex; gap: 8px; }
.scan-manual input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: .95rem;
}
.scan-manual .btn { width: auto; white-space: nowrap; }

.scan-side { display: flex; flex-direction: column; gap: 16px; }
.scan-order-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.scan-order-info { display: flex; align-items: center; gap: 10px; }
.scan-order-ico { font-size: 1.5rem; line-height: 1; }
.scan-order-title { font-weight: 700; }
.scan-order-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-result {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px; min-height: 120px;
}
.scan-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 34px 18px; }
.scan-empty-ico { font-size: 2rem; opacity: .6; }

.scan-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.scan-card-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.scan-card-opt { font-size: .9rem; color: var(--muted); margin: 2px 0 6px; font-weight: 600; }
.scan-card-price { font-size: 1.5rem; font-weight: 800; white-space: nowrap; }
.scan-stats { display: flex; align-items: center; gap: 18px; margin: 14px 0 6px; flex-wrap: wrap; }
.scan-stat { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.scan-stat-n { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.scan-stat-l { font-size: .78rem; color: var(--muted); }
.scan-card-meta { margin-top: 6px; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.scan-actions .btn { flex: 1 1 auto; }

.scan-miss { text-align: center; padding: 12px 6px; }
.scan-miss-ico { font-size: 2rem; }
.scan-miss h3 { margin: 8px 0 4px; }
.scan-miss code, .scan-card-meta code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }

.scan-log-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px; }
.scan-log-head { font-weight: 700; font-size: .95rem; margin-bottom: 8px; }
.scan-log { display: flex; flex-direction: column; gap: 2px; }
.scan-log-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: transparent; border: none; cursor: pointer;
  padding: 8px 8px; border-radius: 10px; color: var(--text); font-size: .9rem;
}
.scan-log-row:hover { background: var(--panel-2); }
.scan-log-name { font-weight: 600; }
.scan-log-code { font-variant-numeric: tabular-nums; }

/* ===================== INVENTORY COUNT ===================== */
#count-video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --- Start screen + history --- */
.count-start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 820px) { .count-start { grid-template-columns: 1fr; } }
.count-start-card, .count-history {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.count-start-card h3, .count-history h3 { margin: 0 0 6px; }
.count-scope { display: flex; gap: 10px; margin-top: 14px; }
.cradio { flex: 1; }
.cradio input { position: absolute; opacity: 0; pointer-events: none; }
.cradio span {
  display: block; text-align: center; padding: 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); background: var(--panel-2); cursor: pointer;
  font-weight: 600; transition: all .15s;
}
.cradio input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.btn-block { width: 100%; display: block; }

.count-hist-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.count-hist-row:last-child { border-bottom: none; }
.count-hist-title { font-weight: 600; }
.count-hist-side { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.count-dur { font-variant-numeric: tabular-nums; font-weight: 600; }
.loss { color: var(--danger); font-weight: 700; }

/* --- Active counting --- */
.count-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.count-title { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.count-topbar-actions { display: flex; gap: 8px; align-items: center; }

.count-progress { margin-bottom: 16px; }
.count-progress-bar {
  height: 10px; border-radius: 999px; background: var(--panel-3); overflow: hidden; margin-bottom: 6px;
}
.count-progress-bar span { display: block; height: 100%; background: var(--accent-grad); border-radius: 999px; transition: width .3s; }

/* the "now counting" stepper */
.count-now {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px;
}
.count-now-empty { text-align: center; padding: 18px; }
.count-now-name { font-size: 1.15rem; font-weight: 700; }
.count-now-name small { font-weight: 500; color: var(--muted); }
.count-now-sub { margin-top: 2px; }
.count-stepper { display: flex; align-items: stretch; gap: 12px; margin: 16px 0 8px; }
.step-btn {
  width: 64px; font-size: 2rem; line-height: 1; border: none; cursor: pointer;
  border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary);
  font-weight: 700; user-select: none; transition: background .12s;
}
.step-btn:hover { background: var(--primary-soft-2); }
.step-btn:active { transform: scale(.96); }
.count-qty {
  flex: 1; text-align: center; font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); padding: 6px; min-width: 0;
}
.count-qty:focus { outline: none; box-shadow: var(--ring); border-color: var(--primary); }
.count-now-hint { text-align: center; margin: 6px 0 12px; }
.count-unknown { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.count-unknown-ico { font-size: 1.8rem; }

/* the live "virtual spreadsheet" */
.count-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; margin-bottom: 4px;
}
.count-sheet {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); max-height: 62vh; overflow-y: auto;
}
.count-sheet-empty { padding: 26px 18px; text-align: center; }
.count-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.count-row:last-child { border-bottom: none; }
.count-row.is-sel { background: var(--primary-soft); }
.count-row-main { flex: 1; min-width: 0; text-align: left; background: none; border: none; cursor: pointer; color: var(--text); padding: 0; }
.count-row-name { display: block; font-weight: 600; }
.count-row-qty { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.count-row-del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 1rem; padding: 4px 6px; border-radius: 8px; }
.count-row-del:hover { color: var(--danger); background: var(--panel-3); }

/* --- More-info modal --- */
.count-info-head { display: flex; gap: 8px; margin-bottom: 12px; }
.count-info-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.count-info-k { color: var(--muted); }
.count-info-v { font-weight: 600; text-align: right; }
.count-info-bar { margin: 16px 0; text-align: center; background: #fff; padding: 10px; border-radius: var(--radius-sm); }
.count-info-vars { margin-top: 14px; }
.count-info-var { display: flex; justify-content: space-between; padding: 7px 10px; border-radius: 8px; }
.count-info-var.is-sel { background: var(--primary-soft); }

/* --- Review modal --- */
.count-review-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 560px) { .count-review-stats { grid-template-columns: repeat(2, 1fr); } }
.crs { background: var(--panel-2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.crs-n { display: block; font-size: 1.5rem; font-weight: 700; }
.crs-l { color: var(--muted); font-size: .78rem; }
.count-ai {
  border: 1.5px solid var(--primary); background: var(--primary-soft); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.count-ai-head { font-weight: 700; margin-bottom: 4px; }
.count-ai-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.count-review-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.ctab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--panel-2); color: var(--muted); cursor: pointer; font-weight: 600; font-size: .85rem;
}
.ctab.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.count-review-table { width: 100%; border-collapse: collapse; }
.count-review-table th, .count-review-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.count-review-table th.num, .count-review-table td.num { text-align: right; }
.count-review-table td.num { font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .count-info-bar { background: #f5f5f7; }

/* ===== Smart Purchasing ===== */
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
}
.po-summary {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px;
}
.po-group { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; background: var(--panel); }
.po-group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.po-group-head h3 { margin: 0; font-size: 1.02rem; }
td.danger { color: var(--danger); font-weight: 700; }
.po-lines-table { width: 100%; border-collapse: collapse; }
.po-lines-table th, .po-lines-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.po-lines-table input { width: 100%; max-width: 110px; }
.po-add-row { margin: 12px 0; }
.po-add-row input { width: 100%; }
.po-subtotal-row { text-align: right; font-size: 1.05rem; margin: 8px 0 4px; }
.po-form-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.po-actions .spacer { flex: 1; }
.chk-line { display: flex; align-items: center; gap: 8px; flex-direction: row !important; }
.chk-line input { width: auto; }
.danger-text { color: var(--danger); }
.trend-up { color: #159a5a; font-weight: 700; white-space: nowrap; }
.trend-down { color: var(--danger); font-weight: 700; white-space: nowrap; }
:root[data-theme="dark"] .trend-up { color: #4cd97b; }
.sales-note {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: .84rem; color: var(--text); margin: 10px 0 4px; line-height: 1.45;
}
.sup-primary { font-size: .95rem; margin-bottom: 2px; }
.sup-cadence { font-size: .82rem; color: var(--primary); font-weight: 600; margin-bottom: 4px; }

/* ===== Stock Forecast page ===== */
.fc-lede { color: var(--muted); font-size: 1rem; line-height: 1.55; max-width: 62ch; margin: 0 0 22px; }
.fc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 10px; }
.fc-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.fc-k { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.fc-v { font-size: 1.85rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fc-v.up { color: #159a5a; } .fc-v.down { color: var(--danger); }
:root[data-theme="dark"] .fc-v.up { color: #4cd97b; }
.fc-s { margin-top: 8px; font-size: .8rem; color: var(--muted); line-height: 1.4; }
.fc-h { font-size: 1.05rem; color: var(--text); font-weight: 700; margin: 28px 0 14px; }
.fc-h4 { font-size: 1rem; color: var(--text); font-weight: 700; margin: 0 0 4px; }
.fc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 14px; }
.fc-sub { font-size: .84rem; color: var(--muted); line-height: 1.45; margin: 0 0 14px; }
.fc-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.fc-bar span { display: block; height: 100%; }
.fc-bar .b-fast { background: var(--primary); }
.fc-bar .b-med { background: color-mix(in srgb, var(--primary) 55%, var(--panel-2)); }
.fc-bar .b-slow { background: color-mix(in srgb, var(--primary) 24%, var(--panel-2)); }
.fc-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.fc-li { display: flex; gap: 10px; align-items: flex-start; }
.fc-li .sw { width: 12px; height: 12px; border-radius: 3px; margin-top: 3px; flex: none; }
.sw-fast { background: var(--primary); }
.sw-med { background: color-mix(in srgb, var(--primary) 55%, var(--panel-2)); }
.sw-slow { background: color-mix(in srgb, var(--primary) 24%, var(--panel-2)); }
.fc-lv { font-weight: 800; color: var(--text); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.fc-ll { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.fc-table { width: 100%; border-collapse: collapse; }
.fc-table th, .fc-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
.fc-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.fc-table td.r, .fc-table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.fc-table td.rank { color: var(--muted); width: 1.6em; font-variant-numeric: tabular-nums; }
.fc-table td.pname { font-weight: 600; color: var(--text); }
.fc-table tbody tr:last-child td { border-bottom: none; }
.fc-chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.fc-chip.up { color: #159a5a; background: rgba(21,154,90,.12); }
.fc-chip.down { color: var(--danger); background: rgba(216,59,52,.12); }
.fc-chip.new { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
:root[data-theme="dark"] .fc-chip.up { color: #4cd97b; background: rgba(47,208,122,.16); }
.fc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .fc-two { grid-template-columns: 1fr; } }
.fc-mv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.fc-mv:last-child { border-bottom: none; }
.fc-mv .nm { font-weight: 600; color: var(--text); }
.fc-mv .det { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-learning { border-style: dashed; }
.fc-note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: .86rem; color: var(--text); line-height: 1.55; margin-top: 24px; }

/* ---- Product Profit page ---- */
.fc-chip.flat { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.pf-cat { margin: 0 0 14px; }
.pf-cat:last-child { margin-bottom: 4px; }
.pf-cat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; font-size: .9rem; }
.pf-cat-name { font-weight: 600; color: var(--text); }
.pf-cat-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-cat-track { height: 12px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.pf-cat-track span { display: block; height: 100%; background: var(--accent-grad); border-radius: 99px; }

/* Keep supplier phone numbers on one line so they don't break at the hyphens */
.phone-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ===================== ORDER ASSISTANT (AI chatbot) ===================== */
.asst-wrap { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.asst-chat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px; min-height: 46vh; max-height: 58vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.asst-msg { display: flex; }
.asst-msg.me { justify-content: flex-end; }
.asst-msg.ai { justify-content: flex-start; }
.asst-bubble {
  max-width: 82%; padding: 11px 15px; border-radius: 18px; line-height: 1.45;
  font-size: 0.95rem; word-wrap: break-word;
}
.asst-msg.ai .asst-bubble { background: var(--panel-2); color: var(--text); border-bottom-left-radius: 6px; }
.asst-msg.me .asst-bubble { background: var(--accent-grad); color: #fff; border-bottom-right-radius: 6px; }

/* typing dots */
.asst-typing { display: inline-flex; gap: 5px; align-items: center; }
.asst-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  opacity: .5; animation: asstBlink 1s infinite;
}
.asst-typing span:nth-child(2) { animation-delay: .2s; }
.asst-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes asstBlink { 0%,80%,100% { opacity:.3; transform: translateY(0);} 40% { opacity:1; transform: translateY(-3px);} }

/* the live order the assistant is building */
.asst-order {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px 18px;
}
.asst-order.hidden { display: none; }
.asst-order-head { margin-bottom: 10px; font-size: 1.02rem; }
.asst-order-lines { display: flex; flex-direction: column; gap: 8px; }
.asst-line {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.asst-line:last-child { border-bottom: none; }
.asst-line-name { font-weight: 500; font-size: 0.95rem; }
.asst-stepper { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.asst-step {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 1.15rem; line-height: 1;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.asst-step:hover { border-color: var(--primary); color: var(--primary); }
.asst-boxes { min-width: 66px; text-align: center; font-weight: 600; }
.asst-rm { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 0.95rem; padding: 4px 6px; border-radius: 8px; }
.asst-rm:hover { color: #ff453a; background: rgba(255,69,58,.1); }
.asst-order-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* quick-start suggestion chips */
.asst-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.asst-chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.asst-chip:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* the input bar */
.asst-inputbar { display: flex; gap: 10px; align-items: stretch; }
.asst-inputbar input {
  flex: 1; padding: 13px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 0.95rem;
}
.asst-inputbar input:focus { outline: none; border-color: var(--primary); }
.asst-send {
  width: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
}

/* =====================================================================
   COMMAND CENTER — top bar, AI briefing, KPI tiles, smart alerts
   Added on top of the Aurora base. Nothing above is changed.
   ===================================================================== */

/* ---- Sticky top bar: global AI search + notifications ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  margin: -34px -40px 26px; padding: 14px 40px;
  background: rgba(255,255,255,.75);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
:root[data-theme="dark"] .topbar { background: rgba(20,20,22,.72); }
.ask-wrap {
  position: relative; flex: 1; max-width: 620px; display: flex; align-items: center;
}
.ask-wrap .ask-ico {
  position: absolute; left: 15px; width: 18px; height: 18px; color: var(--primary);
  pointer-events: none;
}
#ask-input {
  width: 100%; padding: 11px 15px 11px 44px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text);
  font-size: 0.95rem; transition: border-color .15s, box-shadow .15s, background .15s;
}
#ask-input:focus { outline: none; border-color: var(--primary); background: var(--panel); box-shadow: var(--ring); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bell {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .12s;
}
.bell:hover { background: var(--panel-2); box-shadow: var(--shadow-sm); }
.bell:active { transform: scale(.95); }
.bell svg { width: 20px; height: 20px; }
.bell-count {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--panel);
}
.bell-count.hidden { display: none; }

/* ---- Ask-anything answer panel ---- */
.ask-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 22px;
  animation: viewIn .25s ease;
}
.ask-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ask-q { font-weight: 700; }
.ask-answer { font-size: 1.02rem; line-height: 1.55; margin: 6px 0 2px; }
.ask-results { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.ask-result {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; background: transparent;
  border: none; width: 100%; text-align: left; color: var(--text); font-size: 0.92rem;
  transition: background .12s;
}
.ask-result:hover { background: var(--panel-2); }
.ask-close { margin-left: auto; }

/* ---- Dashboard head + greeting ---- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-head h2 { margin: 0; }
.dash-greeting { margin: 4px 0 0; color: var(--muted); font-size: 0.98rem; }

/* ---- AI Daily Briefing hero card ---- */
.briefing-card {
  position: relative; overflow: hidden;
  background:
    radial-gradient(700px 200px at 0% 0%, rgba(94,92,230,.10), transparent 60%),
    radial-gradient(700px 220px at 100% 100%, rgba(10,132,255,.10), transparent 60%),
    var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.briefing-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent-grad);
}
.briefing-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ai-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-size: 0.72rem; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.ai-pill svg { width: 13px; height: 13px; }
.briefing-head .briefing-refresh { margin-left: auto; }
.briefing-headline { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 12px; line-height: 1.35; }
.briefing-points { display: flex; flex-direction: column; gap: 9px; }
.briefing-point { display: flex; align-items: flex-start; gap: 10px; font-size: 0.96rem; line-height: 1.5; }
.briefing-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; }
.briefing-dot.warn { background: var(--warn); }
.briefing-dot.info { background: var(--primary); }
.briefing-dot.good { background: var(--success); }
.briefing-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.95rem; }
.briefing-skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Premium KPI tiles (enhances existing .card) ---- */
#stat-cards .card { position: relative; overflow: hidden; padding: 18px 20px; }
.card .card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .card-ico {
  width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.card .card-ico svg { width: 18px; height: 18px; }
.card.warn .card-ico { background: rgba(255,159,10,.16); color: var(--warn); }
.card.success .card-ico { background: rgba(52,199,89,.16); color: var(--success); }
.card .card-sub { color: var(--faint); font-size: 0.76rem; margin-top: 4px; }
.card .card-value { margin-top: 10px; }
/* radial margin gauge */
.gauge { --pct: 0; width: 58px; height: 58px; border-radius: 50%; position: relative; flex: 0 0 auto;
  background: conic-gradient(var(--success) calc(var(--pct) * 1%), var(--panel-3) 0); }
.gauge::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--panel); }
.gauge b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 800; z-index: 1; }

/* ---- Two-column dashboard band ---- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; margin-top: 4px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---- Smart alerts feed ---- */
.alerts-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; }
.alerts-card h3 { margin: 0 0 12px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.alerts-card h3 .ai-pill { margin-left: auto; }
.alert-item {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); margin-bottom: 8px; background: var(--panel-2);
  cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.alert-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.alert-item:last-child { margin-bottom: 0; }
.alert-ico { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem; }
.alert-item.warn .alert-ico { background: rgba(255,159,10,.16); }
.alert-item.bad .alert-ico { background: rgba(255,59,48,.14); }
.alert-item.good .alert-ico { background: rgba(52,199,89,.16); }
.alert-item.info .alert-ico { background: var(--primary-soft); }
.alert-body { min-width: 0; }
.alert-title { font-weight: 600; font-size: 0.93rem; }
.alert-sub { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.alerts-empty { color: var(--muted); padding: 8px 2px; font-size: 0.92rem; }

/* ---- Reorder "why" reasoning ---- */
.reorder-why { color: var(--muted); font-size: 0.78rem; margin-top: 3px; line-height: 1.4; }
.reorder-why b { color: var(--text); font-weight: 600; }
.trend-up { color: var(--success); font-weight: 700; }
.trend-down { color: var(--warn); font-weight: 700; }

@media (max-width: 720px) {
  .topbar { margin: -22px -16px 18px; padding: 12px 16px; }
  .ask-wrap { max-width: none; }
}
