/* AI E-Commerce Analyst Bot — design system
   Palette validated per the dataviz method: categorical slots in fixed order,
   hairline chrome, thin marks, status colors reserved for state. */

:root {
  color-scheme: light;
  --surface-1: #ffffff;
  --surface-2: #f9f9f9;
  --surface-3: #f2f2f2;
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-tertiary: #8a8a8a;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: #e2e2e2;
  --gridline: #e7e7e7;
  --baseline: #c2c2c2;

  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --series-4: #f2a600;
  --series-5: #ee7fac;
  --series-6: #008a17;
  --series-7: #6a4ce2;
  --series-8: #ec4647;

  --good: #0aac23;
  --good-text: #006c10;
  --warning: #fbb315;
  --serious: #f18a59;
  --critical: #dc3c3d;

  --accent: #257de0;
  --accent-soft: #e8f1fc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #191919;
    --surface-2: #0b0b0b;
    --surface-3: #232323;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --text-tertiary: #7a7a7a;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: #303030;
    --gridline: #303030;
    --baseline: #474747;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --series-4: #d28e05;
    --series-5: #e24d8b;
    --series-6: #0aac23;
    --series-7: #9887ef;
    --series-8: #eb6263;
    --good-text: #53c556;
    --accent: #338ced;
    --accent-soft: #16283c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #191919;
  --surface-2: #0b0b0b;
  --surface-3: #232323;
  --text-primary: #efefef;
  --text-secondary: #9c9c9c;
  --text-tertiary: #7a7a7a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: #303030;
  --gridline: #303030;
  --baseline: #474747;
  --series-1: #338ced;
  --series-2: #e76624;
  --series-3: #00a888;
  --series-4: #d28e05;
  --series-5: #e24d8b;
  --series-6: #0aac23;
  --series-7: #9887ef;
  --series-8: #eb6263;
  --good-text: #53c556;
  --accent: #338ced;
  --accent-soft: #16283c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }

/* ---------------- layout ---------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface-1); border-right: 1px solid var(--border);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brandmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brandmark .dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--series-1), var(--series-7));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
.brandmark .name { font-weight: 650; font-size: 13.5px; line-height: 1.2; }
.brandmark .sub { color: var(--text-tertiary); font-size: 11px; }
.navgroup { margin-bottom: 14px; }
.navlabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-tertiary); padding: 6px 10px 4px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px;
  color: var(--text-primary); font-size: 13px; text-decoration: none; margin-bottom: 1px;
}
.nav a:hover { background: var(--surface-3); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ico { width: 16px; text-align: center; opacity: .75; font-size: 13px; }
.main { padding: 22px 28px 60px; max-width: 1400px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------------- filters ---------------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filters label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; }
.filters .spacer { flex: 1; }
select, textarea,
input[type="text"], input[type="search"], input[type="password"],
input[type="number"], input[type="email"], input[type="date"] {
  font-family: var(--font); font-size: 13px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 6px 9px; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly], input:disabled, select:disabled { background: var(--surface-3);
  color: var(--text-secondary); cursor: not-allowed; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 600; border-radius: 7px;
  padding: 7px 13px; border: 1px solid var(--border-strong); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { border-color: var(--critical); color: var(--critical); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- cards & grid ---------------- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.split-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.split-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 1100px) {
  .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split-2-1, .grid.split-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 16px 14px 40px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: 1fr; }
}
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; }
.card-head .hint { color: var(--text-tertiary); font-size: 11.5px; }
.card-head h2 { font-size: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-tertiary); font-weight: 650; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }

/* ---------------- stat tiles ---------------- */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.stat .value.big { font-size: 30px; }
.stat .delta { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.stat .delta .vs { color: var(--text-tertiary); }
.hero { padding: 4px 0 0; }
.hero .label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.hero .value { font-size: 48px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.05; }
.hero .meta { color: var(--text-secondary); font-size: 12.5px; margin-top: 6px; }

.delta.good { color: var(--good-text); }
.delta.bad { color: var(--critical); }
.delta.flat { color: var(--text-secondary); }
.delta .arrow { font-size: 11px; }

/* ---------------- badges / pills ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-3); color: var(--text-secondary); white-space: nowrap; }
.badge .dotmark { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge.confirmed { color: var(--good-text); background: rgba(10,172,35,.10); border-color: rgba(10,172,35,.25); }
.badge.likely { color: #8a5a00; background: rgba(251,179,21,.14); border-color: rgba(251,179,21,.35); }
.badge.hypothesis { color: var(--text-secondary); background: var(--surface-3); }
.badge.critical { color: var(--critical); background: rgba(220,60,61,.10); border-color: rgba(220,60,61,.3); }
.badge.warning { color: #8a5a00; background: rgba(251,179,21,.14); border-color: rgba(251,179,21,.35); }
.badge.info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge.pending { color: #8a5a00; background: rgba(251,179,21,.14); border-color: rgba(251,179,21,.35); }
.badge.approved, .badge.executed, .badge.succeeded, .badge.done { color: var(--good-text);
  background: rgba(10,172,35,.10); border-color: rgba(10,172,35,.25); }
.badge.rejected, .badge.failed { color: var(--critical); background: rgba(220,60,61,.10);
  border-color: rgba(220,60,61,.3); }
.badge.expired { color: var(--text-tertiary); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.likely,
  :root:not([data-theme="light"]) .badge.warning,
  :root:not([data-theme="light"]) .badge.pending { color: var(--warning); }
}
:root[data-theme="dark"] .badge.likely,
:root[data-theme="dark"] .badge.warning,
:root[data-theme="dark"] .badge.pending { color: var(--warning); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-tertiary); font-weight: 650; padding: 8px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .name { font-weight: 550; }
table.data .muted { color: var(--text-tertiary); font-size: 11.5px; }
.legend-inline { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.linemark { width: 14px; height: 2px; border-radius: 2px; flex: none; }

/* ---------------- charts ---------------- */
.chart-card { position: relative; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .axis-label { fill: var(--text-secondary); font-size: 10.5px;
  font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--gridline); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .crosshair { stroke: var(--baseline); stroke-width: 1; pointer-events: none; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.chart-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 30; min-width: 132px;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow);
  font-size: 12px; opacity: 0; transition: opacity .1s; transform: translate(-50%, -110%);
}
.chart-tooltip.on { opacity: 1; }
.chart-tooltip .tt-title { color: var(--text-secondary); font-size: 11px; margin-bottom: 5px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; justify-content: space-between;
  padding: 1px 0; }
.chart-tooltip .tt-row .k { display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-secondary); }
.chart-tooltip .tt-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-line { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.chart-tooltip .tt-box { width: 9px; height: 9px; border-radius: 2px; flex: none; }
details.table-view { margin-top: 10px; border-top: 1px solid var(--gridline); padding-top: 8px; }
details.table-view summary { cursor: pointer; font-size: 11.5px; color: var(--text-secondary);
  list-style: none; user-select: none; }
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view summary::before { content: "▸ "; }
details.table-view[open] summary::before { content: "▾ "; }
details.table-view .table-wrap { margin-top: 8px; max-height: 260px; overflow: auto; }

/* ---------------- misc blocks ---------------- */
.callout { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface-2); }
.callout.principle { border-left: 3px solid var(--accent); }
.callout.warn { border-left: 3px solid var(--warning); }
.callout.danger { border-left: 3px solid var(--critical); }
.callout .title { font-weight: 650; margin-bottom: 3px; }
.narrative p { font-size: 13.5px; line-height: 1.62; color: var(--text-primary); }
.narrative p:last-child { margin-bottom: 0; }
.finding { border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 13px; margin-bottom: 9px; background: var(--surface-1); }
.finding .head { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.finding .head .t { font-weight: 620; font-size: 13px; }
.finding ul { margin: 4px 0 0; padding-left: 17px; }
.finding li { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 2px; }
.evidence { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.evidence .ev { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 7px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--text-tertiary); padding: 28px 12px; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.timeline { border-left: 2px solid var(--gridline); margin-left: 6px; padding-left: 14px; }
.timeline .ev { position: relative; padding-bottom: 12px; font-size: 12.5px; }
.timeline .ev::before { content: ""; position: absolute; left: -20px; top: 4px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface-1); }
.timeline .ev .when { color: var(--text-tertiary); font-size: 11px; }
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.freshness { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  color: var(--text-secondary); }
.freshness .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.freshness.stale .dot { background: var(--warning); }
footer.foot { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border);
  color: var(--text-tertiary); font-size: 11.5px; display: flex; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; }
