/* ==========================================================
   Иргэний бүртгэлийн хяналтын самбар — үндсэн загвар
   ========================================================== */
:root {
  color-scheme: light;
  --bg: #f3f4fa;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #dcecf6 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #e3f4f1 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --line: #e7e8f1;
  --ink: #0f1222;
  --ink-2: #4b5068;
  --muted: #8a8fa6;
  --accent: #005b89;
  --accent-2: #1a8cc4;
  --accent-soft: #e3f0f7;
  --good: #12a150;
  --good-soft: #e3f7ea;
  --bad: #d9363e;
  --bad-soft: #fde8e9;
  --shadow: 0 1px 2px rgba(16, 18, 40, .04), 0 8px 24px -12px rgba(16, 18, 40, .12);
  --shadow-lg: 0 24px 60px -20px rgba(0, 60, 95, .35);
  --r: 20px;
  --r-sm: 12px;
  /* Диаграммын категори өнгө (тогтмол дараалал) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --grid: #eceef5;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-d: "Manrope", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0e16;
    --bg-grad: radial-gradient(1200px 600px at 85% -10%, #0b2a3e 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0d2a3a 0%, transparent 55%);
    --surface: #151826; --surface-2: #1b1f30; --line: #262b40;
    --ink: #f2f3f9; --ink-2: #c3c6d8; --muted: #8b90aa;
    --accent: #4fb0e3; --accent-2: #7cc6ee; --accent-soft: #0f2c3d;
    --good: #34c46f; --good-soft: #10301f; --bad: #ff6b72; --bad-soft: #3a1619;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --grid: #22263a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e16;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #0b2a3e 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0d2a3a 0%, transparent 55%);
  --surface: #151826; --surface-2: #1b1f30; --line: #262b40;
  --ink: #f2f3f9; --ink-2: #c3c6d8; --muted: #8b90aa;
  --accent: #4fb0e3; --accent-2: #7cc6ee; --accent-soft: #0f2c3d;
  --good: #34c46f; --good-soft: #10301f; --bad: #ff6b72; --bad-soft: #3a1619;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --grid: #22263a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-family: var(--font-d); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  background: color-mix(in srgb, var(--surface) 75%, transparent); backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -8px var(--accent);
}
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.brand-logo { display: grid; place-items: center; width: 40px; height: 64px; flex: none; }
.brand-logo img { height: 64px; width: auto; }
.hero > .hero-wm { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); height: 84%; width: auto; opacity: .09; pointer-events: none; z-index: 0 !important; }
.cb-head .av { background: rgba(255,255,255,.14); }
.cb-head .av img { width: auto !important; height: 32px !important; border-radius: 0 !important; }
/* Лого: гэгээлэг дэвсгэр дээр цэнхэр, харанхуй дээр цагаан */
.lg-d { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lg-l { display: none; } :root:not([data-theme="light"]) .lg-d { display: block; } }
:root[data-theme="dark"] .lg-l { display: none; }
:root[data-theme="dark"] .lg-d { display: block; }

.cb-head .av img { width: 40px; height: 40px; border-radius: 12px; }
.brand b { display: block; font-family: var(--font-d); font-size: 15px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: block; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.side-card {
  padding: 16px; border-radius: 16px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(140deg, #00476d, #005b89 55%, #1a8cc4);
}
.side-card::after { content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; right: -50px; top: -60px; background: rgba(255,255,255,.12); }
.side-card b { display: block; font-family: var(--font-d); font-size: 15px; }
.side-card p { margin: 4px 0 12px; font-size: 12px; opacity: .85; }
.side-card a { display: inline-flex; gap: 6px; align-items: center; background: #fff; color: #005b89; padding: 7px 12px; border-radius: 10px; font-weight: 600; font-size: 12.5px; position: relative; z-index: 1; }
.theme-btn { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink-2); }

.main { min-width: 0; padding: 20px 28px 60px; }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { font-family: var(--font-d); font-size: 26px; margin: 0; letter-spacing: -.02em; line-height: 1.15; }
.top .sub { color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--good-soft); color: var(--good); font-weight: 600; font-size: 12px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent); }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }

.search { position: relative; width: 340px; max-width: 100%; }
.search input {
  width: 100%; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 0 70px 0 42px;
  box-shadow: var(--shadow); outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search > svg { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.search kbd { position: absolute; right: 10px; top: 10px; font: 11px var(--font); padding: 3px 7px; border-radius: 7px; border: 1px solid var(--line); color: var(--muted); background: var(--surface-2); }
.suggest {
  position: absolute; top: 50px; left: 0; right: 0; z-index: 40; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow: auto;
}
.suggest .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }
.suggest button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; }
.suggest button:hover, .suggest button.hl { background: var(--accent-soft); }
.suggest button .r { margin-left: auto; color: var(--muted); font-size: 12px; }
.suggest .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.suggest .ic svg { width: 16px; height: 16px; }
.suggest mark { background: none; color: var(--accent); font-weight: 600; }
.suggest .empty { padding: 14px; color: var(--muted); }

/* ---------- Filters ---------- */
.filters {
  position: sticky; top: 0; z-index: 30; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px; margin: 0 -10px 20px; border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
}
.seg { display: inline-flex; padding: 4px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--ink); color: var(--surface); }
.field { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.field label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.field select { border: 0; background: none; outline: none; font-weight: 600; cursor: pointer; padding-right: 2px; max-width: 160px; }
.field select option { background: var(--surface); color: var(--ink); }
.btn-ghost { height: 44px; padding: 0 14px; border-radius: 13px; border: 1px dashed var(--line); background: transparent; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.f-note { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ---------- Sections & cards ---------- */
.section { margin-top: 34px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { font-family: var(--font-d); font-size: 20px; margin: 0; letter-spacing: -.01em; }
.section-head p { margin: 2px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-h h3 { margin: 0; font-size: 15px; font-family: var(--font-d); }
.card-h p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-h select { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--surface-2); font-size: 12.5px; max-width: 170px; }

.grid { display: grid; gap: 18px; }
.g-hero { grid-template-columns: 1.25fr 2fr; }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-1 { grid-template-columns: 1fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Hero */
.hero {
  position: relative; overflow: hidden; color: #fff; border: 0; padding: 24px;
  background: linear-gradient(150deg, #003a5a 0%, #005b89 50%, #1b8fc7 100%);
  box-shadow: var(--shadow-lg);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.09); }
.hero::before { width: 260px; height: 260px; right: -80px; top: -110px; }
.hero::after { width: 180px; height: 180px; right: 60px; bottom: -120px; }
.hero > * { position: relative; z-index: 1; }
.hero .lbl { display: flex; align-items: center; gap: 10px; opacity: .9; font-weight: 500; }
.hero .lbl .ico { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.hero .big { font-size: 48px; font-weight: 800; margin: 14px 0 4px; line-height: 1; }
.hero .cmp { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .95; flex-wrap: wrap; }
.hero .pill { background: rgba(255,255,255,.2); color: #fff; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.hero-stats div { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 12px; }
.hero-stats small { display: block; opacity: .8; font-size: 11.5px; }
.hero-stats b { font-family: var(--font-d); font-size: 18px; }
.hero-spark { height: 70px; margin-top: 16px; }

.pill { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.pill.up { background: var(--good-soft); color: var(--good); }
.pill.down { background: var(--bad-soft); color: var(--bad); }
.pill.flat { background: var(--surface-2); color: var(--muted); }
.pill svg { width: 12px; height: 12px; stroke-width: 2.5; }

/* KPI cards */
.kpi { display: block; width: 100%; position: relative; padding: 18px; cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s; text-align: left; font: inherit; color: inherit; }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--k) 40%, var(--line)); }
.kpi.sel { border-color: var(--k); box-shadow: 0 0 0 3px color-mix(in srgb, var(--k) 18%, transparent), var(--shadow); }
.kpi-top { display: flex; align-items: center; gap: 12px; }
.kpi .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--k); background: color-mix(in srgb, var(--k) 13%, var(--surface)); }
.kpi .ico svg { width: 22px; height: 22px; }
.kpi .t { font-weight: 600; color: var(--ink-2); font-size: 13px; line-height: 1.25; }
.kpi .t small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.kpi .v { font-size: 28px; font-weight: 800; margin: 14px 0 6px; line-height: 1; }
.kpi .b { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.kpi .spark-box { height: 38px; margin: 12px -4px -4px; }

.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 230px; }
.chart-box.lg { height: 340px; }
.donut-wrap { position: relative; height: 220px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center b { display: block; font-family: var(--font-d); font-size: 26px; line-height: 1; }
.donut-center small { color: var(--muted); font-size: 12px; }
.legend { display: grid; gap: 8px; margin-top: 16px; }
.legend div { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .lv { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend .lp { color: var(--muted); width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 3px; }

.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.mini-stats div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.mini-stats small { color: var(--muted); font-size: 11.5px; display: block; }
.mini-stats b { font-family: var(--font-d); font-size: 18px; }

.insights { display: grid; gap: 10px; }
.insight { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); align-items: flex-start; }
.insight .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.insight .ico svg { width: 18px; height: 18px; }
.insight p { margin: 0; font-size: 13px; color: var(--ink-2); }
.insight b { color: var(--ink); }

/* ---------- Table ---------- */
.tbl-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tbl-tools .search { width: 280px; }
.tbl-tools .search input { height: 40px; box-shadow: none; padding-right: 12px; }
.tbl-tools .search > svg { top: 10px; }
.btn { height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--ink-2); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl th .arr { opacity: .35; margin-left: 4px; }
.tbl th.sorted .arr { opacity: 1; color: var(--accent); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl mark { background: color-mix(in srgb, var(--s4) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); }
.badge i { width: 7px; height: 7px; border-radius: 50%; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }
.pager button { min-width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.pager button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }

.foot { margin-top: 40px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* Loading */
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; transition: opacity .3s; }
.loading.hide { opacity: 0; pointer-events: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.err-box { max-width: 420px; text-align: center; padding: 30px; }

/* Appear */
.reveal { animation: up .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   Чатбот
   ========================================================== */
.cb-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 60; width: 62px; height: 62px; border-radius: 20px; border: 0; cursor: pointer;
  color: #fff; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 34px -10px var(--accent); transition: transform .2s, border-radius .2s;
}
.cb-fab:hover { transform: translateY(-2px) scale(1.04); }
.cb-fab svg { width: 28px; height: 28px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-fab .dot { position: absolute; top: 10px; right: 10px; width: 11px; height: 11px; border-radius: 50%; background: #34d399; border: 2px solid #fff; }
.cb-fab.open { border-radius: 50%; }
.cb-tip { position: fixed; right: 96px; bottom: 38px; z-index: 59; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 9px 14px; border-radius: 14px 14px 4px 14px; font-size: 13px; animation: up .4s both; }
.cb {
  position: fixed; right: 24px; bottom: 100px; z-index: 61; width: 400px; max-width: calc(100vw - 32px); height: 600px; max-height: calc(100vh - 130px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; transform-origin: bottom right; animation: pop .25s cubic-bezier(.2,.8,.2,1) both;
}
.cb[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
.cb-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; color: #fff; background: linear-gradient(135deg, #00476d, #1a8cc4); }
.cb-head .av { width: 40px; height: 40px; border-radius: 13px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.cb-head .av svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; }
.cb-head b { display: block; font-family: var(--font-d); }
.cb-head small { opacity: .85; font-size: 12px; }
.cb-head button { margin-left: auto; background: rgba(255,255,255,.15); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.cb-head button + button { margin-left: 0; }
.cb-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; animation: up .25s both; overflow-wrap: anywhere; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; align-self: flex-start; }
.msg.me { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
.msg .big { font-family: var(--font-d); font-size: 24px; font-weight: 800; display: block; margin: 2px 0; }
.msg table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.msg td { padding: 4px 0; border-top: 1px dashed var(--line); }
.msg td:last-child { padding-left: 12px; white-space: nowrap; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.msg .bar { height: 6px; border-radius: 4px; background: var(--accent); display: block; margin-top: 2px; opacity: .8; }
.msg .act { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.msg .act button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--accent); font-weight: 600; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cb-chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px 0; scrollbar-width: none; background: var(--surface); }
.cb-chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.cb-chips button:hover { border-color: var(--accent); color: var(--accent); }
.cb-form { display: flex; gap: 8px; padding: 12px 14px 14px; background: var(--surface); }
.cb-form input { flex: 1; height: 44px; border-radius: 14px; border: 1px solid var(--line); padding: 0 14px; background: var(--surface-2); outline: none; }
.cb-form input:focus { border-color: var(--accent); }
.cb-form button { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .g-hero { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 70; width: 268px; transform: translateX(-100%); transition: transform .25s; background: var(--surface); }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
  .g-2-1, .g-1-2, .g-1-1, .g-3 { grid-template-columns: 1fr; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 16px 16px 90px; }
  .top-right { width: 100%; margin-left: 0; }
  .search { width: 100%; }
}
@media (max-width: 560px) {
  .g-kpi { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .v { font-size: 24px; }
  .top h1 { font-size: 21px; }
  .hero .big { font-size: 38px; }
  .f-note { display: none; }
  .filters { gap: 8px; position: static; }
  .field { flex: 1 1 calc(50% - 8px); }
  .field select { width: 100%; }
  .cb { right: 8px; bottom: 90px; max-width: calc(100vw - 16px); height: calc(100vh - 110px); }
  .cb-fab { right: 16px; bottom: 16px; }
  .cb-tip { display: none; }
}
@media print {
  .side, .filters, .cb, .cb-fab, .cb-tip, .menu-btn, .search { display: none !important; }
  .app { grid-template-columns: 1fr; }
}
