/* EC Dashboard — enterprise sales control tower */
:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --border: #e4e8ef;
  --border-strong: #d3d9e3;
  --navy: #0b2545;
  --navy-2: #13315c;
  --text: #0f1b2d;
  --text-2: #4f5b6e;
  --muted: #8691a3;
  --primary: #2a78d6;      /* data series 1 */
  --primary-soft: #e8f1fc;
  --accent: #eb6834;       /* series 2: target / comparison */
  --accent-soft: #fdeee7;
  --series-3: #1baf7a;
  --grey-series: #a7afbd;
  --good: #0a8a3a;
  --good-soft: #e6f5ec;
  --bad: #c53030;
  --bad-soft: #fcebeb;
  --warn: #b26b00;
  --warn-icon: #f0a500;
  --warn-soft: #fff6e0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 16px rgba(15, 27, 45, .05);
  --shadow-lg: 0 10px 40px rgba(15, 27, 45, .16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------------ header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px 0;
}
.topbar-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(140deg, var(--navy) 0%, var(--navy-2) 60%, #1f4f8f 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(11, 37, 69, .25);
}
.logo svg.i { width: 21px; height: 21px; stroke-width: 2; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.02em; color: var(--navy); }
.brand p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-2); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.meta-item {
  display: flex; flex-direction: column; padding: 5px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border); min-width: 0;
}
.meta-item span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.meta-item b { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.meta-item.dq { cursor: pointer; transition: border-color .15s, background .15s; }
.meta-item.dq:hover { border-color: var(--primary); background: var(--primary-soft); }
.dq-bar { display: flex; height: 4px; border-radius: 3px; overflow: hidden; margin-top: 4px; background: var(--warn-soft); width: 110px; }
.dq-bar i { background: var(--good); display: block; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  transition: all .15s;
}
.icon-btn:hover { color: var(--navy); border-color: var(--border-strong); background: var(--surface-2); }

.tabs { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 10px 14px 11px; color: var(--text-2); font-weight: 550;
  border-bottom: 2px solid transparent; display: flex; gap: 7px; align-items: center; white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 650; }
.tab svg.i { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ filters */
.filterbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(243, 245, 249, .92); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 28px;
}
.frow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.frow + .frow { margin-top: 8px; }
.flabel { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.fbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; color: var(--text-2);
  transition: all .15s; max-width: 260px;
}
.fbtn:hover { border-color: var(--border-strong); color: var(--text); }
.fbtn .fv { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbtn.on { border-color: var(--primary); background: var(--primary-soft); }
.fbtn.on .fv { color: var(--navy); }
.fbtn svg.i { width: 14px; height: 14px; color: var(--muted); }
.fsep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; }
.btn {
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg.i { width: 14px; height: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px; border-radius: 20px;
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 500; max-width: 360px;
}
.chip b { font-weight: 650; opacity: .75; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: rgba(255,255,255,.16); color: #fff; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.chip button:hover { background: rgba(255,255,255,.3); }
.chip button svg.i { width: 11px; height: 11px; stroke-width: 2.4; }

.pop {
  position: fixed; z-index: 100; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); width: 320px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; max-height: min(480px, 70vh); animation: popin .14s ease-out;
}
@keyframes popin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.pop-head .t { font-weight: 650; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.pop-head .t small { color: var(--muted); font-weight: 500; }
.search {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; height: 32px; background: var(--surface-2);
}
.search:focus-within { border-color: var(--primary); background: var(--surface); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; }
.search svg.i { color: var(--muted); width: 14px; height: 14px; }
.pop-list { overflow-y: auto; padding: 6px; flex: 1; }
.opt { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.opt:hover { background: var(--surface-2); }
.opt input { accent-color: var(--navy); width: 15px; height: 15px; margin: 0; flex: none; }
.opt .ol { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .ov { color: var(--muted); font-size: 12px; }
.pop-foot { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); }
.pop-note { color: var(--muted); font-size: 12px; padding: 8px 10px; }
.period-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
.period-grid label { font-size: 11.5px; color: var(--text-2); font-weight: 600; display: flex; flex-direction: column; gap: 5px; }
.sel {
  height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; background: var(--surface);
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; }
.preset { border: 1px solid var(--border); background: var(--surface-2); border-radius: 20px; padding: 4px 10px; font-size: 12px; color: var(--text-2); }
.preset:hover { border-color: var(--primary); color: var(--navy); }

/* ------------------------------------------------------------------ layout */
main { padding: 22px 28px 48px; max-width: 1880px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.grid + .grid, .grid + .section-title, .section-title + .grid { margin-top: 18px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 0; }
.section-title h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.section-title span { color: var(--muted); font-size: 12.5px; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(228, 232, 239, .7); padding: 18px 20px; min-width: 0; display: flex; flex-direction: column;
}
.card-h { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-h .tt { flex: 1; min-width: 0; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 680; color: var(--text); letter-spacing: -.01em; }
.card-h p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.card-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgba(15,27,45,.12); }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 380px; }
.chart.short { height: 260px; }
.note { font-size: 11.5px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; }
.note svg.i { width: 13px; height: 13px; margin-top: 1px; }
.empty { padding: 36px 12px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ KPI */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px 14px; position: relative; overflow: hidden; }
.kpi.hero { background: linear-gradient(150deg, var(--navy) 0%, var(--navy-2) 75%, #1c4a85 100%); color: #fff; border: 0; }
.kpi .kh { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.kpi.hero .kh { color: rgba(255,255,255,.75); }
.kpi .kic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi.hero .kic { background: rgba(255,255,255,.12); color: #fff; }
.kpi .kv { font-size: 27px; font-weight: 750; letter-spacing: -.03em; margin-top: 12px; line-height: 1.1; white-space: nowrap; }
.kpi .kv small { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin-left: 2px; color: var(--text-2); }
.kpi.hero .kv small { color: rgba(255,255,255,.8); }
.kpi .kd { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.kpi.hero .kd { color: rgba(255,255,255,.7); }
.kpi .kf { font-size: 11.5px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .kf { color: rgba(255,255,255,.65); }
.kpi .spark { position: absolute; right: 12px; top: 14px; width: 84px; height: 30px; opacity: .9; }
.ach { margin-top: 10px; }
.ach-track { height: 6px; background: rgba(255,255,255,.16); border-radius: 4px; overflow: hidden; position: relative; }
.ach-track i { display: block; height: 100%; background: #fff; border-radius: 4px; }
.ach-l { display: flex; justify-content: space-between; font-size: 11.5px; margin-top: 5px; color: rgba(255,255,255,.75); }
.ach-l b { color: #fff; }

.pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 650; 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-3); color: var(--text-2); }
.kpi.hero .pill.up { background: rgba(80, 220, 130, .18); color: #8ff0b2; }
.kpi.hero .pill.down { background: rgba(255, 110, 110, .18); color: #ffb3b3; }
.pill svg.i { width: 11px; height: 11px; stroke-width: 2.6; }
.g-up { color: var(--good); font-weight: 600; }
.g-down { color: var(--bad); font-weight: 600; }
.g-na { color: var(--muted); }

/* ------------------------------------------------------------------ rank list */
.rank { display: flex; flex-direction: column; gap: 2px; }
.rk {
  display: grid; grid-template-columns: 22px minmax(120px, 1.5fr) minmax(50px, 1.3fr) auto; gap: 12px; align-items: center;
  padding: 8px 8px; border-radius: 9px; transition: background .12s;
}
.rk.click { cursor: pointer; }
.rk.click:hover { background: var(--surface-2); }
.rk .n { font-size: 11.5px; color: var(--muted); font-weight: 600; text-align: right; }
.rk .lb { min-width: 0; }
.rk .lb b { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk .lb span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk .bar { height: 10px; background: var(--surface-3); border-radius: 0 4px 4px 0; position: relative; }
.rk .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.rk .bar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); border-radius: 2px; }
.rk.top .bar i { background: var(--navy); }
.rk .vv { text-align: right; min-width: 92px; }
.rk .vv b { display: block; font-weight: 650; }
.rk .vv span { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 1px; }
.tag.best { background: var(--primary-soft); color: var(--navy); }
.tag.low { background: var(--warn-soft); color: var(--warn); }
.legend-inline { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-2); margin-top: 8px; flex-wrap: wrap; }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend-inline i.ln { height: 2px; width: 14px; vertical-align: 3px; border-radius: 1px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; margin-bottom: 10px; }
.crumbs button { border: 0; background: var(--surface-2); color: var(--primary); padding: 3px 9px; border-radius: 6px; font-weight: 600; }
.crumbs button:hover { background: var(--primary-soft); }
.crumbs .cur { font-weight: 650; color: var(--text); padding: 3px 4px; }
.crumbs .sep { color: var(--muted); }
.drill-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }

/* ------------------------------------------------------------------ tables */
.tbl-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tbl-tools .search { width: 260px; max-width: 100%; }
.tbl-tools .sp { flex: 1; }
.tbl-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.t th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 650; color: var(--text-2);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
table.t th.sortable { cursor: pointer; }
table.t th.sortable:hover { color: var(--navy); }
table.t th .ar { opacity: .35; margin-left: 4px; }
table.t th.sorted .ar { opacity: 1; color: var(--primary); }
table.t tr.flt th { padding: 6px 8px; background: var(--surface); top: 35px; }
table.t tr.flt input { width: 100%; min-width: 70px; height: 26px; border: 1px solid var(--border); border-radius: 6px; padding: 0 7px; font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--surface-3); white-space: nowrap; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafbfd; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.rnk { color: var(--muted); font-weight: 600; width: 36px; }
table.t td .mini { display: inline-block; height: 6px; background: var(--primary); border-radius: 0 3px 3px 0; vertical-align: middle; margin-right: 8px; opacity: .85; }
table.t td b { font-weight: 600; }
.tbl-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.tbl-foot .sp { flex: 1; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager button { min-width: 30px; height: 28px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; color: var(--text-2); font-weight: 600; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { border-color: var(--primary); color: var(--navy); }

/* ------------------------------------------------------------------ insights & alerts */
.ins { display: flex; flex-direction: column; gap: 4px; }
.in { display: flex; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--surface-3); align-items: flex-start; line-height: 1.5; }
.in:last-child { border-bottom: 0; }
.in .ii { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.in .ii.g { background: var(--good-soft); color: var(--good); }
.in .ii.r { background: var(--bad-soft); color: var(--bad); }
.in .tx { flex: 1; font-size: 13px; color: var(--text-2); }
.in .tx b { color: var(--text); font-weight: 650; }
.in .tx small { display: block; color: var(--muted); font-size: 11.5px; }
.al { display: flex; gap: 11px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 8px; align-items: flex-start; border-left: 3px solid var(--warn-icon); }
.al.crit { border-left-color: var(--bad); }
.al.info { border-left-color: var(--grey-series); }
.al .ai { color: var(--warn-icon); margin-top: 1px; }
.al.crit .ai { color: var(--bad); }
.al.info .ai { color: var(--muted); }
.al .at { flex: 1; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.al .at b { color: var(--text); font-weight: 650; }
.al .at .lvl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); margin-right: 6px; }
.al.crit .at .lvl { color: var(--bad); }
.al.info .at .lvl { color: var(--muted); }
.al-ok { display: flex; align-items: center; gap: 10px; color: var(--good); padding: 14px; background: var(--good-soft); border-radius: 10px; font-weight: 600; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.tile span { font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.tile b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.tile small { color: var(--muted); font-size: 11.5px; }
.risk { display: inline-flex; gap: 6px; align-items: center; font-weight: 650; font-size: 12px; padding: 3px 10px; border-radius: 20px; }
.risk.low { background: var(--good-soft); color: var(--good); }
.risk.med { background: var(--warn-soft); color: var(--warn); }
.risk.high { background: var(--bad-soft); color: var(--bad); }

.status-rows { display: flex; flex-direction: column; gap: 14px; }
.st-row .st-h { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.st-row .st-h b { font-weight: 650; }
.st-row .st-bar { height: 8px; background: var(--surface-3); border-radius: 0 4px 4px 0; }
.st-row .st-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.st-row .st-m { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 5px; flex-wrap: wrap; }

/* compare */
.cmp-ctl { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.cmp-ctl label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.cmp-ctl .sel { min-width: 170px; max-width: 280px; }
.vs { font-weight: 750; color: var(--muted); padding-bottom: 7px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 22, 40, .45); z-index: 200; display: none; place-items: center; padding: 16px; }
.modal-bg.open { display: grid; }
.modal { background: var(--surface); border-radius: 16px; width: 640px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); padding: 22px 24px; }
.modal h3 { margin: 0 0 4px; font-size: 17px; color: var(--navy); }
.modal .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.dq-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--surface-3); align-items: center; font-size: 12.5px; }
.dq-row .h { color: var(--muted); font-size: 11.5px; }
.dq-ok { color: var(--good); font-weight: 600; }
.dq-bad { color: var(--warn); font-weight: 650; }

.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 300; color: var(--text-2); font-weight: 600; }
.loading .sp { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 0 0 28px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1500px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .c3 { grid-column: span 6; }
}
@media (max-width: 1200px) {
  .c3, .c4, .c5 { grid-column: span 6; }
  .c7, .c8 { grid-column: span 12; }
}
@media (max-width: 860px) {
  .topbar, .filterbar { padding-left: 16px; padding-right: 16px; }
  main { padding: 16px 16px 40px; }
  .grid { gap: 14px; }
  .c3, .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi .kv { font-size: 22px; }
  .kpi .spark { display: none; }
  .meta { margin-left: 0; }
  .rk { grid-template-columns: 18px minmax(80px, 1fr) minmax(40px, .8fr) auto; gap: 8px; }
  .tiles { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 2200px) { /* TV / wall display */
  body { font-size: 15px; }
  main { max-width: 2400px; }
  .chart { height: 380px; }
  .kpi .kv { font-size: 34px; }
}
@media print {
  .filterbar, .tabs, .icon-btn { display: none; }
  .page { display: block !important; }
}

/* ------------------------------------------------------------------ dashboard switcher */
.dash-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.dash-switch a { padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.dash-switch a:hover { color: var(--navy); }
.logout-link { font-size: 12.5px; font-weight: 600; color: var(--text-2); text-decoration: none; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border); white-space: nowrap; }
.logout-link:hover { color: var(--bad); border-color: var(--bad); }
.dash-switch a.on { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgba(15, 27, 45, .12); }

/* Sync data button (manual refresh from the data lake), next to Log out */
.sync-btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  padding: 5px 11px; border-radius: 7px; border: 1px solid var(--primary); background: var(--primary-soft); color: var(--primary); }
.sync-btn:hover:not(:disabled) { background: var(--primary); color: #fff; }
.sync-btn:disabled { cursor: progress; opacity: .85; }
.sync-btn svg.i { width: 14px; height: 14px; flex: none; }
.sync-btn.busy svg.i { animation: sync-spin 1s linear infinite; }
.sync-btn[hidden] { display: none; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sync-btn.busy svg.i { animation: none; } }

/* ------------------------------------------------------------------ home page */
.home-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.home-kpis .kpi .kd b { font-weight: 650; }
a.card.biz { display: block; text-decoration: none; color: inherit; border-top: 3px solid var(--biz); transition: box-shadow .15s, transform .15s; }
a.card.biz:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.biz-h { display: flex; align-items: flex-start; gap: 10px; }
.biz-h > div { flex: 1; min-width: 0; }
.biz-h h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--navy); }
.biz-h p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.biz-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--biz); margin-top: 4px; }
.biz-open { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--biz); }
.biz-open svg.i, table.home-t .btn svg.i { width: 14px; height: 14px; }
.biz-v { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 30px; font-weight: 750; letter-spacing: -.03em; color: var(--text); }
.biz-v small { font-size: 16px; font-weight: 650; color: var(--text-2); margin-left: 3px; margin-right: auto; }
.biz-v .spark { position: static; width: 110px; height: 34px; }
.biz-ach { margin-top: 10px; }
.biz-track { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.biz-track i { display: block; height: 100%; background: var(--biz); border-radius: 4px; }
.biz-l { display: flex; justify-content: space-between; font-size: 11.5px; margin-top: 5px; color: var(--text-2); }
.biz-tiles { margin-top: 14px; }
.biz-tiles .tile b { font-size: 18px; }
.biz-f { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.biz-f b { color: var(--text); font-weight: 600; }
table.home-t tr.tot td { background: var(--surface-2); border-top: 1px solid var(--border); font-weight: 600; }
@media (max-width: 1200px) { .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .home-kpis { grid-template-columns: 1fr; } }
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.biz-tiles .tile b.g-up, .biz-tiles .tile b.g-down { font-weight: 750; }
.tgt-sum { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tgt-sum > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; min-width: 150px; }
.tgt-sum span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.tgt-sum b { display: block; font-size: 16px; font-weight: 750; color: var(--navy); margin-top: 2px; }
.tgt-sum small { display: block; font-size: 11px; color: var(--muted); }
.rk .vv b .vt { display: inline; font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.rev-note { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; max-width: 520px; padding: 6px 12px; border-radius: 9px;
  background: var(--warn-soft); border: 1px solid #f3dfa8; color: var(--warn); font-size: 12px; font-weight: 600; line-height: 1.35; }
.rev-note svg.i { width: 15px; height: 15px; flex: none; }
.rev-note + .dash-switch { margin-left: 0; }
