/* Stocks dashboard — palette from the dataviz reference instance (light + dark). */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --orange: #eb6834;
  --yellow: #eda100;
  --aqua: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 16px rgba(11,11,11,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --page: #0d0d0d; --surface: #1a1a19; --text: #fff; --text-2: #c3c2b7;
    --muted: #898781; --grid: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,.10);
    --accent: #3987e5; --orange: #d95926; --yellow: #c98500; --aqua: #199e70;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0d0d0d; --surface: #1a1a19; --text: #fff; --text-2: #c3c2b7;
  --muted: #898781; --grid: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,.10);
  --accent: #3987e5; --orange: #d95926; --yellow: #c98500; --aqua: #199e70;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* CSS display must not override the HTML attribute */

html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.xsmall { font-size: 11px; }
.accent { color: var(--accent); }
.tabular { font-variant-numeric: tabular-nums; }
.row-gap { display: flex; gap: 8px; }

/* Buttons */
.btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { border-color: var(--baseline); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn-secondary { background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 6%, transparent); border-color: transparent; }

.input {
  font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: transparent; }
.input-date, .input-select { width: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.form-error { color: var(--critical); font-size: 12px; }

/* Login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 320px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.brand-lg { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.topbar-right { display: flex; gap: 6px; }

/* Layout */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; padding: 18px 20px; max-width: 1400px; margin: 0 auto; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

/* Sidebar */
.sidebar { position: sticky; top: 74px; }
.add-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cabinet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cabinet-item {
  display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
}
.cabinet-item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.cabinet-item.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cabinet-name { font-weight: 600; }
.cabinet-fp { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Main panel */
.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.meta-line { margin-top: 4px; color: var(--text-2); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.history-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.tile-bar { height: 3px; border-radius: 4px; background: var(--accent); width: 40px; }
.tile-bar.t-orange { background: var(--orange); }
.tile-bar.t-yellow { background: var(--yellow); }
.tile-bar.t-aqua { background: var(--aqua); }

/* Controls */
.controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 2px; background: color-mix(in srgb, var(--text) 5%, transparent); padding: 3px; border-radius: 9px; }
.tab { font: inherit; font-size: 13px; border: none; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters .input[type="search"] { min-width: 220px; }

/* Table */
.table-card { padding: 0; overflow: hidden; }
.table-status { padding: 10px 16px 0; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 9px 16px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { font-weight: 600; }
.data-table .dim { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 16px; }

/* Sync runs */
.runs-list { display: flex; flex-direction: column; gap: 8px; }
.run-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.run-main { min-width: 0; }
.run-title { font-size: 13px; font-weight: 600; }
.run-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.run-time { font-size: 12px; color: var(--muted); white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.b-good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.b-run { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.badge.b-wait { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.badge.b-bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.badge.b-neutral { color: var(--text-2); background: color-mix(in srgb, var(--text) 8%, transparent); }

/* View toggle */
.viewtoggle { display: inline-flex; gap: 2px; background: color-mix(in srgb, var(--text) 5%, transparent); padding: 3px; border-radius: 9px; margin-left: auto; }
.vbtn { font: inherit; font-size: 12px; border: none; background: transparent; color: var(--text-2); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.vbtn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Product cards */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.pcard-img { display: block; aspect-ratio: 3 / 4; background: color-mix(in srgb, var(--text) 4%, transparent); overflow: hidden; }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.pcard-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.pcard-vendor { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-brand { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-nm { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pcard-stats { display: flex; gap: 14px; margin-top: 6px; }
.pstat { display: flex; flex-direction: column; }
.pstat span { font-size: 11px; color: var(--muted); }
.pstat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.pager.card { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--page); padding: 10px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 20; max-width: 90vw;
}
.toast.err { background: var(--critical); color: #fff; }
