/* Retail Dashboard Design System v1.0 — shared, local-only design tokens. */
:root {
  --rd-canvas: #f4f6f8;
  --rd-surface: #ffffff;
  --rd-text: #202a36;
  --rd-muted: #596777;
  --rd-line: #dce2e8;
  --rd-line-soft: #edf0f3;
  --rd-header: #f7f9fb;
  --rd-accent: #245fba;
  --rd-selected: #edf4ff;
  --rd-positive: #187048;
  --rd-negative: #b52d36;
  --rd-warning: #925b08;
  --rd-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --rd-font-small: 12px;
  --rd-font-body: 13px;
  --rd-font-section: 15px;
  --rd-font-title: 22px;
  --rd-font-metric: 26px;
  --rd-space-1: 4px;
  --rd-space-2: 8px;
  --rd-space-3: 12px;
  --rd-space-4: 16px;
  --rd-space-6: 24px;
  --rd-control-height: 34px;
  --rd-radius-control: 4px;
  --rd-radius-panel: 6px;
}

/* Clothing adapter. Token names above are shared across retail modules. */
:root {
  --bg: var(--rd-canvas); --panel: var(--rd-surface); --ink: var(--rd-text);
  --muted: var(--rd-muted); --line: var(--rd-line); --accent: var(--rd-accent);
  --good: var(--rd-positive); --bad: var(--rd-negative); --warn: var(--rd-warning);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--rd-font-body)/1.5 var(--rd-font); }
button, input, select { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { min-width: 0; height: var(--rd-control-height); padding: 0 10px; border: 1px solid var(--line); border-radius: var(--rd-radius-control); color: var(--ink); background: var(--panel); }
button { cursor: pointer; font-weight: 500; }
button:hover { border-color: var(--accent); background: var(--rd-selected); }
button:disabled { cursor: wait; opacity: .55; }
:is(button, a, input, select, summary, .table-wrap):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell { width: min(1600px, calc(100% - 48px)); margin: auto; padding: 20px 0 32px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0; }
h1 { font-size: var(--rd-font-title); line-height: 1.4; }
h2 { font-size: var(--rd-font-section); }
h3 { font-size: 14px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 0 16px; }
.eyebrow { margin: 0 0 4px; font-size: var(--rd-font-small); color: var(--muted); }
.eyebrow span { margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--line); }
.source { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--muted); font-size: var(--rd-font-small); }
.sync-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; }
.sync-status { display: inline-flex; align-items: baseline; gap: 6px; color: var(--good); }
.sync-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.sync-status.is-syncing { color: var(--warn); }
.sync-status.is-error { color: var(--bad); }
.plain-link { height: auto; border: 0; padding: 2px 0; color: var(--accent); background: transparent; }
.plain-link:hover { background: transparent; text-decoration: underline; }
.filters { display: grid; grid-template-columns: 155px 155px minmax(160px,1fr) minmax(160px,1fr) auto; gap: 12px; align-items: end; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--rd-radius-panel); background: var(--panel); }
label { display: grid; gap: 4px; color: var(--muted); font-size: var(--rd-font-small); }
input, select { width: 100%; color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin: 12px 0 0; padding: 14px 0; border: 1px solid var(--line); border-radius: var(--rd-radius-panel); background: var(--panel); }
.kpis article { min-width: 0; padding: 0 20px; border-right: 1px solid var(--line); }
.kpis article:last-child { border: 0; }
.kpis span, .kpis em { display: block; color: var(--muted); font-size: var(--rd-font-small); font-style: normal; }
.kpis strong { display: block; margin: 4px 0; font-size: var(--rd-font-metric); font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.section-nav { display: flex; flex-wrap: wrap; gap: 24px; padding: 0 4px; margin-top: 12px; border-bottom: 1px solid var(--line); }
.section-nav a { padding: 10px 0; color: var(--ink); font-weight: 500; }
.section-nav a:hover { color: var(--accent); }
.drill-context { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 4px; font-size: var(--rd-font-small); color: var(--muted); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--rd-radius-panel); background: var(--panel); }
.panel-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-title span { color: var(--muted); font-size: var(--rd-font-small); overflow-wrap: anywhere; }
.panel-title button { color: #fff; background: var(--accent); border-color: var(--accent); }
.panel-title button:hover { background: #1c4f9c; }
.table-wrap { overflow: auto; max-height: 440px; overscroll-behavior: contain; border-radius: 0 0 var(--rd-radius-panel) var(--rd-radius-panel); }
.table-wrap.detail { max-height: 520px; }
table { width: 100%; border-spacing: 0; border-collapse: separate; font-size: var(--rd-font-body); font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--rd-line-soft); white-space: nowrap; text-align: left; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: var(--rd-header); font-size: var(--rd-font-small); font-weight: 500; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--rd-header); }
tr.is-clickable { cursor: pointer; }
tr.is-active { background: var(--rd-selected); }
tr.is-active:hover { background: #e2edfd; }
#storeTable :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); border-right: 1px solid var(--line); }
#storeTable th:first-child { z-index: 3; background: var(--rd-header); }
#storeTable tr.is-active td:first-child { background: var(--rd-selected); }
.table-action { display: inline; height: auto; border: 0; padding: 0; color: var(--accent); background: transparent; font-weight: 500; text-align: left; }
.table-action:hover { background: transparent; text-decoration: underline; }
.comparison-note { margin: 0; padding: 8px 16px 4px; font-size: var(--rd-font-small); color: var(--muted); line-height: 1.6; }
.method-note { padding: 0 16px 8px; color: var(--muted); font-size: var(--rd-font-small); }
.method-note summary { width: fit-content; cursor: pointer; }
.method-note .comparison-note { padding: 8px 0 0; }
#storeTable small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--rd-font-small); white-space: normal; max-width: 170px; }
.record-disclosure { margin-top: 12px; scroll-margin-top: 12px; }
.record-disclosure > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; }
.record-disclosure > summary > span { margin-left: 12px; color: var(--muted); font-size: var(--rd-font-small); font-weight: 400; }
.record-disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.record-disclosure > .panel { border: 0; }
.record-disclosure > p, .inventory-panel > p, #sourceScopeSummary, #allocationNotice, #detailScope { margin: 0; padding: 10px 16px; color: var(--muted); font-size: var(--rd-font-small); line-height: 1.6; }
.inventory-panel { margin: 0; }
#sourceScopePanel { margin-top: 12px; padding: 16px; }
#sourceScopePanel h2 { font-size: 14px; }
#sourceScopeSummary { padding: 8px 0; }
#sourceScopePanel summary { padding: 8px 0; cursor: pointer; font-size: var(--rd-font-small); color: var(--muted); }
.store-list { display: grid; max-height: 430px; overflow: auto; }
.store-list-head, .store-list-row { display: grid; grid-template-columns: minmax(150px,1.4fr) minmax(110px,1fr) 100px 110px; align-items: center; gap: 12px; padding: 10px 16px; }
.store-list-head { position: sticky; top: 0; z-index: 1; background: var(--rd-header); color: var(--muted); font-size: var(--rd-font-small); }
.store-list-row { width: 100%; height: auto; min-height: 54px; border: 0; border-bottom: 1px solid var(--rd-line-soft); border-radius: 0; text-align: left; font-weight: 400; }
.store-list-row.active { background: var(--rd-selected); }
.store-list-row strong, .store-list-row small, .store-list-row em { display: block; }
.store-list-row small, .store-list-row em, .store-stock { font-size: var(--rd-font-small); color: var(--muted); font-style: normal; }
.store-list-row b { font-weight: 500; font-variant-numeric: tabular-nums; }
.store-empty { padding: 16px; }
.pos { color: var(--good); } .neg { color: var(--bad); } .muted { color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 28px 16px; }
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: min(420px,calc(100% - 32px)); }
.login-card { border: 1px solid var(--line); border-radius: var(--rd-radius-panel); padding: 24px; background: var(--panel); }
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.login-form button { color: #fff; background: var(--accent); }
.login-message { color: var(--bad); min-height: 20px; margin: 0; }
@media (max-width: 1100px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .source { align-items: flex-start; }
  .sync-row { justify-content: flex-start; }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)) auto; }
  .filters label:nth-of-type(3) { grid-row: 2; }
  .filters label:nth-of-type(4) { grid-row: 2; }
  .filters > button { grid-column: 3; grid-row: 2; }
  .kpis article { padding: 0 14px; }
}
@media (max-width: 640px) {
  .shell { width: calc(100% - 24px); padding: 12px 0 24px; }
  h1 { font-size: 20px; }
  .filters { padding: 12px; gap: 10px; grid-template-columns: repeat(2,minmax(0,1fr)); }
  input, select, button { min-height: 40px; }
  .plain-link, .table-action { min-height: auto; }
  .filters > button { grid-row: 3; grid-column: 2; justify-self: end; min-width: 70px; }
  .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 0; }
  .kpis article { padding: 12px; }
  .kpis article:nth-child(2) { border-right: 0; }
  .kpis article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .kpis strong { font-size: 23px; }
  .section-nav { gap: 20px; }
  .section-nav a { font-size: var(--rd-font-small); }
  .record-disclosure > summary > span { display: block; margin: 4px 0 0 14px; }
  .panel-title { padding: 12px; }
  .table-wrap { max-height: 420px; }
  .store-list-head, .store-list-row { min-width: 530px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.section-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.panel-title .plain-link { color: var(--accent); background: transparent; border: 0; }
