:root {
  --bg: #E8EDF5;
  --surface: #fff;
  --text: #1E293B;
  --muted: #64748B;
  --brand-text: #101A3C;
  --brand-muted: #4E5B7C;
  --brand-faint: #7C88A8;
  --accent: #2563EB;
  --violet: #4C56F2;
  --navy: #101A3C;
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --purple: #5B21B6;
  --teal: #0D9488;
  --border: #E2E8F0;
  --indigo: #3333CC;
  --lime: #66CC00;
  --shadow: 0 1px 2px rgba(16,26,60,.05), 0 10px 28px rgba(16,26,60,.07);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(16,26,60,.08), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(76,86,242,.08), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body.is-login { background: #F7F9FD; overflow: hidden; }
.hidden { display: none !important; }

/* ── Login (matches VortexERP LoginScreen) ── */
.login-shell { display: flex; min-height: 100vh; }
.login-hero {
  flex: 1.15;
  position: relative;
  overflow: hidden;
  min-height: 220px;
  clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
}
.login-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 20% 50%;
}
.login-veil {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(16,26,60,.35) 0%, rgba(16,26,60,.22) 40%, rgba(16,26,60,.72) 100%);
}
.login-hero-inner {
  position: relative; z-index: 1;
  height: 100%;
  display: flex; flex-direction: column;
  padding: 36px 56px 28px 36px;
  color: #fff;
}
.login-hero-inner h1,
.login-hero-inner p,
.login-hero-inner .brand-k,
.login-hero-inner .brand-s {
  color: #fff;
}
.brand-row { display: flex; align-items: center; gap: 16px; }
.vmark {
  width: 52px; height: 52px;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(76,86,242,.28);
  background: #fff;
}
.vmark.sm { width: 36px; height: 36px; box-shadow: none; }
.brand-k { font-size: 18px; font-weight: 800; letter-spacing: 4px; }
.brand-s { font-size: 11px; font-weight: 600; letter-spacing: 4.6px; opacity: .72; margin-top: 4px; }
.hero-copy { margin-top: auto; margin-bottom: 28px; text-shadow: 0 2px 16px rgba(0,0,0,.45); }
.hero-copy h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 900; letter-spacing: -1.6px; line-height: 1.02;
  margin: 0 0 8px;
  color: #fff;
}
.hero-copy .tag { margin: 0; font-size: 16px; font-weight: 600; opacity: .78; }
.hero-copy .place-sub { margin: 10px 0 0; font-size: 15px; font-weight: 700; opacity: .9; }
.place-card {
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 10px 12px;
  max-width: 420px;
}
.place-title { font-size: 12.5px; font-weight: 800; }
.place-blurb { font-size: 12px; opacity: .8; margin-top: 2px; line-height: 1.4; }

.login-pane {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 36px;
}
.login-card {
  width: 100%; max-width: 430px;
  background: #fff;
  border-radius: 22px;
  padding: 28px 26px 24px;
  box-shadow: 0 22px 50px rgba(16,26,60,.10);
  border: 1px solid #EEF1F6;
}
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: #DBEAFE; display: grid; place-items: center; flex-shrink: 0;
}
.card-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--brand-text); letter-spacing: -.3px; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--brand-muted); line-height: 1.3; }
.meta-pills { display: flex; gap: 8px; margin: 14px 0 20px; }
.meta-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 5px 10px; border-radius: 999px;
  background: #F1F5F9; color: var(--brand-muted);
}
.meta-pill.on { background: #DBEAFE; color: var(--violet); }
.fld { display: block; margin-bottom: 12px; }
.fld > span:first-child {
  display: block; font-size: 12px; font-weight: 700; color: var(--brand-muted); margin-bottom: 6px;
}
.fld-box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0 10px; background: #FAFBFD;
  transition: border-color .15s, box-shadow .15s;
}
.fld-box:focus-within {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(76,86,242,.16);
  background: #fff;
}
.fld-box input {
  flex: 1; border: 0; background: transparent; outline: none;
  padding: 12px 4px; font-size: 15px; margin: 0; width: auto; color: var(--brand-text);
}
.eye {
  border: 0; background: none; color: var(--brand-faint);
  font-size: 12px; font-weight: 700; cursor: pointer; padding: 6px 4px;
}
.err-box {
  background: #FEE2E2; border: 1px solid rgba(220,38,38,.22);
  color: var(--danger); border-radius: 12px; padding: 10px 12px;
  font-size: 13px; line-height: 1.35; margin: 0 0 12px;
}
.btn-primary {
  width: 100%; border: 0; border-radius: 12px;
  background: var(--navy); color: #fff;
  font-weight: 800; font-size: 15px; padding: 13px 16px;
  cursor: pointer; letter-spacing: .2px;
  box-shadow: 0 8px 18px rgba(16,26,60,.18);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-primary.sm { width: auto; padding: 10px 16px; font-size: 13.5px; box-shadow: none; }
.kbd-hint { text-align: center; font-size: 11.5px; color: var(--brand-faint); margin: 12px 0 0; }
.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--brand-faint); }

@media (max-width: 860px) {
  body.is-login { overflow: auto; }
  .login-shell { flex-direction: column; }
  .login-hero { flex: none; height: 210px; clip-path: none; border-radius: 0 0 22px 22px; }
  .login-hero-inner { padding: 18px 18px 14px; }
  .hero-copy h1 { font-size: 28px; color: #fff; }
  .hero-copy .tag, .place-card { display: none; }
  .login-pane { padding: 22px 16px 40px; }
  .login-foot { padding: 0 8px; text-align: center; }
}

/* ── App chrome ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 11px 20px;
  background: linear-gradient(90deg, #0B1228 0%, var(--navy) 55%, #162048 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(16,26,60,.28);
}
.top-brand { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.top-name { font-weight: 800; font-size: 14px; letter-spacing: .2px; }
.top-role { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; opacity: .7; }
.top-meta { flex: 1; font-size: 12.5px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-store {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; max-width: 180px;
}
.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }
.top-actions { display: flex; gap: 8px; }
.btn {
  border: 0; border-radius: 10px; padding: 9px 13px;
  font-weight: 700; cursor: pointer; font-size: 13px;
  background: #fff; color: var(--text);
}
.btn.ghost {
  background: rgba(255,255,255,.08);
  color: #fff; border: 1px solid rgba(255,255,255,.14);
}
.btn.ghost:hover { background: rgba(255,255,255,.16); }
.btn-navy { background: var(--navy); color: #fff; }
.btn.on { background: var(--navy); color: #fff; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 20px 64px; }
.row { display: flex; align-items: center; gap: 12px; }
.space { justify-content: space-between; }
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 800; color: var(--brand-text); letter-spacing: -.4px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.pills {
  display: flex; gap: 4px; flex-wrap: nowrap;
  overflow-x: auto;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 5px; margin: 14px 0 16px;
  box-shadow: var(--shadow);
}
.pill {
  flex: 0 0 auto; text-align: center;
  padding: 10px 14px; border-radius: 10px;
  font-weight: 700; font-size: 13px; cursor: pointer; color: #374151;
}
.pill:hover { background: #F8FAFC; }
.pill.on { color: #fff; }
.pill.sales.on { background: var(--accent); }
.pill.proc.on { background: var(--warn); }
.pill.fleet.on { background: var(--teal); }
.pill.fin.on { background: var(--ok); }
.pill.hrm.on { background: var(--purple); }
.pill.home.on { background: var(--navy); }
.pill.reports.on { background: #0F766E; }
.pill.analytics.on { background: #7C3AED; }
.pill.alerts.on { background: #BE123C; }

.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.dark { background: #0F172A; color: #fff; box-shadow: 0 16px 40px rgba(15,23,42,.28); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.tile {
  width: 180px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; border-left: 3px solid #D8DEE8;
  cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.tile:hover, .dtile:hover, .arow:hover, .card-link:hover {
  box-shadow: 0 8px 20px rgba(15,23,42,.12); transform: translateY(-1px);
}
.tile .k { font-size: 10px; font-weight: 700; letter-spacing: .4px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 800; margin-top: 6px; }
.tile .s { font-size: 11px; color: var(--muted); }
.tile.ok { border-left-color: var(--ok); }
.tile.warn { border-left-color: var(--warn); }
.tile.danger { border-left-color: var(--danger); }
.banner { padding: 12px; border-radius: 10px; margin-top: 10px; font-size: 13px; }
.banner.warn { background: #FEF3C7; }
.banner.danger { background: #FEE2E2; }
.banner.ok { background: #DCFCE7; }
.radar {
  background: linear-gradient(180deg, #F5F3FF, #EDE9FE);
  border: 1px solid #E9D5FF; border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.ask { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; }
.ask.hidden { display: none !important; }
.ask-scrim { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.ask-panel {
  position: relative; z-index: 1;
  width: min(480px, 100%); height: 100%;
  background: #fff; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: -12px 0 40px rgba(0,0,0,.18);
}
.ask-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ask-head h3 { margin: 0; font-size: 18px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-chips button {
  background: #F5F3FF; border: 1px solid #E9D5FF; color: #5B21B6;
  border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.ask-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.ask-msg { border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; }
.ask-msg.user { background: #0F172A; color: #fff; align-self: flex-end; max-width: 90%; }
.ask-msg.bot { background: #F8FAFC; border: 1px solid var(--border); }
.ask-form { display: flex; gap: 8px; }
.ask-form input {
  flex: 1; margin: 0; width: auto;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.sql { font-size: 11px; color: var(--muted); white-space: pre-wrap; }
.explain { background: #F5F3FF; color: #5B21B6; margin: 8px 0; }
.insight { margin: 8px 0 12px; }
.brief { background: linear-gradient(180deg, #F8F6FF, #F5F3FF); border: 1px solid #E9D5FF; border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; color: #1E293B; border-left: 4px solid #4C56F2; }
.brief .ai-rich { max-height: 240px; overflow: auto; padding-right: 4px; margin-top: 10px; }
.brief summary { display: flex; flex-direction: column; gap: 4px; list-style: none; }
.brief summary::-webkit-details-marker { display: none; }
.brief-kicker { font-size: 12px; font-weight: 800; letter-spacing: .4px; color: #5B21B6; }
.brief-teaser { font-size: 13px; color: #334155; font-weight: 600; line-height: 1.35; }
.brief[open] .brief-teaser { display: none; }
.card.slim { padding: 12px 16px; }
.bars.compact { height: 80px; margin-top: 8px; padding-bottom: 16px; }
.brief summary { cursor: pointer; font-weight: 800; font-size: 13px; letter-spacing: .3px; color: #5B21B6; }
.brief .body { margin-top: 10px; font-size: 13.5px; line-height: 1.5; }
.ai-kicker { font-size: 11px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase; color: #5B21B6; margin-bottom: 8px; }
.ai-rich { font-size: 13.5px; line-height: 1.5; }
.ai-rich p { margin: 0 0 8px; }
.ai-rich p:last-child { margin-bottom: 0; }
.ai-lead { font-size: 16px; font-weight: 700; color: #101A3C; line-height: 1.35; margin: 0 0 12px !important; }
.ai-h { font-weight: 800; font-size: 14px; color: #101A3C; margin: 10px 0 6px; }
.ai-rich ul, .ai-rich ol { margin: 0 0 10px; padding-left: 1.2em; }
.ai-rich li { margin: 0 0 5px; }
.ai-rich strong { color: #101A3C; }
.ai-kes { display: inline-block; background: #DBEAFE; color: #1E40AF; border-radius: 6px; padding: 0 6px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ai-sec { border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; }
.ai-sec.find { background: #EFF6FF; border: 1px solid #BFDBFE; }
.ai-sec.mean { background: #F5F3FF; border: 1px solid #E9D5FF; }
.ai-sec.next { background: #ECFDF5; border: 1px solid #A7F3D0; }
.ai-lab { font-size: 10.5px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase; color: #6B7280; margin-bottom: 4px; }
.ai-sec.next .ai-lab { color: #047857; }
.ai-sec.find .ai-lab { color: #1D4ED8; }
.ai-txt p { margin: 0; }
.ask-msg.bot .ai-rich { color: #1E293B; }
.ask-msg.bot .card { margin: 10px 0 0; box-shadow: none; }
.digest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.digest a, .digest .pillish {
  background: #FFF7ED; border: 1px solid #FED7AA; color: #9A3412;
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.digest .pillish.crit { background: #FEE2E2; border-color: #FECACA; color: #991B1B; }
.fresh { font-size: 10.5px; color: var(--muted); letter-spacing: .3px; }
.verdict { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; margin: 0 0 14px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; animation: xdp 2s infinite; }
.pulse.warn { background: #FBBF24; }
.pulse.crit { background: #F87171; }
@keyframes xdp { 0%{box-shadow:0 0 0 0 rgba(255,255,255,.4)} 70%{box-shadow:0 0 0 7px rgba(255,255,255,0)} 100%{box-shadow:0 0 0 0 rgba(255,255,255,0)} }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 10px; padding-bottom: 16px; }
.bar { flex: 1; background: linear-gradient(180deg, #60A5FA, #2563EB); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; }
.bar .t { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--muted); white-space: nowrap; }
.ins { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ins-row { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.ins-row.critical { background: #FEE2E2; }
.ins-row.warning { background: #FEF3C7; }
.ins-row.info { background: #DCFCE7; }
.ew-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: inline-block; background: #FEE2E2; border-radius: 8px; padding: 6px 10px; font-size: 12px; margin: 4px 4px 0 0; }
.dtile { width: 220px; background: #1E293B; border-radius: 12px; padding: 14px; border-left: 3px solid #334155; cursor: pointer; }
.dtile.danger { border-left-color: var(--danger); }
.dtile .k { color: #94A3B8; font-size: 10px; font-weight: 700; }
.dtile .v { color: #fff; font-size: 22px; font-weight: 800; margin-top: 6px; }
.arow { background: #1E293B; border-radius: 10px; padding: 14px; margin-bottom: 8px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0 14px; font-size: 15px; }
.err { color: var(--danger); font-size: 13px; }
.page-err { color: var(--danger); font-size: 13px; min-height: 0; }
.link { color: var(--accent); font-weight: 700; cursor: pointer; font-size: 13px; }
.crumbs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; }
.crumbs b { cursor: pointer; color: var(--accent); }
.filters {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 0 14px; padding: 12px 14px;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filters label { font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px; }
.filters input, .filters select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; margin: 0; background: #F8FAFC; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--violet); background: #fff; box-shadow: 0 0 0 3px rgba(76,86,242,.12); }
.filters .grow { flex: 1; min-width: 180px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filter-export { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }
.preset {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--brand-muted);
}
.preset.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.workspace { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
.rail {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 10px; max-height: calc(100vh - 220px); overflow: auto;
  position: sticky; top: 68px;
}
.rail input { margin: 0 0 8px; }
.rail-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.rail-item:hover { background: #F8FAFC; }
.rail-item.on { background: #EFF6FF; color: var(--accent); font-weight: 700; }
.rail-item small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.work-main { min-width: 0; }
.viz-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.viz-btns { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.viz-btns button { border: 0; background: #fff; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--brand-muted); }
.viz-btns button.on { background: var(--navy); color: #fff; }
.viz-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; background: transparent; padding: 0; }
.fchip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #EFF6FF; border-radius: 999px; padding: 4px 8px; font-weight: 600;
}
.fchip b { font-weight: 800; }
.fchip button { border: 0; background: none; cursor: pointer; font-weight: 800; color: var(--brand-muted); padding: 0 2px; }
.th-more {
  border: 0; background: none; cursor: pointer; opacity: .35; font-size: 11px; padding: 0 2px; color: var(--muted);
}
th:hover .th-more, .th-more:focus { opacity: 1; color: var(--accent); }
.col-vals { max-height: 220px; overflow: auto; margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.col-vals input { width: 100%; margin: 0 0 6px; padding: 6px 8px; font-size: 12px; }
.col-vals button { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.col-vals .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.col-sum { font-size: 11px; color: var(--muted); padding: 6px 10px; }
.top-auto {
  background: rgba(255,255,255,.08); color: #fff;
  border: 1px solid rgba(255,255,255,.14); border-radius: 8px;
  padding: 6px 8px; font-size: 12px; font-weight: 700;
}
td.mini { position: relative; }
td.mini .cellbar {
  position: absolute; left: 0; top: 3px; bottom: 3px;
  background: rgba(37,99,235,.16); border-radius: 0 4px 4px 0; pointer-events: none;
}
td.mini span { position: relative; z-index: 1; }
tr.selrow td { background: #DBEAFE; }
.rail-item .star { float: right; color: #D97706; }
.stats { font-size: 12px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
table.grid.wrap td { white-space: normal; max-width: 280px; }
td.rn, th.rn { width: 36px; color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.star-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.star-row .rail-item { width: auto; display: inline-block; border: 1px solid var(--border); background: #fff; }
.rail-item .pin { float: right; font-size: 10px; color: var(--brand-faint); }
table.grid.compact td, table.grid.compact th { padding: 4px 8px; font-size: 12px; }
.pager select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.viz-host { margin: 0 0 12px; }
.viz-svg { width: 100%; height: 180px; background: #F8FAFC; border-radius: 12px; }
.pie-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.pie-leg { font-size: 12px; margin: 4px 0; }
.pie-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.combo-leg { font-size: 11px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.combo-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 6px 0 2px; vertical-align: -1px; }
.kpi .delta { font-size: 11px; font-weight: 700; }
.kpi .delta.up { color: #16A34A; }
.kpi .delta.dn { color: #DC2626; }
.drill-menu {
  position: fixed; z-index: 50; min-width: 200px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15,23,42,.18); padding: 6px; font-size: 13px;
}
.drill-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.drill-menu button:hover { background: #EFF6FF; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 12px; }
.pager button { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-weight: 700; }
td.neg { color: #DC2626; font-weight: 700; }
td.pos { color: #15803D; font-weight: 700; }
.spark { display: block; margin-top: 6px; }
.prog { height: 6px; background: #334155; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.prog i { display: block; height: 100%; background: #60A5FA; }
.inspect {
  position: fixed; top: 56px; right: 0; bottom: 0; width: min(340px, 100%);
  background: #fff; border-left: 1px solid var(--border); z-index: 35;
  padding: 14px; overflow: auto; box-shadow: -8px 0 24px rgba(15,23,42,.08);
}
.inspect-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.inspect dl { margin: 0; }
.inspect dt { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 8px; }
.inspect dd { margin: 2px 0 0; font-weight: 600; }
td.sel { background: #DBEAFE !important; }
.card.fs { position: fixed; inset: 10px; z-index: 32; overflow: auto; max-width: none; }
.skel { height: 10px; border-radius: 6px; background: linear-gradient(90deg,#E5E7EB,#F3F4F6,#E5E7EB); background-size: 200% 100%; animation: sk 1.2s infinite; margin: 8px 0; }
.skel.lg { height: 22px; width: 42%; }
.skel.w80 { width: 80%; }
.skel-block { padding: 16px; }
@keyframes sk { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
.sql-panel { margin-top: 10px; font-size: 12px; color: var(--muted); }
.sql-panel summary { cursor: pointer; font-weight: 700; }
.sql-panel pre {
  background: #0F172A; color: #E2E8F0; padding: 10px 12px; border-radius: 10px;
  overflow: auto; max-height: 200px; font-size: 11px; white-space: pre-wrap; margin: 8px 0 0;
}
.kbd-toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #0F172A; color: #fff; padding: 8px 14px; border-radius: 10px;
  font-size: 12px; z-index: 70; box-shadow: 0 10px 28px rgba(15,23,42,.25);
}
.kbd-help {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.45);
}
.kbd-help .card { min-width: 280px; max-width: 420px; }
.kbd-help kbd {
  display: inline-block; min-width: 22px; text-align: center;
  background: #F1F5F9; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 6px; font-size: 11px; font-weight: 700; margin-right: 8px;
}
table.grid.dragging { user-select: none; }
.inspect dd.num { font-variant-numeric: tabular-nums; }
.chart { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.chart-row { display: grid; grid-template-columns: 110px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; }
.chart-row .cl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--brand-muted); }
.chart-row .cb { height: 10px; background: #EFF6FF; border-radius: 99px; overflow: hidden; }
.chart-row .cb i { display: block; height: 100%; background: linear-gradient(90deg, #60A5FA, #2563EB); border-radius: 99px; }
.chart-row .cv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tfoot td { font-weight: 800; background: #F8FAFC; border-top: 2px solid var(--border); }
.badge { font-size: 10px; font-weight: 800; letter-spacing: .4px; color: var(--brand-faint); }
.colpick {
  position: absolute; z-index: 15; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; box-shadow: 0 12px 32px rgba(15,23,42,.14);
  max-height: 280px; overflow: auto; min-width: 200px;
}
.colpick label { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; padding: 4px 0; cursor: pointer; }
.filters { position: relative; }
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { position: static; max-height: 220px; }
}
.gridwrap {
  overflow: auto; max-height: calc(100vh - 240px);
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th {
  position: sticky; top: 0; background: #F1F5F9;
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
}
table.grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.grid th.sortable:hover { color: var(--accent); background: #EFF6FF; }
table.grid th.sorted { color: var(--accent); }
table.grid th .sortind { font-size: 10px; opacity: .4; }
table.grid th.sorted .sortind { opacity: 1; }
table.grid th:first-child, table.grid td:first-child, table.grid tfoot td:first-child {
  position: sticky; left: 0; z-index: 1; background: #fff;
}
table.grid th:first-child { z-index: 2; background: #F8FAFC; }
table.grid th:nth-child(2), table.grid td:nth-child(2), table.grid tfoot td:nth-child(2) {
  position: sticky; left: 36px; z-index: 1; background: #fff;
}
table.grid th:nth-child(2) { z-index: 2; background: #F1F5F9; }
table.grid tbody tr:nth-child(even) td:first-child,
table.grid tbody tr:nth-child(even) td:nth-child(2) { background: #F8FAFC; }
table.grid tbody tr:hover td:first-child,
table.grid tbody tr:hover td:nth-child(2) { background: #EFF6FF; }
table.grid tr.hot:hover td:first-child,
table.grid tr.hot:hover td:nth-child(2) { background: #DBEAFE; }
body.focus-mode .rail { display: none; }
body.focus-mode .workspace { grid-template-columns: 1fr; }
body.focus-mode #hello, body.focus-mode .pills { display: none; }
body.focus-mode .wrap { max-width: none; padding-top: 10px; }
body.focus-mode .gridwrap { max-height: calc(100vh - 150px); }
body.focus-mode #focusBtn { background: rgba(255,255,255,.2); }
mark { background: #FDE68A; padding: 0 1px; border-radius: 2px; }
.col-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; align-items: center; }
.col-filter select, .col-filter input { font-size: 12px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px; }
.col-filter input { min-width: 90px; }
.colmove { margin-left: auto; display: inline-flex; gap: 2px; }
.colmove button { border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; font-size: 11px; padding: 0 4px; }
.colpick label { justify-content: space-between; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 8px 0; font-size: 13px; font-weight: 600; cursor: pointer; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid #F1F5F9; white-space: nowrap; }
table.grid tbody tr:nth-child(even) td { background: #F8FAFC; }
table.grid tbody tr:hover td { background: #EFF6FF; }
table.grid tr.hot { cursor: pointer; }
table.grid tr.hot:hover td { background: #DBEAFE; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.kpi {
  background: linear-gradient(180deg, #fff, #F8FAFC);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; min-width: 132px;
  box-shadow: 0 1px 0 rgba(16,26,60,.04);
}
.kpi .k { font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 800; letter-spacing: -.4px; color: var(--brand-text); margin-top: 4px; }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.card-link { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; }
.card-link h4 { margin: 0 0 4px; font-size: 14px; }
.card-link p { margin: 0; color: var(--muted); font-size: 12px; }
.group { font-size: 12px; font-weight: 800; letter-spacing: .6px; color: var(--muted); margin: 16px 0 8px; }
.busy { opacity: .6; pointer-events: none; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.back { background: #fff; border: 1px solid var(--border); color: var(--text); }
@media (max-width: 700px) {
  .tile, .dtile { width: calc(50% - 8px); }
  .top-meta { display: none; }
  /* Phone: let the top bar wrap instead of scrolling the page sideways. */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .top-brand { min-width: 0; }
  .top-actions { flex-wrap: wrap; width: 100%; gap: 6px; }
  .top-actions .btn, .top-auto { padding: 7px 10px; font-size: 12px; }
  h1 { font-size: 20px; }
  .filter-export { margin-left: 0; }
  .rpt-count { display: none; }
}

.rpt-kicker {
  font-size: 10px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--violet); margin-bottom: 4px;
}
.rpt-kicker.light { color: #93C5FD; }
.rpt-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.rpt-head h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.4px; color: var(--brand-text); }
.rpt-head .hint { margin: 0; }
.rpt-count {
  min-width: 64px; text-align: right;
  font-size: 28px; font-weight: 800; letter-spacing: -1px; color: var(--brand-text); line-height: 1;
}
.rpt-count small { display: block; font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.report-card { padding-top: 16px; }
.viz-toolbar { gap: 10px; padding: 8px 0 4px; border-top: 1px solid #F1F5F9; }
.viz-cluster { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.viz-opts .btn, .viz-more .btn { padding: 6px 10px; font-size: 12px; background: #F8FAFC; border: 1px solid var(--border); }
.viz-opts .btn.on, .viz-more .btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.workspace { gap: 16px; }
.rail {
  border-radius: var(--radius); padding: 12px 10px;
  box-shadow: var(--shadow); max-height: calc(100vh - 200px);
}
.rail input {
  border-radius: 10px; background: #F8FAFC; margin-bottom: 10px; font-size: 13px;
}
.rail-item { border-radius: 10px; padding: 9px 10px; }
.rail-item.on { background: linear-gradient(90deg, #EFF6FF, #F8FAFC); box-shadow: inset 3px 0 0 var(--accent); }
.group { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; margin: 14px 8px 6px; }
.tile, .dtile { transition: box-shadow .15s, transform .15s, border-color .15s; }
.tile { border-radius: 14px; padding: 14px; }
.dtile {
  background: linear-gradient(165deg, #1E293B, #0F172A);
  border-radius: 14px; box-shadow: 0 10px 24px rgba(15,23,42,.22);
}
.hero-board { border-radius: 20px; padding: 20px; }
.radar {
  background: linear-gradient(135deg, #F5F3FF 0%, #EEF2FF 55%, #F8FAFC 100%);
  border-radius: 16px; box-shadow: var(--shadow);
}
.radar-crit { color: #DC2626; font-weight: 800; }
.radar-chips { margin-top: 8px; }
.inspect .btn.ghost, .ask-panel .btn.ghost {
  background: #F1F5F9; color: var(--brand-text); border: 1px solid var(--border);
}
.inspect-head b { font-size: 14px; color: var(--brand-text); }
.pager {
  padding: 8px 2px; color: var(--muted);
}
.pager button:hover { background: #EFF6FF; border-color: #BFDBFE; }
.stats {
  background: #F8FAFC; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin-top: 10px;
}
.star-row .rail-item { border-radius: 999px; padding: 8px 14px; box-shadow: 0 1px 0 rgba(16,26,60,.04); }
h1 { letter-spacing: -.6px; }
.btn { transition: background .12s, color .12s, box-shadow .12s; }
.filters .btn { background: #fff; border: 1px solid var(--border); }
.filters .btn:hover { background: #F8FAFC; }
.chart-card h3 { font-size: 15px; }
.viz-svg { background: linear-gradient(180deg, #F8FAFC, #EEF2FF); }
table.grid tfoot td { background: #EEF2FF; }
tr.selrow td { background: #DBEAFE !important; box-shadow: inset 0 0 0 1px #93C5FD; }
.work-main > .card { min-height: 280px; }

@media print {
  .app-footer,
  .topbar, .pills, .filters, .rail, .ask, #askBtn, #focusBtn, #refresh, #signOut, #autoRef, .explain,
  .inspect, .drill-menu, .kbd-toast, .kbd-help, .sql-panel, .viz-toolbar, #colMenu, .vx-loading-host { display: none !important; }
  .workspace { display: block; }
  .gridwrap { max-height: none; overflow: visible; }
  .card.fs { position: static; inset: auto; }
  body { background: #fff; }
}

/* Loading overlay — same pattern as Family Bank MicroLens, Vortex navy */
.vx-loading-host {
  position: fixed; inset: 0; z-index: 100050;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease;
}
.vx-loading-host.is-on { opacity: 1; visibility: visible; pointer-events: auto; }
.vx-loading-host[hidden] { display: none !important; }
.vx-loading-scrim {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(76,86,242,.22), transparent 70%),
    rgba(16,26,60,.48);
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
}
.vx-loading-card {
  position: relative; z-index: 1; width: min(380px, 100%);
  padding: 28px 26px 22px; border-radius: 18px; text-align: center;
  color: #0f172a; background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 24px 60px rgba(16,26,60,.32);
  animation: vxLoadIn .35s cubic-bezier(.22,1,.36,1) both;
}
@keyframes vxLoadIn {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.vx-loading-ring {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 50%;
  background: conic-gradient(from 0deg, #101A3C 0deg, #4C56F2 140deg, transparent 140deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 0);
  animation: vxLoadSpin .85s linear infinite;
}
@keyframes vxLoadSpin { to { transform: rotate(360deg); } }
.vx-loading-brand {
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: #4C56F2; margin-bottom: 6px; opacity: .8;
}
.vx-loading-title {
  margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -.01em;
  color: #101A3C; line-height: 1.35;
}
.vx-loading-sub { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: #64748b; min-height: 1.4em; }
.vx-loading-bar {
  height: 4px; margin: 16px 0 0; border-radius: 99px; background: #EEF2FF; overflow: hidden;
}
.vx-loading-bar i {
  display: block; height: 100%; width: 38%; border-radius: 99px;
  background: linear-gradient(90deg, #4C56F2, #66CC00);
  animation: vxLoadBar 1.15s ease-in-out infinite;
}
@keyframes vxLoadBar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}
.vx-loading-actions { display: none; margin-top: 16px; gap: 8px; justify-content: center; flex-wrap: wrap; }
.vx-loading-host.is-stuck .vx-loading-actions { display: flex; }
.vx-loading-actions button {
  font: inherit; font-size: 12.5px; font-weight: 700; padding: 8px 14px;
  border-radius: 9px; cursor: pointer; border: 1px solid #e2e8f0; background: #fff; color: #0f172a;
}
.vx-loading-actions button.primary { background: #101A3C; border-color: #101A3C; color: #fff; }
.vx-loading-dots { display: inline-flex; gap: 4px; margin-left: 4px; vertical-align: middle; }
.vx-loading-dots i {
  width: 4px; height: 4px; border-radius: 50%; background: #4C56F2; opacity: .35;
  animation: vxLoadDot 1.2s ease-in-out infinite;
}
.vx-loading-dots i:nth-child(2) { animation-delay: .15s; }
.vx-loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes vxLoadDot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .vx-loading-ring, .vx-loading-dots i, .vx-loading-card, .vx-loading-bar i { animation: none !important; }
  .vx-loading-host { transition: none; }
}

/* Keyboard focus on clickable tiles and rows. */
.tile[role="button"]:focus-visible, .dtile[role="button"]:focus-visible {
  outline: 2px solid #93C5FD; outline-offset: 2px;
}

/* Branch multi-pick in the report / analytics filter bar. */
.branch-wrap { position: relative; }
.branch-btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #F8FAFC; border: 1px solid var(--border); }
.branch-pick { top: 100%; left: 0; margin-top: 6px; min-width: 240px; max-height: 340px; }
.branch-pick .bp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 8px; }
.branch-pick .bp-actions .btn { padding: 5px 9px; font-size: 12px; }
.branch-pick .bp-all { border-bottom: 1px solid var(--border); margin-bottom: 4px; padding-bottom: 6px; }
.branch-pick .bp-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; position: sticky; bottom: -10px; background: #fff; padding: 6px 0 2px; }
.scope-note { color: var(--muted); font-size: 12px; margin: 0 0 8px; }

/* Footer: same strip as the ERP shell (navy, user left, version right). */
.app-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 19;
  height: 28px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #101A3C; color: rgba(255,255,255,.65);
  font-size: 11px; line-height: 1;
}
.app-footer .foot-user { white-space: pre; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.app-footer .foot-ver { color: rgba(255,255,255,.55); font-weight: 600; white-space: nowrap; }
body:not(.is-login) { padding-bottom: 28px; }
@media (max-width: 700px) {
  .app-footer { padding: 0 12px; }
}
