/* ============================================================================
   Price Watch — design system
   Modern SaaS dashboard aesthetic: deep indigo/teal gradient sidebar,
   clean light workspace, card-based layout, generous whitespace,
   fully responsive down to phone width.
   ============================================================================ */

:root {
  /* Brand */
  --brand-teal: #0ea5a3;
  --brand-teal-dark: #0b6e6c;
  --brand-indigo: #4f46e5;
  --brand-indigo-dark: #3730a3;
  --brand-gradient: linear-gradient(135deg, #0f172a 0%, #134e4a 55%, #0f2f4f 100%);
  --accent-gradient: linear-gradient(135deg, #14b8a6 0%, #6366f1 100%);

  /* Surfaces */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e5e9f0;
  --border-strong: #d7dce6;

  /* Text */
  --text: #101828;
  --text-muted: #667085;
  --text-faint: #98a2b3;
  --text-on-dark: #e6f4f3;
  --text-on-dark-muted: #9fc4c1;

  /* Status */
  --success: #12b76a;
  --success-bg: #ecfdf3;
  --danger: #f04438;
  --danger-bg: #fef3f2;
  --warning: #f79009;
  --warning-bg: #fffaeb;
  --info: #4f46e5;
  --info-bg: #eef2ff;

  /* Shape */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --sidebar-w: 264px;
  --topbar-h: 68px;
  --topbar-bg: rgba(244, 246, 250, .85);
  --skeleton-base: var(--surface-alt);
  --skeleton-shine: #eef1f6;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

/* ----------------------------------------------------------------------
   Dark theme — toggled via data-theme="dark" on <html> (see app.js);
   sidebar stays on the same dark gradient in both themes, so only the
   workspace surfaces/text/borders need overriding here.
   ---------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1220;
  --surface: #111a2c;
  --surface-alt: #182234;
  --border: #253247;
  --border-strong: #324361;

  --text: #e7ebf3;
  --text-muted: #9aa7bd;
  --text-faint: #6b7890;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);

  --topbar-bg: rgba(11, 18, 32, .82);
  --skeleton-base: #182234;
  --skeleton-shine: #202c42;

  --success-bg: rgba(18, 183, 106, .16);
  --danger-bg: rgba(240, 68, 56, .16);
  --warning-bg: rgba(247, 144, 9, .16);
  --info-bg: rgba(99, 102, 241, .2);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
:focus-visible { outline: 2px solid var(--brand-indigo); outline-offset: 2px; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); margin: 0 0 4px; color: var(--text); font-weight: 700; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 20px; letter-spacing: -0.01em; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
a { color: var(--brand-indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); }
ul, ol { margin: 0; padding-left: 20px; }
::selection { background: rgba(79, 70, 229, .18); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd3e0; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #aab3c4; }

/* ----------------------------------------------------------------------
   App shell
   ---------------------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand-gradient);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .25s ease;
  box-shadow: 2px 0 24px rgba(0,0,0,.15);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  box-shadow: 0 4px 14px rgba(20, 184, 166, .35);
  flex-shrink: 0;
}

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 12px 12px; }
.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-on-dark-muted);
  padding: 16px 12px 6px;
  font-weight: 600;
}
/* Collapsible sidebar groups (one per platform) — the MAIN level: a bold header with a coloured icon tile.
   The pages inside a group are the INNER level: indented under a guide line, lighter and smaller (see below). */
details.nav-group { --g: #2dd4bf; margin: 6px 0 2px; }
details.nav-group[data-group="shopify"]  { --g: #95bf47; }
details.nav-group[data-group="zoho"]     { --g: #ff6b6b; }
details.nav-group[data-group="xero"]     { --g: #22b8e8; }
details.nav-group[data-group="extensiv"] { --g: #fbab2e; }
details.nav-group[data-group="nzyme"]    { --g: #b196ff; }
details.nav-group[data-group="compare"]  { --g: #2dd4bf; }
details.nav-group[data-group="sync"]     { --g: #ffd24d; }
details.nav-group[data-group="pricing"]  { --g: #f78fc4; }
details.nav-group > summary.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 8px 10px;
  margin: 0;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  transition: background .15s ease;
}
details.nav-group > summary.sidebar-section::-webkit-details-marker { display: none; }
details.nav-group > summary.sidebar-section > span { display: inline-flex; align-items: center; gap: 10px; }
details.nav-group > summary.sidebar-section > span > i {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--g);
  background: color-mix(in srgb, var(--g) 20%, transparent);
}
details.nav-group > summary.sidebar-section:hover { background: rgba(255,255,255,.1); }
details.nav-group .nav-chevron { font-size: 11px; opacity: .7; transition: transform .15s ease; }
details.nav-group:not([open]) .nav-chevron { transform: rotate(-90deg); }
details.nav-group[data-has-active="1"] > summary.sidebar-section { background: color-mix(in srgb, var(--g) 16%, rgba(255,255,255,.04)); }
/* INNER level: the pages inside a group */
details.nav-group > .sidebar-link {
  margin: 1px 0 1px 23px;
  padding: 7px 10px 7px 14px;
  border-left: 1px solid rgba(255,255,255,.14);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  font-weight: 400;
  gap: 9px;
  color: rgba(230, 244, 243, .7);
}
details.nav-group > .sidebar-link i { font-size: 13px; width: 15px; opacity: .55; }
details.nav-group > .sidebar-link:hover { transform: none; background: rgba(255,255,255,.07); border-left-color: var(--g); }
details.nav-group > .sidebar-link.active {
  background: color-mix(in srgb, var(--g) 18%, transparent);
  border-left: 2px solid var(--g);
  padding-left: 13px;
  color: #fff;
  font-weight: 600;
}
details.nav-group > .sidebar-link.active i { opacity: 1; color: var(--g); }
details.nav-group > .sidebar-link.active::before { display: none; }
/* MAIN level entries that are not groups (Dashboard, Single SKU Lookup): bold, with an icon tile like the group headers. */
.sidebar-scroll > .sidebar-link {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  padding: 8px 10px;
  gap: 10px;
}
.sidebar-scroll > .sidebar-link > i {
  width: 26px; height: 26px; border-radius: 8px; opacity: 1;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--brand-teal);
  background: rgba(20, 184, 166, .16);
}
.sidebar-scroll > .sidebar-link:hover > i { transform: none; }
/* Small caps labels ("Overview", "System") are only dividers between blocks, clearly quieter than group headers. */
.sidebar-scroll > div.sidebar-section { padding: 14px 10px 5px; font-size: 10.5px; opacity: .8; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(230, 244, 243, .78);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-link i { font-size: 16px; width: 18px; text-align: center; opacity: .85; transition: opacity .15s ease, transform .15s ease; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; transform: translateX(2px); }
.sidebar-link:hover i { opacity: 1; }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(20, 184, 166, .22), rgba(20, 184, 166, .06));
  color: #fff;
  font-weight: 600;
}
.sidebar-link.active i { opacity: 1; }
.sidebar-link.active::before {
  content: '';
  position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand-teal), var(--brand-indigo));
  box-shadow: 0 0 10px rgba(20, 184, 166, .7);
}

.pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: default;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.pill-ok { color: var(--success); background: var(--success-bg); border-color: transparent; }
.pill-ok .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(18,183,106,.2); }
.pill-off { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.pill-off .dot { background: var(--danger); }
a.pill { cursor: pointer; }
a.pill:hover { filter: brightness(0.96); text-decoration: none; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user .who { min-width: 0; flex: 1; }
.sidebar-user .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 11px; color: var(--text-on-dark-muted); text-transform: capitalize; }
.sidebar-user .logout-btn { color: var(--text-on-dark-muted); font-size: 16px; flex-shrink: 0; }
.sidebar-user .logout-btn:hover { color: #fff; }

.sidebar-close, .sidebar-toggle { display: none; }

/* Main column */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; white-space: nowrap; }
.topbar-sub { color: var(--text-muted); font-size: 12.5px; }
.hamburger, .theme-toggle-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  align-items: center; justify-content: center;
  font-size: 18px; color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-toggle-btn { display: inline-flex; }
.theme-toggle-btn:hover, .hamburger:hover { background: var(--surface-alt); }
.theme-toggle-btn:active { transform: scale(.92); }
.theme-toggle-btn .bi-sun { display: none; }
:root[data-theme="dark"] .theme-toggle-btn .bi-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle-btn .bi-moon-stars { display: none; }
.hamburger { display: none; }

/* ----------------------------------------------------------------------
   Notification bell
   ---------------------------------------------------------------------- */
.notif-bell-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-width: 90vw; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 60;
}
.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
}
.notif-item {
  display: block; padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; color: var(--text); cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-alt); text-decoration: none; }
.notif-item.unread { background: var(--info-bg); }
.notif-item .notif-time { display: block; color: var(--text-faint); font-size: 11px; margin-top: 3px; }

/* ----------------------------------------------------------------------
   SKU autocomplete (PO Generation)
   ---------------------------------------------------------------------- */
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto; z-index: 50;
}
.autocomplete-item { padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--surface-alt); }
.autocomplete-item .ac-sku { font-family: var(--font-mono); font-weight: 700; }
.autocomplete-item .ac-title { color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.autocomplete-item .ac-meta { color: var(--text-faint); font-size: 11px; margin-top: 2px; }

.content { padding: 26px 28px 60px; flex: 1; max-width: 1440px; width: 100%; margin: 0 auto; animation: content-in .35s ease; }
@keyframes content-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

a.card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .2s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--brand-teal); box-shadow: var(--shadow); text-decoration: none; }

.footer {
  padding: 18px 28px 28px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  z-index: 39;
}

/* ----------------------------------------------------------------------
   Cards & stat tiles
   ---------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: background-color .2s ease, border-color .2s ease;
}
.card + .card { margin-top: 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.chart-wrap { position: relative; height: 280px; width: 100%; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-gradient);
  opacity: .85;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  margin-bottom: 14px;
  background: var(--accent-gradient);
}
.stat-card.teal::before, .stat-card.teal .icon { background: linear-gradient(135deg, #14b8a6, #0b6e6c); }
.stat-card.indigo::before, .stat-card.indigo .icon { background: linear-gradient(135deg, #818cf8, #4338ca); }
.stat-card.amber::before, .stat-card.amber .icon { background: linear-gradient(135deg, #fbbf24, #b45309); }
.stat-card.rose::before, .stat-card.rose .icon { background: linear-gradient(135deg, #fb7185, #be123c); }
.stat-card.cyan::before, .stat-card.cyan .icon { background: linear-gradient(135deg, #22d3ee, #0e7490); }
.stat-card.violet::before, .stat-card.violet .icon { background: linear-gradient(135deg, #c4b5fd, #6d28d9); }
.stat-card .icon { box-shadow: 0 6px 16px -4px rgba(0,0,0,.25); }
.stat-card .value { font-family: var(--font-display); font-size: 27px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.stat-card .meta { color: var(--text-faint); font-size: 11.5px; margin-top: 8px; }

/* ----------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 13.5px; font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .12s ease, transform .05s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-gradient); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.28); }
.btn-primary:hover { filter: brightness(1.06); text-decoration: none; transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); text-decoration: none; }
.btn-outline { background: transparent; color: var(--brand-indigo); border-color: rgba(79,70,229,.35); }
.btn-outline:hover { background: var(--info-bg); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 13px 22px; font-size: 14.5px; }

.hidden { display: none !important; }
.tab-btn {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 10px 4px; margin-bottom: -1px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; font-family: var(--font-body);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--info); border-bottom-color: var(--info); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-flex; }
.btn.is-loading .btn-label { opacity: .7; }

/* ----------------------------------------------------------------------
   Forms
   ---------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.input, .select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-indigo);
  box-shadow: 0 0 0 3px rgba(79,70,229,.14);
}
.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--brand-indigo); }

/* ----------------------------------------------------------------------
   Tables
   ---------------------------------------------------------------------- */
.supplier-group {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden;
}
.supplier-group summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; cursor: pointer; list-style: none;
  background: var(--surface-alt); font-weight: 700; font-size: 13.5px;
  user-select: none;
}
.supplier-group summary::-webkit-details-marker { display: none; }
.supplier-group summary::before {
  content: '▸'; margin-right: 10px; color: var(--text-muted);
  display: inline-block; transition: transform .15s ease;
}
.supplier-group[open] summary::before { transform: rotate(90deg); }
.supplier-group .table-wrap { border: none; border-radius: 0; border-top: 1px solid var(--border); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-alt);
  text-align: left;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 700;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: var(--surface-alt); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-mono { font-family: var(--font-mono); font-size: 12.5px; }
.cell-muted { color: var(--text-muted); }
.cell-num { text-align: right; font-family: var(--font-mono); }
.row-flagged { background: var(--danger-bg); }
.row-flagged:hover { background: #fde4e2 !important; }

.thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--surface-alt); border: 1px solid var(--border); }

/* ----------------------------------------------------------------------
   Badges
   ---------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ----------------------------------------------------------------------
   Empty / loading states
   ---------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty-state i { font-size: 34px; color: var(--text-faint); margin-bottom: 12px; display: block; }
.empty-state h3 { color: var(--text); margin-bottom: 4px; }

.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 0; color: var(--text-muted); font-size: 13px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: rgba(79,70,229,.25); border-top-color: var(--brand-indigo); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 37%, var(--skeleton-base) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 8px; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ----------------------------------------------------------------------
   Toasts
   ---------------------------------------------------------------------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: var(--text); color: #fff;
  padding: 13px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .2s ease;
}
.toast i { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.toast.success { background: #0f5132; }
.toast.error { background: #7a271a; }
.toast.info { background: #1e293b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------------
   Modal
   ---------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 150; padding: 20px;
}
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: 24px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-lg { max-width: 760px; max-height: calc(100vh - 60px); display: flex; flex-direction: column; }
.modal-body-scroll { overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.detail-label { color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.detail-item .detail-value { font-size: 14px; font-weight: 600; word-break: break-word; }
.detail-section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.detail-section-title:first-child { margin-top: 0; }
.comment-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: var(--surface-alt); }
.comment-item .comment-date { color: var(--text-muted); font-size: 11.5px; margin-bottom: 4px; }
.comment-item .comment-message { font-size: 13.5px; white-space: pre-wrap; }
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: var(--surface-alt); }

/* ----------------------------------------------------------------------
   Auth pages
   ---------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-visual {
  background: var(--brand-gradient);
  color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.auth-visual::before {
  content: '';
  position: absolute; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(20,184,166,.35), transparent 70%);
  top: -140px; right: -140px;
}
.auth-visual::after {
  content: '';
  position: absolute; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.3), transparent 70%);
  bottom: -120px; left: -80px;
}
.auth-visual .brand { position: relative; display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.auth-visual .pitch { position: relative; max-width: 420px; }
.auth-visual .pitch h1 { font-size: 32px; color: #fff; line-height: 1.2; }
.auth-visual .pitch p { color: var(--text-on-dark-muted); font-size: 14.5px; margin-top: 10px; }
.auth-visual .stats-row { position: relative; display: flex; gap: 28px; }
.auth-visual .stats-row div b { display: block; font-family: var(--font-display); font-size: 22px; }
.auth-visual .stats-row div span { font-size: 12px; color: var(--text-on-dark-muted); }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.auth-form-box { width: 100%; max-width: 380px; }
.auth-form-box h1 { font-size: 25px; }
.auth-form-box .subtitle { color: var(--text-muted); font-size: 13.5px; margin-bottom: 26px; }
.auth-alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start; }
.auth-alert.error { background: var(--danger-bg); color: #b42318; }
.auth-alert.success { background: var(--success-bg); color: #067647; }
.auth-alert.info { background: var(--surface-alt); color: var(--text-muted); }

/* ----------------------------------------------------------------------
   Misc utility
   ---------------------------------------------------------------------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 12.5px; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.tag-pill { display: inline-block; background: var(--surface-alt); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; font-size: 11px; color: var(--text-muted); margin: 2px 3px 0 0; }
.hero-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.field-array-row { display: grid; grid-template-columns: 1fr 140px 40px; gap: 10px; margin-bottom: 8px; align-items: center; }

/* ----------------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 15px; }
  .card { padding: 16px; }
  .field-array-row { grid-template-columns: 1fr 100px 34px; }
  h1 { font-size: 21px; }
  .hero-row .btn { flex: 1; }
}

/* ----------------------------------------------------------------------
   Mobile card tables — below 700px, wide data tables (Sales, Stock Sync,
   Inventory Report, PO Planner, etc.) drop the horizontal-scroll table
   and stack each row as a card instead. Cells get their column header as
   a label via a data-label attribute that app.js copies from the
   table's own <thead> automatically (see labelDataTables in app.js) —
   individual pages don't need to set it themselves.
   ---------------------------------------------------------------------- */
@media (max-width: 700px) {
  .table-wrap { border: none; overflow: visible; }
  table.data-table, table.data-table tbody, table.data-table tr { display: block; width: 100%; }
  table.data-table thead { display: none; }
  table.data-table tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    padding: 4px 14px;
  }
  table.data-table tbody tr:hover { background: var(--surface); }
  table.data-table tbody td {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    text-align: right;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
    white-space: normal;
    word-break: break-word;
  }
  table.data-table tbody td:last-child { border-bottom: none; }
  table.data-table tbody td::before {
    content: attr(data-label);
    margin-right: auto;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  table.data-table tbody td:not([data-label]) ::before,
  table.data-table tbody td[data-label=""]::before { content: none; }
  /* Placeholder rows (empty state / loading) span the whole card, no label */
  table.data-table tbody td[colspan] { display: block; text-align: center; }
  table.data-table tbody td[colspan]::before { content: none; }
}


/* Date range filter (assets/js/app.js: createDateRange / setupDateRange) */
.date-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 3px 8px 3px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.date-range.active { border-color: var(--brand-teal); box-shadow: 0 0 0 2px rgba(14, 165, 163, .15); }
.date-range-label { font-size: 12px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.date-range .input { padding-top: 6px; padding-bottom: 6px; height: auto; border-color: transparent; background: transparent; width: auto; min-width: 0; }
.date-range select.input { padding-right: 24px; }
.date-range input[type="date"].input { width: 138px; }
.date-range-sep { color: var(--text-muted); }
@media (max-width: 640px) { .date-range { width: 100%; } .date-range input[type="date"].input { flex: 1; min-width: 120px; } }

.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warning); font-weight: 600; }

/* SKU details window (assets/js/sku_detail.js) */
.sku-detail-tabs { display: flex; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.sku-detail-tabs .tab-btn { white-space: nowrap; }
#skuDetailBody { padding: 18px 22px 22px; }
.sku-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.sku-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: var(--surface); }
.sku-card-title { font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.sku-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; }
.sku-card .sku-kv { grid-template-columns: 1fr 1fr; }
.sku-detail-link { font-weight: 600; text-decoration: none; }
.sku-detail-link:hover { text-decoration: underline; }
@media (max-width: 640px) { .sku-card .sku-kv { grid-template-columns: 1fr; } }
