:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-soft: #86b6ef;
  --compare: #898781;
  --good: #006300;
  --bad: #d03b3b;
  --hover: rgba(11, 11, 11, 0.04);
  --tooltip-bg: #0b0b0b;
  --tooltip-text: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-soft: #1c5cab;
    --compare: #898781;
    --good: #0ca30c;
    --bad: #e66767;
    --hover: rgba(255, 255, 255, 0.05);
    --tooltip-bg: #f0efec;
    --tooltip-text: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-soft: #1c5cab;
  --compare: #898781;
  --good: #0ca30c;
  --bad: #e66767;
  --hover: rgba(255, 255, 255, 0.05);
  --tooltip-bg: #f0efec;
  --tooltip-text: #0b0b0b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 24px clamp(16px, 3vw, 40px) 48px;
  max-width: 1440px;
  margin-inline: auto;
}
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
.sub { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }

button, select, input { font: inherit; color: inherit; }
.ghost {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; color: var(--text-2);
}
.ghost:hover { background: var(--hover); color: var(--text); }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  position: sticky; top: 0; z-index: 10; background: var(--page);
  padding: 8px 0 12px; border-bottom: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 112px; flex: 0 1 auto; }
.field.wide { flex: 1 1 200px; max-width: 300px; }
.flabel { font-size: 12px; color: var(--text-2); }
.filters select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; min-height: 36px; color: var(--text);
}
.filters select:disabled { opacity: 0.5; }

/* Multi-select picker */
.ms { position: relative; }
.ms-btn {
  width: 100%; min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  cursor: pointer; text-align: left;
}
.ms-btn:hover { border-color: var(--axis); }
.ms-btn.active { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--muted); font-size: 11px; }
.ms-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: max(100%, 280px); max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16); padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.ms-panel[hidden] { display: none; }
.ms-search { width: 100%; background: var(--page); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
.ms-presets, .ms-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.ms-presets button, .ms-actions button {
  border: 1px solid var(--border); background: transparent; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; cursor: pointer; color: var(--text-2);
}
.ms-presets button:hover, .ms-actions button:hover { background: var(--hover); color: var(--text); }
.ms-actions button { border: 0; padding: 3px 6px; color: var(--series-1); }
.ms-list { max-height: 300px; overflow-y: auto; margin: 0 -4px; }
.ms-opt { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.ms-opt:hover { background: var(--hover); }
.ms-opt input { margin: 2px 0 0; accent-color: var(--series-1); width: 16px; height: 16px; flex: none; }
.ms-label { display: flex; flex-direction: column; min-width: 0; }
.ms-label small { color: var(--muted); font-size: 11px; }
.ms-empty { color: var(--muted); font-size: 12px; margin: 6px 8px; }
.ms-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--grid); padding-top: 6px; font-size: 12px; color: var(--text-2); }
.ms-done { background: var(--series-1); color: #fff; border: 0; border-radius: 6px; padding: 5px 14px; cursor: pointer; }


/* Supplier 360 */
.logo { height: 44px; width: auto; }
.top-right { display: flex; align-items: center; gap: 8px; }
.refresh-msg { color: var(--text-2); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs [role="tab"] { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--text-2); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--series-1); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 14px; font-size: 13px; min-height: 28px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; background: var(--surface); }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.chip button:hover { color: var(--text); }
.link { background: none; border: 0; color: var(--series-1); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.loading { opacity: 0.5; }
.basis { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .label { color: var(--text-2); font-size: 12px; cursor: help; text-decoration: underline dotted var(--axis); text-underline-offset: 3px; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--text-2); }
.up { color: var(--good); font-weight: 600; }
.down { color: var(--bad); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.span2 { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-note { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tools input[type="search"], .tools select { background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.prior { fill: var(--compare); opacity: 0.45; }
.chart .bar.hl { fill: var(--series-1-soft); }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: var(--hover); }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--tooltip-bg); color: var(--tooltip-text); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.4; max-width: 280px; }
.tip[hidden] { display: none; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin: 0 0 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(0, 38%) 1fr auto; gap: 10px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.hbar:hover { background: var(--hover); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hbar .track { height: 10px; }
.hbar .fill { height: 10px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.table-wrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 12px; cursor: pointer; user-select: none; z-index: 1; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; }
tbody tr:hover { background: var(--hover); }
td.name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.share { display: inline-block; width: 60px; height: 8px; background: var(--grid); border-radius: 4px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--series-1); }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); }
.badge.late { color: var(--bad); border-color: currentColor; }
.badge.crit { color: var(--text); font-weight: 600; }
.muted { color: var(--muted); }
.defs { font-size: 13px; color: var(--text-2); }
.defs dt { font-weight: 600; color: var(--text); margin-top: 8px; }
.defs dd { margin: 2px 0 0; }
.filter-toggle { display: none; margin-left: auto; }
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .filter-toggle { display: inline-block; }
  .filters { display: none; position: static; }
  .filters.open { display: flex; }
  .field, .field.wide { flex: 1 1 140px; max-width: none; }
  .hbar { grid-template-columns: minmax(0, 45%) 1fr auto; }
  .logo { height: 32px; }
}

@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.chart .trend { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.legend .trend-key { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--text-2); vertical-align: 3px; }
.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; padding: 0; border-radius: 50%; border: 1px solid var(--axis); background: transparent; color: var(--text-2); font: italic 600 10px/1 Georgia, serif; cursor: pointer; vertical-align: 1px; }
.info:hover, .info:focus-visible { border-color: var(--series-1); color: var(--series-1); outline: none; }
.kpi .label { cursor: default; text-decoration: none; }
th .info { margin-left: 3px; }
.tip { max-width: 320px; }
@media (min-width: 1300px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
