/* ============================================================
   CloudMSP Billing — styles
   Built on the "C3 Dashboard" design system (see /design-system.html):
   dark-first, token-driven, floating neumorphic cards, DM Sans / DM Mono,
   fixed semantic palette (green=good, red=bad, blue=info, amber=warning).
   Re-theme by editing :root — components only reference var(--token).
   ============================================================ */

/* ---------- 1) Design tokens ---------- */
:root, :root[data-theme="dark"] {
  --bg: #0a0a0f; --bg2: #111118; --bg3: #18181f; --card: #1c1c25; --card2: #22222c;
  --border: #34344a; --border2: #41415a;
  --text: #e8e8f0; --text2: #9898b0; --text3: #5a5a72;

  --green: #22d07a; --green2: rgba(34,208,122,.14);
  --red:   #f05070; --red2:   rgba(240,80,112,.14);
  --blue:  #4d9fff; --blue2:  rgba(77,159,255,.14);
  --amber: #f5b730; --amber2: rgba(245,183,48,.14);
  --purple:#a78bfa; --purple2:rgba(167,139,250,.14);
  --cyan:  #38bdf8; --orange: #fb923c; --pink: #f472b6;
  --lime:  #a3e635; --lime2:  rgba(163,230,53,.16);

  /* brand accent aliased onto blue so the app stays token-driven */
  --brand: var(--blue); --brand-soft: var(--blue2);
  --hero: linear-gradient(135deg, #5a86ff, #2f5fe0);

  --grid: rgba(255,255,255,.05);
  --shadow: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.5);

  --neu-hi: rgba(255,255,255,.045); --neu-lo: rgba(0,0,0,.55);
  --neu-out:      -5px -5px 12px var(--neu-hi), 6px 6px 18px var(--neu-lo);
  --neu-out-soft: -2px -2px 6px  var(--neu-hi), 3px 3px 10px var(--neu-lo);
  --neu-in:  inset 2px 2px 6px var(--neu-lo), inset -2px -2px 6px var(--neu-hi);

  --r: 18px; --r2: 12px;
  --sidebar-w: 250px;
}

:root[data-theme="light"] {
  /* light, airy SaaS look — white sidebar/cards on a soft grey canvas */
  --bg: #f2f4f8; --bg2: #ffffff; --bg3: #eef1f6; --card: #ffffff; --card2: #f6f7fa;
  --border: #eaedf3; --border2: #dde2ec;
  --text: #0f1729; --text2: #5b6472; --text3: #97a0af;
  --green: #22b573; --green2: rgba(34,181,115,.12);
  --red:   #ef4a5e; --red2:   rgba(239,74,94,.11);
  --blue:  #3b6ef5; --blue2:  rgba(59,110,245,.10);
  --amber: #f0a020; --amber2: rgba(240,160,32,.14);
  --purple:#7c5cf0; --purple2:rgba(124,92,240,.10);
  --cyan:  #0891b2; --orange: #f0803c; --pink: #db2777;
  --lime:  #97d33e; --lime2:  rgba(151,211,62,.16);
  --hero: linear-gradient(135deg, #4d7cff, #2f5fe0);
  --grid: rgba(15,23,42,.05);
  --shadow: 0 4px 20px rgba(23,37,84,.06);
  --shadow-lg: 0 24px 60px rgba(23,37,84,.16);
  /* flat, soft drop-shadows (no neumorphic emboss in the light theme) */
  --neu-out: 0 4px 20px rgba(23,37,84,.06);
  --neu-out-soft: 0 2px 10px rgba(23,37,84,.05);
  --neu-in: inset 0 1px 2px rgba(23,37,84,.06);
}

/* ---------- 2) Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono, .num, .kpi-value, .stat__value { font-family: 'DM Mono', monospace; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text3); }

/* ---------- Layout shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  color: var(--text2); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; font-weight: 600; color: var(--text); font-size: 15px; }
.sidebar__brand .logo {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-size: 15px; box-shadow: 0 6px 14px color-mix(in srgb, var(--blue) 30%, transparent);
}
.sidebar__brand small { display: block; font-weight: 400; color: var(--text3); font-size: 11px; letter-spacing: .02em; }

.persona-switch { padding: 8px 12px 14px; border-bottom: 1px solid var(--border); }
.persona-switch__label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text2); padding: 6px 6px 8px; }
.persona-btn {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  color: var(--text2); padding: 9px 10px; border-radius: var(--r2); display: flex; gap: 9px; align-items: center;
  font-size: 12.5px; margin-bottom: 3px; transition: .12s;
}
.persona-btn:hover { background: var(--bg3); }
.persona-btn.active { background: var(--card); border-color: var(--border2); box-shadow: var(--neu-out-soft); }
.persona-btn__text { min-width: 0; }
.persona-btn__text b { display: block; color: var(--text); font-weight: 600; font-size: 12.5px; line-height: 1.25; }
.persona-btn__sub { font-size: 11px; color: var(--text3); }
.persona-btn .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }

.cust-switch { padding: 8px 2px 2px; }
.cust-switch label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text3); margin: 0 4px 6px; }
.cust-switch select { width: 100%; border: 1px solid var(--border2); background: var(--card); color: var(--text); border-radius: var(--r2); padding: 8px 10px; font-size: 12.5px; font-family: inherit; outline: none; cursor: pointer; }
.cust-switch select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue2); }

.nav { padding: 10px 12px; overflow-y: auto; flex: 1; }
.nav__group { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text2); padding: 16px 8px 6px; }
.nav__item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--r2); color: var(--text2); font-size: 13px; font-weight: 500; transition: .12s; margin-bottom: 1px; }
.nav__item:hover { background: var(--bg3); color: var(--text); }
.nav__item.active { background: var(--blue); color: #fff; box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 32%, transparent); }
.nav__item.active .badge { background: rgba(255,255,255,.22); color: #fff; border-color: transparent; }
.nav__label { flex: 1; }
.nav__item .badge { margin-left: auto; flex: none; }

/* ---------- Light-mode sidebar polish ---------- */
:root[data-theme="light"] .sidebar { border-right: 1px solid var(--border2); box-shadow: 4px 0 24px rgba(23,37,84,.035); }
:root[data-theme="light"] .persona-btn.active { background: #fff; border-color: var(--border2); box-shadow: 0 6px 16px rgba(23,37,84,.10), 0 0 0 1px var(--border2); }
:root[data-theme="light"] .nav__item.active { box-shadow: 0 6px 14px color-mix(in srgb, var(--blue) 22%, transparent); }
:root[data-theme="light"] .nav::-webkit-scrollbar { width: 8px; }
:root[data-theme="light"] .nav::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; }
:root[data-theme="light"] .nav::-webkit-scrollbar-track { background: transparent; }

.sidebar__foot { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 600; font-size: 17px; letter-spacing: -.3px; }
.topbar__crumb { color: var(--text3); font-size: 11.5px; font-family: 'DM Mono', monospace; }
.topbar__spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 9px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 18px; color: var(--text3);
  font-size: 13px; width: 320px;
}
.search input { border: none; background: transparent; outline: none; width: 100%; font-size: 13px; color: var(--text); font-family: inherit; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg3); display: grid; place-items: center; color: var(--text2); position: relative; transition: .15s; }
#menuBtn { display: none; border-radius: 12px; }
.iconbtn:hover { color: var(--blue); border-color: var(--blue); background: var(--blue2); }
.iconbtn .pip { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid var(--bg2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; box-shadow: var(--neu-out-soft); }
.topbar__user { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.topbar__user .who { line-height: 1.25; }
.topbar__user .who b { font-size: 13px; font-weight: 600; display: block; }
.topbar__user .who span { font-size: 11.5px; color: var(--text3); }

.content { padding: 28px 32px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* impersonation banner */
.imp-banner { background: var(--amber2); border: 1px solid var(--amber); color: var(--amber); border-radius: var(--r); padding: 11px 15px; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.imp-banner button { margin-left: auto; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.page-head p { margin: 6px 0 0; color: var(--text2); font-size: 13px; max-width: 80ch; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

/* ---------- Buttons ---------- */
.btn { background: var(--card); border: 1px solid var(--border2); color: var(--text2); border-radius: 999px; padding: 9px 16px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: all .15s; }
.btn:hover { color: var(--blue); background: var(--blue2); border-color: var(--blue); }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 26%, transparent); }
.btn--primary:hover { background: #2f5fe0; border-color: #2f5fe0; color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text2); }
.btn--ghost:hover { background: var(--card2); }
.btn--sm { padding: 6px 12px; font-size: 11.5px; }
.btn--danger { color: var(--red); border-color: var(--red); }
.btn--danger:hover { background: var(--red2); }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: 20px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2,1fr);} .grid--3{grid-template-columns:1fr 1fr;} }
@media (max-width: 760px) { .grid--4,.grid--3,.grid--2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--neu-out); overflow: hidden; transition: box-shadow .25s ease; }
.card:hover { box-shadow: var(--neu-out), var(--shadow); }
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card__head h3 { margin: 0; font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); }
.card__head .sub { color: var(--text3); font-size: 11px; }
.card__head .spacer { flex: 1; }
.card__body { padding: 20px; }
.card__body.tight { padding: 0; }

/* KPI stat — airy card: circular ↗ button, pill delta, subtext, + blue hero variant */
.stat { position: relative; padding: 22px; box-shadow: var(--neu-out-soft); transition: transform .2s ease, box-shadow .25s ease; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat__arrow { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--text2); display: grid; place-items: center; font-size: 14px; transition: .15s; }
.stat:hover .stat__arrow { background: var(--blue); color: #fff; border-color: var(--blue); }
.stat__label { color: var(--text2); font-size: 14px; font-weight: 600; letter-spacing: 0; padding-right: 34px; }
.stat__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stat__value { font-size: 26px; font-weight: 700; line-height: 1.05; letter-spacing: -.6px; }
.stat__delta { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 999px; }
.stat__delta.up { background: var(--green2); color: var(--green); }
.stat__delta.down { background: var(--red2); color: var(--red); }
.stat__delta.flat { background: var(--card2); color: var(--text3); }
.stat__sub { font-size: 12px; color: var(--text3); margin-top: 10px; }
.stat--hero { background: var(--hero); color: #fff; border-color: transparent; box-shadow: 0 16px 34px color-mix(in srgb, var(--blue) 34%, transparent); }
.stat--hero .stat__label { color: rgba(255,255,255,.88); }
.stat--hero .stat__value { color: #fff; }
.stat--hero .stat__sub { color: rgba(255,255,255,.8); }
.stat--hero .stat__delta { background: rgba(255,255,255,.22); color: #fff; }
.stat--hero .stat__arrow, .stat--hero:hover .stat__arrow { background: #fff; color: var(--blue); border-color: transparent; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 14px; background: var(--card2); color: var(--text2); white-space: nowrap; border: 1px solid var(--border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.badge--green { background: var(--green2); color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.badge--amber { background: var(--amber2); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge--red   { background: var(--red2);   color: var(--red);   border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.badge--blue  { background: var(--blue2);  color: var(--blue);  border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.badge--indigo{ background: var(--purple2);color: var(--purple);border-color: color-mix(in srgb, var(--purple) 40%, transparent); }
.badge--gray  { background: var(--card2);  color: var(--text2); border-color: var(--border); }
.badge--aws   { background: var(--amber2); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge--gcp   { background: var(--blue2);  color: var(--blue);  border-color: color-mix(in srgb, var(--blue) 40%, transparent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { text-align: left; padding: 12px 16px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); font-weight: 600; background: var(--bg3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--card2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .strong { font-weight: 600; color: var(--text); }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { color: var(--text3); font-size: 11.5px; }

/* ---------- Misc ---------- */
.muted { color: var(--text3); }
.right { text-align: right; }
.pos { color: var(--green); font-weight: 500; }
.neg { color: var(--red); font-weight: 500; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 2px; }
.wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.provider-ico { width: 22px; height: 22px; border-radius: 5px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.provider-ico.aws { background: var(--orange); color: #1a1a22; }
.provider-ico.gcp { background: var(--blue); color: #fff; }

.avatar-sm { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; flex: none; box-shadow: var(--neu-out-soft); }

/* progress / glossy bar */
.bar { height: 24px; background: linear-gradient(to right, var(--bg3), var(--border) 100%); border-radius: 6px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; border-radius: 6px; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.25); background: linear-gradient(90deg, var(--blue) 0%, var(--blue) 85%, color-mix(in srgb, var(--blue) 20%, transparent) 100%); transition: width .8s cubic-bezier(.2,.7,.1,1); }
.bar > span::after { content:''; position: absolute; inset: 0; border-radius: 6px; pointer-events: none; background: linear-gradient(to bottom, rgba(255,255,255,.24), rgba(255,255,255,0) 55%); }
.bar.green > span { background: linear-gradient(90deg, var(--green) 0%, var(--green) 85%, color-mix(in srgb, var(--green) 20%, transparent) 100%); }
.bar.amber > span { background: linear-gradient(90deg, var(--amber) 0%, var(--amber) 85%, color-mix(in srgb, var(--amber) 20%, transparent) 100%); }
.bar.red > span   { background: linear-gradient(90deg, var(--red) 0%, var(--red) 85%, color-mix(in srgb, var(--red) 20%, transparent) 100%); }

/* pipeline stages */
.pipeline { display: flex; align-items: center; gap: 6px; }
.pipeline .stage { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--text3); }
.pipeline .stage .pip { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; background: var(--bg3); color: var(--text3); font-family: 'DM Mono', monospace; }
.pipeline .stage.done .pip { background: var(--green); color: #fff; }
.pipeline .stage.active .pip { background: var(--blue); color: #fff; }
.pipeline .stage.done { color: var(--green); }
.pipeline .stage.active { color: var(--blue); }
.pipeline .arw { color: var(--border2); }

/* bar charts (towers) — interactive, rounded gradient bars w/ floating value pills */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 22px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; cursor: pointer; }
.chart .col .bar-pill { font-size: 10.5px; font-weight: 700; background: var(--card); color: var(--text2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; box-shadow: var(--shadow); white-space: nowrap; transition: .15s; }
.chart .col.col--hot .bar-pill { background: var(--blue); color: #fff; border-color: var(--blue); }
.chart .col .stack { width: 100%; max-width: 42px; border-radius: 12px 12px 8px 8px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; transform-origin: bottom; animation: growUp .55s cubic-bezier(.2,.7,.1,1) both; animation-delay: calc(var(--i, 0) * 55ms); transition: filter .15s ease; }
.chart .col .seg { transition: background .15s ease; }
.chart .col .seg-cost { background: color-mix(in srgb, var(--blue) 20%, var(--card)); }
.chart .col .seg-margin { background: linear-gradient(180deg, var(--lime), color-mix(in srgb, var(--lime) 72%, #000)); border-radius: 12px 12px 0 0; }
.chart .col .seg-solo { background: linear-gradient(180deg, #5a86ff, var(--blue)); border-radius: 12px 12px 8px 8px; }
.chart .col.col--hot .stack { filter: brightness(1.05) drop-shadow(0 6px 14px rgba(23,37,84,.16)); }
.chart .col.col--hot .lbl { color: var(--text); }
.chart .col .lbl { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; transition: color .15s ease; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .chart .col .stack, .donut-svg { animation: none !important; } }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text2); }
.legend .k { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* donut — SVG arcs, per-slice interactive */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { width: 150px; height: 150px; position: relative; flex: none; }
.donut-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform-origin: 50% 50%; animation: donutIn .55s ease both; overflow: visible; }
@keyframes donutIn { from { opacity: 0; transform: scale(.82) rotate(-10deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.donut-track { stroke: var(--bg3); }
.donut-seg { cursor: pointer; transition: stroke-width .18s ease, opacity .18s ease, filter .18s ease; }
.donut-seg.hot { stroke-width: 7.5; filter: brightness(1.12) drop-shadow(0 0 3px rgba(0,0,0,.45)); }
.donut-wrap.focus .donut-seg:not(.hot) { opacity: .42; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; z-index: 1; pointer-events: none; }
.donut-center b { font-size: 16px; display: block; font-family: 'DM Mono', monospace; font-weight: 500; line-height: 1.1; }
.donut-center span { font-size: 10.5px; color: var(--text3); line-height: 1.2; max-width: 88px; }
.donut-legend { display: flex; flex-direction: column; gap: 3px; font-size: 13px; flex: 1; }
.donut-legrow { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px; margin: 0 -8px; border-radius: 6px; transition: background .12s; }
.donut-legrow:hover, .donut-legrow.hot { background: var(--card2); }
.donut-legrow .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.donut-legrow .amt { margin-left: auto; font-weight: 500; font-family: 'DM Mono', monospace; }

/* chart tooltip (cursor-following) */
.chart-tip { position: fixed; z-index: 300; pointer-events: none; background: var(--bg2); border: 1px solid var(--border2); color: var(--text); font-size: 12px; padding: 8px 11px; border-radius: 8px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease; max-width: 240px; line-height: 1.45; }
.chart-tip.on { opacity: 1; transform: translateY(0); }
.chart-tip b { font-weight: 600; }

/* semicircle gauge */
.gauge { position: relative; width: 100%; max-width: 200px; margin: 0 auto; text-align: center; cursor: default; }
.gauge-svg { width: 100%; display: block; overflow: visible; }
.gauge-track { stroke: var(--bg3); }
.gauge-val { animation: gaugeIn .8s cubic-bezier(.2,.7,.1,1) both; }
@keyframes gaugeIn { from { stroke-dasharray: 0 100; } }
.gauge-center { margin-top: -14px; }
.gauge-center b { display: block; font-family: 'DM Mono', monospace; font-size: 24px; font-weight: 600; line-height: 1; }
.gauge-center span { font-size: 11.5px; color: var(--text3); }
.gauge-sub { font-size: 11.5px; color: var(--text3); margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .gauge-val { animation: none; } }

/* ranked horizontal bars */
.ranklist { display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: grid; grid-template-columns: 150px 1fr 92px; gap: 12px; align-items: center; }
.rank-name { font-size: 12.5px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 22px; background: var(--bg3); border-radius: 6px; overflow: hidden; position: relative; }
.rank-bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), color-mix(in srgb, var(--blue) 55%, var(--card))); transition: width .8s cubic-bezier(.2,.7,.1,1); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.rank-val { font-size: 12.5px; font-weight: 600; font-family: 'DM Mono', monospace; text-align: right; }
.rank-row:hover .rank-bar > span { filter: brightness(1.08); }

/* commitment expiry timeline */
.timeline { padding: 22px 6px 6px; }
.timeline-track { position: relative; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--red2), var(--amber2) 33%, var(--green2)); }
.tl-marker { position: absolute; top: 50%; transform: translate(-50%, -50%); cursor: pointer; }
.tl-marker i { display: block; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform .12s ease; }
.tl-marker.urg-hi i { background: var(--red); }
.tl-marker.urg-md i { background: var(--amber); }
.tl-marker.urg-lo i { background: var(--green); }
.tl-marker:hover i { transform: scale(1.35); }
.timeline-axis { position: relative; height: 16px; margin-top: 8px; }
.timeline-axis span { position: absolute; transform: translateX(-50%); font-size: 10.5px; color: var(--text3); font-family: 'DM Mono', monospace; }

/* list rows */
.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 15px; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .main b { font-size: 13px; font-weight: 600; color: var(--text); }
.list-row .main div { color: var(--text3); font-size: 12px; }
.ic-red { background: var(--red2); color: var(--red); }
.ic-amber { background: var(--amber2); color: var(--amber); }
.ic-green { background: var(--green2); color: var(--green); }
.ic-blue { background: var(--blue2); color: var(--blue); }
.ic-indigo { background: var(--purple2); color: var(--purple); }

/* segmented tabs */
.tabs { display: inline-flex; gap: 2px; background: var(--bg3); padding: 3px; border-radius: var(--r2); margin-bottom: 18px; border: 1px solid var(--border); }
.tabs button { border: none; background: transparent; padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--text2); }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--neu-out-soft); }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 6px; color: var(--text2); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--r2); padding: 9px 11px; font-size: 13px; font-family: inherit; outline: none; background: var(--card2); color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue2); }
.field .hint { font-size: 11.5px; color: var(--text3); margin-top: 4px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; padding: 24px; }
.modal { background: var(--card); border: 1px solid var(--border2); border-radius: var(--r); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; }
.modal__head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal__head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.3px; }
.modal__head .close { margin-left: auto; }
.modal__body { padding: 20px 22px; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.wizard-steps { display: flex; gap: 8px; margin-bottom: 20px; }
.wizard-steps .st { flex: 1; text-align: center; font-size: 11.5px; font-weight: 500; color: var(--text3); }
.wizard-steps .st .n { width: 26px; height: 26px; border-radius: 50%; background: var(--bg3); color: var(--text3); display: grid; place-items: center; margin: 0 auto 6px; font-size: 12px; font-family: 'DM Mono', monospace; }
.wizard-steps .st.active .n { background: var(--blue); color: #fff; }
.wizard-steps .st.done .n { background: var(--green); color: #fff; }

/* option cards */
.opt-card { border: 1px solid var(--border); border-radius: var(--r2); padding: 14px; cursor: pointer; transition: .12s; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; background: var(--card2); }
.opt-card:hover { border-color: var(--border2); }
.opt-card.selected { border-color: var(--blue); background: var(--blue2); }
.opt-card .oc-ic { width: 38px; height: 38px; border-radius: var(--r2); display: grid; place-items: center; flex: none; font-size: 18px; background: var(--bg3); }
.opt-card h4 { margin: 0 0 3px; font-size: 13px; font-weight: 600; }
.opt-card p { margin: 0; font-size: 12px; color: var(--text3); }

.empty { text-align: center; padding: 40px; color: var(--text3); }

/* toasts */
.toast-host { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--card); border: 1px solid var(--border2); color: var(--text); padding: 12px 16px; border-radius: var(--r2); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: slidein .2s ease; }
.toast .tc { color: var(--green); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

/* definition list */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13px; }
.dl dt { color: var(--text3); }
.dl dd { margin: 0; font-weight: 500; color: var(--text); }

/* RBAC permission matrix */
.tbl.matrix th.matrix-role { text-align: center; white-space: normal; min-width: 96px; font-size: 10px; line-height: 1.3; vertical-align: bottom; }
.tbl.matrix .matrix-cap { position: sticky; left: 0; background: var(--card); min-width: 230px; z-index: 1; font-weight: 500; color: var(--text); }
.tbl.matrix thead th.matrix-cap { background: var(--bg3); z-index: 2; }
.tbl.matrix .matrix-cell { text-align: center; }
.tbl.matrix tr.matrix-area td { position: sticky; left: 0; background: var(--bg3); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); font-weight: 600; padding: 8px 16px; }
.tbl.matrix tbody tr:hover td:not(.matrix-cap) { background: var(--card2); }
.rbac-ok { color: var(--green); font-weight: 700; }
.rbac-no { color: var(--text3); }

/* guided page tours (spotlight coach-marks) */
.btn-tour { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, var(--border2)); }
.btn-tour:hover { background: var(--blue2); }
.tour-catch { position: fixed; inset: 0; z-index: 150; background: transparent; cursor: default; }
.tour-spot { position: fixed; z-index: 151; border-radius: 12px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(9,14,30,.62), 0 0 0 2px var(--blue), 0 0 0 6px color-mix(in srgb, var(--blue) 35%, transparent); transition: left .28s cubic-bezier(.2,.7,.1,1), top .28s cubic-bezier(.2,.7,.1,1), width .28s, height .28s, opacity .2s; }
.tour-tip { position: fixed; z-index: 160; width: 320px; max-width: calc(100vw - 24px); background: var(--card); border: 1px solid var(--border2); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 16px 18px; transition: left .28s cubic-bezier(.2,.7,.1,1), top .28s cubic-bezier(.2,.7,.1,1); animation: tipIn .2s ease; }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } }
.tour-x { position: absolute; top: 10px; right: 10px; border: none; background: transparent; color: var(--text3); font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.tour-x:hover { background: var(--card2); color: var(--text); }
.tour-tip__title { font-size: 14.5px; font-weight: 700; padding-right: 20px; margin-bottom: 6px; }
.tour-tip__body { font-size: 12.5px; color: var(--text2); line-height: 1.5; }
.tour-tip__foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.tour-count { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; }
.tour-dots { display: flex; gap: 5px; flex: 1; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border2); }
.tour-dots span.on { background: var(--blue); }
.tour-controls { display: flex; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-tip { transition: none; } .tour-tip { animation: none; } }

/* toggle switch */
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 12.5px; color: var(--text2); margin-top: 8px; }
.switch { width: 34px; height: 20px; background: var(--border2); border-radius: 12px; position: relative; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--text2); border-radius: 50%; transition: .15s; }
.switch-row input, .toggle input { display: none; }
.switch-row input:checked + .switch, .toggle input:checked + .switch { background: var(--blue); }
.switch-row input:checked + .switch::after, .toggle input:checked + .switch::after { left: 16px; background: #fff; }

/* settings layout */
.settings-layout { display: grid; grid-template-columns: 232px 1fr; gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 8px; box-shadow: var(--neu-out-soft); }
.settings-nav__item { padding: 9px 12px; border-radius: var(--r2); color: var(--text2); font-size: 13px; font-weight: 500; cursor: pointer; transition: .12s; }
.settings-nav__item:hover { background: var(--card2); color: var(--text); }
.settings-nav__item.active { background: var(--blue2); color: var(--text); border: 1px solid color-mix(in srgb, var(--blue) 40%, transparent); }
.settings-panel { min-width: 0; }

/* invoice document template */
.invoice-doc { background: var(--card); border-radius: var(--r); }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 20px; border-bottom: 2px solid var(--border2); margin-bottom: 22px; gap: 16px; }
.inv-brand { display: flex; gap: 12px; align-items: center; }
.inv-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; box-shadow: var(--neu-out-soft); }
.inv-brandname { font-size: 16px; font-weight: 600; }
.inv-title { text-align: right; }
.inv-title h2 { margin: 0; font-size: 22px; letter-spacing: 3px; font-weight: 600; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; margin-bottom: 22px; }
.inv-plabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); margin-bottom: 7px; }
.inv-pname { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.inv-paddr { font-size: 12.5px; line-height: 1.5; }
.inv-dates { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; min-width: 170px; }
.inv-dates > div { display: flex; justify-content: space-between; gap: 20px; }
.inv-dates b { font-family: 'DM Mono', monospace; font-weight: 500; }
.inv-items { width: 100%; border-collapse: collapse; margin-bottom: 22px; font-size: 13px; }
.inv-items thead th { text-align: left; padding: 10px 12px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); border-bottom: 1px solid var(--border2); }
.inv-items thead th.num, .inv-items td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-items tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.inv-summary { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.inv-terms { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 14px 16px; }
.inv-totals { display: flex; flex-direction: column; gap: 1px; }
.inv-trow { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 13px; }
.inv-grand { border-top: 2px solid var(--border2); margin-top: 6px; padding-top: 12px; font-weight: 700; }
.inv-grand .mono { font-size: 17px; }
.inv-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; text-align: center; }
@media (max-width: 640px) {
  .inv-parties, .inv-summary { grid-template-columns: 1fr; }
  .inv-head { flex-direction: column; }
  .inv-title { text-align: left; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .search { display: none; }
  #menuBtn { display: grid; }
  .page-head { flex-wrap: wrap; }
  .page-head__actions { margin-left: 0; }
  .content { padding: 18px; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}
