/* ===== Themes ===== */
/* Horizon — default: bright, airy, light sidebar */
:root, [data-skin="horizon"] {
  color-scheme: light;
  --bg: #f4f6fd;
  --bg-grad: radial-gradient(900px 520px at 100% -8%, rgba(91,91,214,.16), transparent 62%), radial-gradient(760px 480px at 18% 112%, rgba(27,175,122,.12), transparent 60%), radial-gradient(600px 400px at 55% 40%, rgba(42,120,214,.06), transparent 70%);
  --panel: rgba(255,255,255,.82);
  --panel-2: #f6f7fc;
  --sidebar: rgba(255,255,255,.72);
  --border: #e3e6f3;
  --text: #141a33;
  --text-2: #4a5272;
  --muted: #747c99;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --grid: rgba(20,26,51,.07);
  --good: #13854e; --warn: #a86b00; --bad: #c8333a;
  --shadow: 0 1px 2px rgba(20,26,51,.04), 0 10px 30px rgba(60,64,140,.08);
  --side-text: #3d4566; --side-strong: #141a33; --side-muted: #8a91ad; --side-hover: rgba(91,91,214,.07); --side-active: rgba(91,91,214,.12); --side-border: #e3e6f3;
  --card-blur: blur(14px) saturate(140%);
}
[data-skin="midnight"] {
  color-scheme: dark;
  --side-text: #c4cddb; --side-strong: #ffffff; --side-muted: #8794a8; --side-hover: rgba(255,255,255,.06); --side-active: rgba(255,255,255,.09); --side-border: rgba(255,255,255,.06);
  --card-blur: none;
  --bg: #0b1220;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, rgba(57,135,229,.18), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(144,133,233,.12), transparent 60%);
  --panel: #111a2c;
  --panel-2: #16223a;
  --sidebar: #0a1020;
  --border: #22314f;
  --text: #eef2f8;
  --text-2: #a9b4c8;
  --muted: #7a879e;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --grid: rgba(169,180,200,.12);
  --good: #2fbf71; --warn: #e3a008; --bad: #ef5d5d;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.25);
}
[data-skin="aurora"] {
  --side-text: #bfd6d1; --side-strong: #ffffff; --side-muted: #7fa39c; --side-hover: rgba(255,255,255,.06); --side-active: rgba(255,255,255,.09); --side-border: rgba(255,255,255,.06);
  --card-blur: none;
  color-scheme: dark;
  --bg: #0b1517;
  --bg-grad: radial-gradient(1000px 600px at 90% -20%, rgba(47,212,167,.20), transparent 60%), radial-gradient(900px 600px at 0% 120%, rgba(144,133,233,.20), transparent 60%);
  --panel: #102023;
  --panel-2: #142a2e;
  --sidebar: #091214;
  --border: #1f3b40;
  --text: #ecf7f4;
  --text-2: #a7c4be;
  --muted: #73938d;
  --accent: #2fd4a7;
  --accent-ink: #062019;
  --grid: rgba(167,196,190,.12);
  --good: #2fd4a7; --warn: #f2b134; --bad: #ff6b6b;
  --shadow: 0 10px 30px rgba(0,0,0,.3);
}
[data-skin="daylight"] {
  --side-text: #c6d0e2; --side-strong: #ffffff; --side-muted: #8a97ad; --side-hover: rgba(255,255,255,.07); --side-active: rgba(255,255,255,.11); --side-border: rgba(255,255,255,.06);
  --card-blur: none;
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-grad: radial-gradient(1000px 500px at 90% -10%, rgba(42,120,214,.10), transparent 60%);
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --sidebar: #0f1b33;
  --border: #e2e7ef;
  --text: #0d1726;
  --text-2: #475569;
  --muted: #6b7a90;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --grid: rgba(15,27,51,.08);
  --good: #12804a; --warn: #a86b00; --bad: #c62828;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
}
[data-skin="sandstone"] {
  --side-text: #e3d3c2; --side-strong: #ffffff; --side-muted: #a8927c; --side-hover: rgba(255,255,255,.07); --side-active: rgba(255,255,255,.11); --side-border: rgba(255,255,255,.06);
  --card-blur: none;
  color-scheme: light;
  --bg: #f6f1e8;
  --bg-grad: radial-gradient(1000px 500px at 100% -10%, rgba(194,87,26,.10), transparent 60%);
  --panel: #fffdf9;
  --panel-2: #faf5ec;
  --sidebar: #2b1d14;
  --border: #e8dccb;
  --text: #2a1d12;
  --text-2: #6b5847;
  --muted: #8a7764;
  --accent: #c2571a;
  --accent-ink: #ffffff;
  --grid: rgba(42,29,18,.08);
  --good: #3f7d20; --warn: #a86b00; --bad: #b3261e;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 8px 24px rgba(60,40,20,.07);
}
[data-skin="corporate"] {
  --side-text: #d6d4d2; --side-strong: #ffffff; --side-muted: #a19f9d; --side-hover: rgba(255,255,255,.07); --side-active: rgba(255,255,255,.11); --side-border: rgba(255,255,255,.06);
  --card-blur: none;
  color-scheme: light;
  --bg: #f3f2f1;
  --bg-grad: none;
  --panel: #ffffff;
  --panel-2: #faf9f8;
  --sidebar: #252423;
  --border: #e1dfdd;
  --text: #201f1e;
  --text-2: #605e5c;
  --muted: #8a8886;
  --accent: #f2c811;
  --accent-ink: #201f1e;
  --grid: rgba(32,31,30,.08);
  --good: #107c10; --warn: #a86b00; --bad: #a4262c;
  --shadow: 0 1.6px 3.6px rgba(0,0,0,.08), 0 .3px .9px rgba(0,0,0,.06);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  transition: background-color .3s, color .3s;
}
.num, .kpi-value, .tbl td.n { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--sidebar);
  backdrop-filter: var(--card-blur);
  color: var(--side-strong);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--side-border);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  text-align: left; background: transparent; border: 0; color: var(--side-text);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item .ico { width: 20px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--side-hover); color: var(--side-strong); }
.nav-item.active { background: var(--side-active); color: var(--side-strong); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 0 6px; }
.theme-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); font-weight: 700; display: block; margin-bottom: 8px; }
.theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; padding: 0;
  position: relative; overflow: hidden;
}
.swatch span { position: absolute; inset: 0; }
.swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.swatch { border-color: var(--side-border); }
.swatch:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.foot-note { font-size: 11px; color: var(--side-muted); margin-top: 16px; }

/* ===== Main ===== */
.main { padding: 22px 28px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; font-weight: 800; }
.subtitle { margin: 2px 0 0; color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.pill-live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.pill-live.on::before { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.menu-btn { display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; }

/* Filters */
.filters {
  display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)) auto; gap: 10px;
  background: var(--panel); backdrop-filter: var(--card-blur); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 18px;
  box-shadow: var(--shadow); position: sticky; top: 8px; z-index: 5;
}
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.f input, .f select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 9px; min-width: 0; width: 100%;
  font-size: 13px;
}
.f select:focus, .f input:focus, #orderSearch:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.f-btns { flex-direction: row; align-items: flex-end; gap: 8px; }
.quick { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.quick button { background: var(--panel-2); border: 0; padding: 7px 10px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.quick button + button { border-left: 1px solid var(--border); }
.quick button.on { background: var(--accent); color: var(--accent-ink); }
.btn, .btn-ghost { border-radius: 9px; padding: 7px 12px; cursor: pointer; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.btn { background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

/* Views */
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-1 { grid-template-columns: 1fr 1fr; }
.card { background: var(--panel); backdrop-filter: var(--card-blur); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: -.005em; }
.unit { font-size: 11.5px; color: var(--muted); }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall { height: 320px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); backdrop-filter: var(--card-blur); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .85; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 24px; font-weight: 600; margin: 6px 0 4px; letter-spacing: -.02em; white-space: nowrap; }
.kpi-delta { font-size: 12px; font-weight: 600; color: var(--text-2); }
.kpi-delta.up { color: var(--good); }
.kpi-delta.down { color: var(--bad); }
.kpi-delta .vs { color: var(--muted); font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl th .arr { opacity: .6; margin-left: 3px; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell i { display: block; height: 6px; border-radius: 3px; background: var(--accent); opacity: .75; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.badge.good { color: var(--good); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }
.orders-tools { display: flex; gap: 8px; flex: 1; justify-content: flex-end; min-width: 260px; }
#orderSearch { flex: 1; max-width: 420px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; color: var(--text-2); font-size: 12.5px; }
.pager div { display: flex; gap: 6px; }

/* Insights */
.insights-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.insights-head h3 { margin: 0; }
.insights-head p { margin: 2px 0 0; }
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.insight { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.insight .tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; display: inline-flex; gap: 6px; align-items: center; }
.insight.growth .tag { color: var(--good); } .insight.risk .tag { color: var(--bad); } .insight.cost .tag { color: var(--warn); } .insight.headline .tag { color: var(--accent); }
.insight h4 { margin: 8px 0 6px; font-size: 15px; }
.insight p { margin: 0; color: var(--text-2); }

/* Power BI */
.pbi { border-radius: 10px; overflow: hidden; background: var(--panel-2); border: 1px dashed var(--border); min-height: 200px; display: grid; place-items: center; color: var(--muted); }
.pbi { display: block; }
.pbi iframe { width: 100%; aspect-ratio: 4 / 5; min-height: 600px; border: 0; display: block; background: #fff; }
.pbi-help { color: var(--text-2); font-size: 13px; }
.pbi-help code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; background: var(--panel); border: 1px dashed var(--border); border-radius: 14px; margin-bottom: 16px; }
.empty-ico { font-size: 40px; color: var(--muted); }
.empty h2 { margin: 8px 0 4px; font-size: 18px; }
.empty p { color: var(--text-2); margin: 0 0 14px; }
body.is-empty .view.active { display: none; }

.page-foot { color: var(--muted); font-size: 11.5px; text-align: center; padding: 18px 0 0; }
.tooltip-note { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; }
.tooltip-note.show { opacity: 1; transform: translateX(-50%); }

/* ===== Responsive ===== */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .f-btns { grid-column: span 4; justify-content: flex-end; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .menu-btn { display: grid; place-items: center; }
  .g-2-1, .g-1-1 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .filters { position: static; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .f-btns { grid-column: span 2; }
  .topbar h1 { font-size: 20px; }
  .topbar-right { display: none; }
  .kpi-value { font-size: 20px; }
}

/* ===== Ask-the-data chat assistant ===== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ask-btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 12px; cursor: pointer; white-space: nowrap; }
.ask-btn:hover { filter: brightness(1.08); }
.nav-ask { margin-top: 6px; border: 1px dashed var(--side-border) !important; color: var(--accent) !important; }
.chat-fab {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 12px 18px 12px 14px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: transform .15s, opacity .2s;
}
.chat-fab span:first-child { font-size: 18px; }
.chat-fab:hover { transform: translateY(-2px); }
body.chat-open .chat-fab { opacity: 0; pointer-events: none; }
.chat {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 45;
  width: min(440px, calc(100vw - 24px)); height: min(680px, calc(100vh - 36px));
  display: flex; flex-direction: column; background: var(--bg-grad), var(--bg); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right; transition: opacity .2s, transform .2s;
}
.chat.open { opacity: 1; transform: none; }
.chat-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.chat-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 17px; flex: none; }
.chat-name { font-weight: 800; font-size: 14.5px; }
.chat-mode { font-size: 11.5px; color: var(--muted); }
.chat-actions { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--panel); border-color: var(--border); color: var(--text); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; min-width: 0; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; font-weight: 600; }
.msg.bot .bubble { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; width: 92%; }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 6px; padding-left: 18px; }
.bubble b { font-weight: 800; }
.bubble code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: var(--panel); padding: 1px 4px; border-radius: 4px; }
.muted-s { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--border); background: var(--panel); color: var(--text-2); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chat-chart { position: relative; margin: 10px 0 4px; }
.chat-data { margin-top: 8px; }
.chat-data summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-2); }
.chat-table { overflow-x: auto; margin-top: 6px; border: 1px solid var(--border); border-radius: 8px; }
.chat-table table { border-collapse: collapse; width: 100%; font-size: 12px; }
.chat-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.chat-table td { padding: 5px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.chat-table td.n { text-align: right; font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.chat-table tr:last-child td { border-bottom: 0; }
.msg-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
[data-skin="corporate"] .link-btn { color: var(--text); }
.src { font-size: 11px; color: var(--muted); margin-left: auto; }
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--panel-2); align-items: flex-end; }
.chat-form textarea { flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 13.5px; max-height: 120px; line-height: 1.4; }
.chat-form textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.chat-send { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-size: 16px; flex: none; }
.chat-send:disabled { opacity: .5; cursor: wait; }
@media (max-width: 600px) {
  .chat { right: 0; bottom: 0; width: 100vw; height: 100%; border-radius: 0; border: 0; }
  .chat-fab .fab-label { display: none; }
  .chat-fab { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .chat, .chat-fab, .typing span { transition: none; animation: none; } }

/* ===== Rich visuals & interaction ===== */
.kpi.has-spark { padding-bottom: 46px; }
.spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--accent); opacity: .09; }
.spark-dot { fill: var(--accent); }
[data-skin="corporate"] .spark-line, [data-skin="corporate"] .spark-dot { stroke: #a37f00; fill: #a37f00; }
[data-skin="corporate"] .spark-dot { stroke: none; }
.active-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 16px; }
.chips-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); }
.fchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--text); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.fchip span { opacity: .6; font-size: 11px; }
.fchip:hover span { opacity: 1; }
.fchip-clear { background: none; border: 0; color: var(--text-2); font-size: 12.5px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.donut-wrap { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 18px; align-items: center; min-height: 230px; }
.donut { position: relative; height: 210px; }
.legend { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.leg { display: grid; grid-template-columns: 12px 1fr auto 52px; gap: 10px; align-items: center; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 7px 9px; cursor: pointer; font-size: 13px; }
.leg:hover { background: var(--panel-2); border-color: var(--border); }
.leg i { width: 12px; height: 12px; border-radius: 4px; }
.leg b { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 12.5px; }
.leg em { font-style: normal; color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.hm { display: grid; gap: 4px; min-width: 560px; }
.hm-col { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: center; padding: 4px 2px 6px; }
.hm-row { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; }
.hm-cell { border: 0; border-radius: 8px; padding: 12px 4px; cursor: pointer; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--accent) var(--t), var(--panel-2)); transition: transform .12s, box-shadow .12s; }
.hm-cell.strong { color: var(--accent-ink); }
.hm-cell:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--accent); }
.hm-cell:focus-visible, .leg:focus-visible, .fchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#tWarehouse tbody tr { cursor: pointer; }
#tWarehouse tbody tr.sel td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
@media (max-width: 600px) { .donut-wrap { grid-template-columns: 1fr; } .donut { height: 190px; } }
