:root {
  --bg: #090d19;
  --bg-soft: #0d1324;
  --panel: rgba(19, 27, 48, .9);
  --panel-strong: #151f38;
  --panel-soft: #10182c;
  --line: rgba(152, 169, 211, .16);
  --line-bright: rgba(157, 132, 255, .38);
  --text: #f4f6ff;
  --muted: #9aa7c8;
  --violet: #9b82ff;
  --violet-soft: #735dce;
  --pink: #ff74b2;
  --green: #60deb0;
  --yellow: #f4c766;
  --red: #ff819e;
  --blue: #69b8ff;
  --radius: 24px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 80% -10%, rgba(116, 94, 206, .28), transparent 65%),
    radial-gradient(700px 500px at -10% 30%, rgba(255, 116, 178, .09), transparent 68%),
    var(--bg);
  font: 15px/1.5 Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 86%);
}

.topbar {
  height: 76px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 26px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(9, 13, 25, .8);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(130%);
}
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  font: 700 17px Unbounded, sans-serif;
  letter-spacing: .03em;
}
.brand-mark { width: 32px; height: 32px; object-fit: contain; border-radius: 50%; margin-right: 10px; filter: drop-shadow(0 0 12px rgba(255,116,178,.2)); }
.report-meta { flex: 1; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { color: var(--violet); padding: 0 8px; }
.top-actions { display: flex; gap: 8px; }

.layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  padding: 30px 16px 20px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(9, 13, 25, .34);
}
.side-title, .eyebrow, .lab-label {
  color: var(--violet);
  font: 600 10px JetBrains Mono, monospace;
  letter-spacing: .15em;
}
.side-title { padding: 0 13px 13px; }
.nav {
  min-height: 46px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: .18s ease;
}
.nav b { width: 18px; color: var(--violet); text-align: center; font-size: 16px; }
.nav:hover { color: #fff; background: rgba(155, 130, 255, .08); }
.nav.active { color: #fff; background: linear-gradient(135deg, rgba(155,130,255,.18), rgba(255,116,178,.07)); border-color: rgba(155,130,255,.22); box-shadow: inset 3px 0 0 var(--violet); }
.side-note { margin-top: auto; padding: 15px; color: #6f7d9f; font-size: 11px; line-height: 1.55; }

main { width: 100%; max-width: 1540px; margin: 0 auto; padding: 44px clamp(20px, 4vw, 66px) 90px; }
.section { display: none; }
.section.active { display: block; animation: section-in .36s ease both; }
@keyframes section-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
h1 { margin: 12px 0 10px; font: 700 clamp(30px, 4vw, 49px)/1.1 Unbounded, sans-serif; letter-spacing: -.045em; }
h2 { margin: 0 0 6px; font: 600 17px/1.3 Unbounded, sans-serif; letter-spacing: -.02em; }
h3 { margin: 26px 0 14px; font: 700 16px Unbounded, sans-serif; }
p { margin: 0; }
.lead { max-width: 780px; margin-bottom: 30px; color: var(--muted); font-size: 16px; }
.muted { color: var(--muted); }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(96,222,176,.18);
  border-radius: 999px;
  background: rgba(96,222,176,.07);
  color: #a8ecd2;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(96,222,176,.08); }

.grid { display: grid; gap: 18px; margin-top: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .kpi {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(22,31,54,.95), rgba(14,21,39,.94));
  box-shadow: var(--shadow);
}
.card::before, .kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 62%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  pointer-events: none;
}
.card { padding: 24px; }
.card.spotlight { background: linear-gradient(145deg, rgba(31,39,69,.98), rgba(13,20,37,.96)); }
.kpi { padding: 19px; min-height: 126px; transition: transform .2s ease, border-color .2s ease; }
.kpi:hover { transform: translateY(-2px); border-color: var(--line-bright); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { margin-top: 10px; font: 700 clamp(21px, 2vw, 28px) Unbounded, sans-serif; letter-spacing: -.04em; }
.kpi-delta { margin-top: 9px; color: var(--green); font-size: 11px; font-weight: 700; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.card-head p { color: var(--muted); font-size: 13px; }
.hero-finance {
  background:
    radial-gradient(470px 220px at 100% 0, rgba(255,116,178,.15), transparent 70%),
    linear-gradient(140deg, rgba(50,39,96,.98), rgba(18,27,48,.97));
}
.badge { padding: 7px 10px; border-radius: 999px; background: rgba(96,222,176,.11); color: var(--green); font-size: 11px; font-weight: 800; }
.fact-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 23px 0; }
.fact-grid > div { padding: 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 15px; background: rgba(6,10,22,.22); }
.fact-grid span { display: block; color: #abb6d2; font-size: 11px; }
.fact-grid b { display: block; margin-top: 7px; font: 700 19px Unbounded, sans-serif; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--pink)); box-shadow: 0 0 18px rgba(155,130,255,.28); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.progress + small { display: block; margin-top: 10px; }

select, input {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: #0c1427;
  color: var(--text);
  font-size: 13px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
select:focus, input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(155,130,255,.1); }
.ghost, .link-btn, .icon-button {
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: .18s ease;
}
.ghost { min-height: 40px; padding: 8px 13px; border-radius: 11px; color: var(--text); }
.ghost.compact { display: inline-flex; align-items: center; gap: 8px; }
.ghost.compact b { color: var(--violet); }
.ghost:hover, .icon-button:hover { border-color: var(--violet); background: rgba(155,130,255,.08); color: #fff; }
.ghost.mini { min-height: 34px; padding: 6px 9px; text-decoration: none; font-size: 12px; }
.link-btn { padding: 5px; border-color: transparent; color: #b8a8ff; font-weight: 800; }
.link-btn:hover { color: #fff; }
.icon-button { min-width: 38px; min-height: 38px; padding: 4px 8px; border-radius: 10px; color: #a5b0cc; }

.chart { min-height: 280px; }
.chart.tall { min-height: 355px; }
.chart-legend { display: flex; gap: 22px; flex-wrap: wrap; margin: -4px 0 8px; color: #c7d0e8; font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend-line { display: inline-block; width: 28px; height: 3px; border-radius: 3px; background: var(--violet); }
.legend-line.prediction { background: repeating-linear-gradient(90deg, var(--pink) 0 7px, transparent 7px 11px); }
.chart-hint { margin-top: 6px; color: #7582a4; font-size: 11px; }
.line-chart { overflow-x: auto; overflow-y: hidden; }
.revenue-svg { width: 100%; min-width: 660px; height: auto; overflow: visible; }
.chart-grid { stroke: rgba(160,174,212,.12); stroke-width: 1; }
.chart-axis-y, .chart-axis-x { fill: #7785a8; font: 10px JetBrains Mono, monospace; }
.chart-axis-y { text-anchor: end; }
.chart-axis-x { text-anchor: middle; }
.chart-area { fill: rgba(155, 130, 255, .12); }
.chart-line { fill: none; stroke: var(--series); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-line.is-forecast { stroke-dasharray: 9 8; }
.chart-point circle:last-child { fill: var(--series); stroke: #151f38; stroke-width: 3; transition: r .16s ease; }
.point-hit { fill: transparent; cursor: pointer; }
.chart-point:hover circle:last-child, .chart-point:focus circle:last-child { r: 6.5px; }
.interactive-bars {
  min-height: 315px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 26px 4px 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.bar-column {
  flex: 1 0 62px;
  min-width: 62px;
  height: 270px;
  padding: 0;
  display: grid;
  grid-template-rows: 30px 1fr 42px;
  align-items: end;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.bar-column i { width: min(34px, 70%); min-height: 4px; margin: 0 auto; border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, var(--pink), var(--violet)); box-shadow: 0 0 20px rgba(155,130,255,.15); transition: filter .18s ease, transform .18s ease; }
.bar-column:hover i, .bar-column:focus i { filter: brightness(1.2); transform: scaleX(1.08); }
.bar-value { align-self: start; color: #cbd4eb; font: 600 9px JetBrains Mono, monospace; white-space: nowrap; }
.bar-label { align-self: start; padding-top: 8px; color: #8592b2; font-size: 10px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.analytics-table { border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.analytics-table-head, .analytics-table button { display: grid; grid-template-columns: minmax(160px, 1fr) 150px 90px; gap: 12px; align-items: center; padding: 13px 15px; }
.analytics-table-head { background: rgba(255,255,255,.035); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.analytics-table button { width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.analytics-table button:hover { background: rgba(155,130,255,.06); }
.analytics-table small { color: var(--muted); }

.analytics-lab { background: radial-gradient(600px 260px at 100% 0, rgba(105,184,255,.09), transparent 70%), linear-gradient(145deg, rgba(27,37,65,.98), rgba(13,20,37,.97)); }
.lab-label { display: block; margin-bottom: 7px; color: var(--blue); }
.analytics-controls { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 10px; margin-bottom: 17px; }
.analytics-controls label { display: grid; gap: 6px; color: #7f8dac; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.analytics-controls select, .analytics-controls input { width: 100%; text-transform: none; letter-spacing: 0; }
.substats { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.substat { padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(10,16,31,.55); color: var(--muted); font-size: 11px; }
.substat b { margin-left: 5px; color: #fff; }

.insights { display: grid; gap: 10px; }
.insight {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid rgba(155,130,255,.12);
  border-left: 3px solid var(--violet);
  border-radius: 13px;
  background: rgba(12,20,39,.68);
  color: #d8dff1;
  text-align: left;
}
button.insight { cursor: pointer; }
button.insight:hover { background: rgba(155,130,255,.08); }
.insight strong, .insight span { display: block; }
.insight strong { margin-bottom: 4px; color: #fff; }
.mini-callout, .metric-note { margin-top: 16px; padding: 13px 14px; border-radius: 13px; background: rgba(155,130,255,.075); color: #c8d1e8; font-size: 12px; }
.inline-client, .table-link { padding: 0; border: 0; background: transparent; color: #c1b3ff; font-weight: 800; cursor: pointer; text-align: left; }
.inline-client:hover, .table-link:hover { color: #fff; text-decoration: underline; }

.segments { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.segments.wide { grid-template-columns: repeat(5, minmax(0,1fr)); margin-bottom: 18px; }
.segment { min-height: 103px; padding: 14px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 15px; background: rgba(10,16,31,.48); cursor: pointer; text-align: left; transition: .18s ease; }
.segment:hover { border-color: var(--line-bright); transform: translateY(-2px); }
.segment small { color: var(--muted); }
.segment b { margin: 4px 0; font: 700 23px Unbounded, sans-serif; }
.segment span { margin-top: auto; color: #8073b9; font-size: 10px; font-weight: 800; }
.upcoming-item { width: 100%; min-height: 65px; padding: 11px 2px; display: flex; justify-content: space-between; gap: 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.upcoming-item:last-child { border-bottom: 0; }
.upcoming-item:hover { color: #fff; }
.upcoming-item > span { display: grid; }
.upcoming-item > span:last-child { text-align: right; }
.upcoming-item small { color: var(--muted); }
.upcoming-item i { color: #aa9aff; font-style: normal; font-size: 11px; }
.service-mini-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.service-tile { min-height: 142px; padding: 16px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 16px; background: rgba(10,16,31,.48); cursor: pointer; text-align: left; transition: .18s ease; }
.service-tile:hover { border-color: var(--line-bright); transform: translateY(-2px); }
.service-tile > span { color: #625799; font: 600 10px JetBrains Mono; }
.service-tile b { margin: 9px 0 auto; font-size: 15px; }
.service-tile strong { font: 600 17px Unbounded; }
.service-tile small { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0 18px; }
.toolbar input:first-child { min-width: 270px; flex: 1; }
.table-card { padding: 0; }
.table-wrap { overflow: auto; scrollbar-width: thin; }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 15px 17px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; font-size: 12px; }
th { color: #7f8dac; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
tbody tr:hover { background: rgba(155,130,255,.035); }
.client-main { display: flex; align-items: center; gap: 9px; min-width: 180px; }
.client-profile { padding: 0; display: inline-flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.client-profile:hover b { color: #c7bbff; }
.avatar { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #493a86, #d35b98); color: #fff; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.avatar.large { width: 54px; height: 54px; font-size: 20px; }
.client-contact { display: grid; min-width: 0; }
.client-contact small { color: #7d8aa9; }
.user-link { color: #bbaaFF; text-decoration: none; font-size: 11px; }
.user-link:hover { color: #fff; text-decoration: underline; }
.actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.status, .payment { display: inline-flex; width: max-content; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status.completed, .status.loyal, .payment.paid { color: var(--green); background: rgba(96,222,176,.11); }
.status.upcoming, .status.new { color: #b9aeff; background: rgba(155,130,255,.13); }
.status.pending, .status.sleeping, .payment.waiting { color: var(--yellow); background: rgba(244,199,102,.11); }
.status.cancelled, .status.lost { color: #ff9ab3; background: rgba(255,116,178,.11); }
.payment.neutral { color: #91a0c1; background: rgba(145,160,193,.08); }
.payment-row { margin-top: 10px; }
.pager { padding: 15px; display: flex; justify-content: center; align-items: center; gap: 16px; }
.mobile-pager, .mobile-cards { display: none; }

.donut-wrap { min-height: 280px; display: flex; align-items: center; justify-content: center; gap: 24px; }
.donut { flex: 0 0 auto; width: 190px; height: 190px; position: relative; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; }
.donut::after { content: ""; position: absolute; inset: 40px; border-radius: 50%; background: #151f38; box-shadow: inset 0 0 0 1px var(--line); }
.donut-center { position: relative; z-index: 1; display: grid; text-align: center; }
.donut-center b { font: 600 16px Unbounded; }
.donut-center small { color: var(--muted); font-size: 10px; }
.donut-legend { display: grid; gap: 7px; width: min(260px, 100%); }
.donut-legend button { width: 100%; display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; border: 0; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.donut-legend i { width: 9px; height: 9px; border-radius: 3px; }
.donut-legend b { color: #fff; }
.service-row { width: 100%; display: grid; grid-template-columns: 170px 1fr 95px; gap: 12px; align-items: center; padding: 13px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.service-row:last-child { border-bottom: 0; }
.bar { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--pink)); }
.service-row small { text-align: right; color: var(--muted); }

.plan-fact { display: grid; gap: 12px; }
.plan-row { display: grid; grid-template-columns: 110px 1fr 100px; gap: 10px; align-items: center; font-size: 11px; }
button.plan-row { width: 100%; padding: 6px 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.plan-row > span { color: var(--muted); }
.plan-row > b { text-align: right; }
.plan-line { height: 9px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.plan-line i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--green)); }
.forecast-line i { background: repeating-linear-gradient(90deg, var(--pink) 0 8px, rgba(255,116,178,.35) 8px 12px); }
.waiting-line i { background: var(--yellow); }
.metric-card { min-height: 190px; }
.big-number { margin: 27px 0 8px; font: 700 40px Unbounded, sans-serif; letter-spacing: -.05em; }

.lv-legend { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.lv-pill { padding: 5px 8px; border-radius: 8px; font-size: 10px; font-weight: 800; }
.lv-high { color: var(--green); background: rgba(96,222,176,.1); }
.lv-mid { color: #b9aeff; background: rgba(155,130,255,.12); }
.lv-low { color: var(--yellow); background: rgba(244,199,102,.1); }
.dna-code { color: #d8d0ff; font: 600 11px JetBrains Mono; }
.type-row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.type-row b { text-align: right; }

.scenario-switch { width: max-content; max-width: 100%; margin: -4px 0 20px; padding: 4px; display: flex; border: 1px solid var(--line); border-radius: 14px; background: rgba(10,16,31,.55); overflow-x: auto; }
.scenario-switch button { min-height: 38px; padding: 8px 13px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.scenario-switch button.active { background: linear-gradient(135deg, rgba(155,130,255,.24), rgba(255,116,178,.12)); color: #fff; }
.forecast-row { width: 100%; padding: 14px 0; display: flex; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.forecast-row:last-child { border-bottom: 0; }
.forecast-row:hover span { color: #fff; }
.forecast-row span { color: var(--muted); }
.momentum-row { width: 100%; padding: 11px 0; display: flex; justify-content: space-between; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.momentum-row span { display: grid; }
.momentum-row small { color: var(--muted); }
.momentum-row strong { font: 700 12px JetBrains Mono; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.explain { max-width: 820px; line-height: 1.75; }

.empty-state { min-height: 150px; padding: 24px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state b, .empty-state span { display: block; }
.empty-state b { margin-bottom: 5px; color: #dfe4f5; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: calc(100vw - 40px); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #1a2644; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }

.modal { position: fixed; inset: 0; z-index: 50; padding: 20px; display: none; align-items: center; justify-content: center; background: rgba(3,6,13,.76); backdrop-filter: blur(10px); }
.modal.open { display: flex; animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box { width: min(720px, 100%); max-height: min(90vh, 860px); padding: 27px; position: relative; overflow: auto; border: 1px solid var(--line-bright); border-radius: 24px; background: linear-gradient(145deg, #18233e, #10182c); box-shadow: 0 34px 100px rgba(0,0,0,.5); }
.wide-modal { width: min(850px, 100%); }
.modal-close { position: sticky; top: -15px; z-index: 2; float: right; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: #131d34; color: var(--muted); font-size: 24px; cursor: pointer; }
.modal-profile { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.modal-profile h2 { margin: 0 0 3px; }
.modal-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-right: 50px; margin-bottom: 22px; }
.modal-title-row h2 { margin-top: 9px; font-size: 23px; }
.modal-title-row > b { font: 700 22px Unbounded; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin: 18px 0; }
.detail-chip { min-height: 77px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(8,13,26,.32); }
.detail-chip span, .detail-chip b { display: block; }
.detail-chip span { color: var(--muted); font-size: 10px; }
.detail-chip b { margin-top: 6px; }
.modal-actions { margin: 14px 0; }
.timeline { padding-left: 16px; display: grid; gap: 9px; border-left: 2px solid var(--violet); }
.timeline-item { width: 100%; padding: 12px 13px; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,16,31,.5); text-align: left; cursor: pointer; }
.timeline-item small { color: var(--muted); }
.timeline-item em { color: #c4cee5; font-size: 11px; font-style: normal; }
.drill-list { display: grid; gap: 8px; }
.drill-list button { width: 100%; padding: 12px 13px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,16,31,.45); text-align: left; cursor: pointer; }
.drill-list button:hover { border-color: var(--line-bright); }
.drill-list span { display: grid; }
.drill-list small { color: var(--muted); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 210px minmax(0,1fr); }
  .analytics-controls { grid-template-columns: repeat(3, minmax(140px,1fr)); }
  .segments.wide { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .service-mini-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    width: 100%;
    height: calc(70px + env(safe-area-inset-bottom));
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    flex-direction: row;
    gap: 3px;
    overflow-x: auto;
    border: 0;
    border-top: 1px solid var(--line);
    background: rgba(9,13,25,.94);
    backdrop-filter: blur(22px);
    box-shadow: 0 -14px 40px rgba(0,0,0,.28);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .side-title, .side-note { display: none; }
  .nav {
    flex: 1 0 74px;
    min-width: 74px;
    height: 56px;
    padding: 5px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-radius: 11px;
    text-align: center;
    font-size: 10px;
  }
  .nav b { width: auto; font-size: 16px; line-height: 1; }
  .nav.active { box-shadow: inset 0 2px 0 var(--violet); }
  main { padding-bottom: 108px; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .topbar { padding: 0 18px; }
  .report-meta { display: none; }
  .desktop-table { display: none; }
  .mobile-cards { display: grid; gap: 10px; }
  .mobile-pager { display: flex; }
  .mobile-card { padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, rgba(22,31,54,.96), rgba(14,21,39,.95)); box-shadow: 0 14px 35px rgba(0,0,0,.16); }
  .mobile-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 13px; }
  .mobile-card-head > span:first-child { display: grid; }
  .mobile-card-head small { color: var(--muted); }
  .mobile-card-head b { margin-top: 2px; }
  .mobile-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; margin: 13px 0; }
  .mobile-stats > span { min-height: 60px; padding: 9px; display: grid; align-content: space-between; border-radius: 11px; background: rgba(8,13,26,.38); }
  .mobile-stats small { color: var(--muted); font-size: 9px; }
  .mobile-stats b { font-size: 11px; }
  .appointment-card { cursor: pointer; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 650px) {
  .topbar { height: 64px; }
  .brand { font-size: 14px; }
  .brand-mark { width: 28px; height: 28px; }
  .top-actions .ghost { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; }
  .top-actions .ghost span { display: none; }
  main { padding: 28px 14px 105px; }
  h1 { font-size: clamp(27px, 9vw, 36px); }
  .lead { margin-bottom: 23px; font-size: 14px; }
  .section-heading { display: block; }
  .live-pill { margin: -9px 0 22px; }
  .kpis { gap: 9px; }
  .kpi { min-height: 110px; padding: 15px; }
  .kpi-value { font-size: 19px; }
  .card { padding: 18px; border-radius: 19px; }
  .card-head { margin-bottom: 16px; }
  .responsive-head { display: grid; }
  .responsive-head select { width: 100%; }
  .fact-grid { grid-template-columns: 1fr; }
  .fact-grid > div { min-height: 74px; }
  .analytics-controls { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .analytics-controls label:nth-last-child(-n+3) { grid-column: span 1; }
  .segments.wide { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .service-mini-grid { grid-template-columns: 1fr 1fr; }
  .service-tile { min-height: 130px; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar input:first-child { min-width: 0; grid-column: 1 / -1; }
  .toolbar select, .toolbar input { width: 100%; min-width: 0; }
  .donut-wrap { flex-direction: column; }
  .donut { width: 164px; height: 164px; }
  .donut::after { inset: 35px; }
  .service-row { grid-template-columns: minmax(90px,130px) 1fr 80px; }
  .plan-row { grid-template-columns: 90px 1fr 77px; }
  .grid.three { grid-template-columns: 1fr; }
  .metric-card { min-height: 150px; }
  .big-number { margin-top: 20px; font-size: 34px; }
  .scenario-switch { width: 100%; }
  .scenario-switch button { flex: 1; }
  .revenue-svg { min-width: 600px; }
  .chart { min-height: 250px; }
  .chart.tall { min-height: 310px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { width: 100%; max-height: 92vh; padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .modal-title-row { padding-right: 42px; }
  .modal-title-row > b { font-size: 17px; }
  .modal-actions { display: grid; grid-template-columns: 1fr; }
  .modal-actions .ghost { width: 100%; text-align: center; }
  .toast { right: 12px; bottom: calc(82px + env(safe-area-inset-bottom)); }
  .analytics-table-head, .analytics-table button { grid-template-columns: minmax(120px,1fr) 100px 55px; }
}

@media (max-width: 420px) {
  .analytics-controls { grid-template-columns: 1fr; }
  .segments, .segments.wide { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .segment { min-height: 95px; }
  .service-mini-grid { grid-template-columns: 1fr; }
  .mobile-stats { grid-template-columns: 1fr 1fr; }
  .chart-legend { gap: 12px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .sidebar, .toolbar, .top-actions, .scenario-switch, .ghost, .link-btn, .actions, .pager, .chart-hint { display: none !important; }
  body { background: #fff; color: #111; }
  .layout { display: block; }
  main { max-width: none; padding: 0; }
  .section { display: block !important; page-break-before: always; }
  .section:first-child { page-break-before: auto; }
  .card, .kpi { break-inside: avoid; background: #fff; color: #111; border-color: #ddd; box-shadow: none; }
  .muted, .card-head p, th { color: #555; }
  .desktop-table { display: block; }
  .mobile-cards { display: none; }
}

/* ===== Statistics usability fixes ===== */
.help-button {
  position: relative;
  min-width: 42px;
}
.help-button.attention {
  border-color: var(--violet);
  background: rgba(155,130,255,.12);
  box-shadow: 0 0 0 4px rgba(155,130,255,.08), 0 0 26px rgba(155,130,255,.24);
  animation: help-attention 1.05s ease-in-out 2;
}
@keyframes help-attention {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.tour-coach {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  pointer-events: none;
  background: rgba(3,6,13,.28);
}
.tour-coach.open { display: block; }
.tour-card {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(420px, calc(100vw - 44px));
  padding: 20px;
  pointer-events: auto;
  border: 1px solid var(--line-bright);
  border-radius: 20px;
  background: linear-gradient(145deg, #18233e, #10182c);
  box-shadow: 0 30px 90px rgba(0,0,0,.5);
}
.tour-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--violet);
  font: 700 10px JetBrains Mono, monospace;
  letter-spacing: .08em;
}
#tourClose {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.tour-card h2 { margin-bottom: 8px; }
.tour-card p { color: #c7d0e8; font-size: 13px; line-height: 1.65; }
.tour-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.tour-actions button { flex: 1; }
.tour-next {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid rgba(155,130,255,.45);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(155,130,255,.3), rgba(255,116,178,.15));
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}
.tour-focus {
  position: relative;
  z-index: 91 !important;
  outline: 2px solid var(--violet);
  outline-offset: 6px;
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(3,6,13,.36), 0 0 34px rgba(155,130,255,.35) !important;
}

.horizontal-lock,
.line-chart,
.interactive-bars,
.scenario-switch {
  overscroll-behavior-x: contain;
}

@media (max-width: 900px) {
  .sidebar {
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    scroll-snap-type: x proximity;
    transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
  }
  .sidebar .nav { scroll-snap-align: center; }
  .sidebar.nav-attention {
    transform: translateY(-5px) scale(1.015);
    border-top-color: rgba(155,130,255,.7);
    box-shadow: 0 -18px 55px rgba(0,0,0,.4), 0 -5px 30px rgba(155,130,255,.24);
  }
  .sidebar.nav-attention .nav {
    min-width: 80px;
    height: 60px;
  }
  .line-chart,
  .interactive-bars,
  .scenario-switch,
  .horizontal-lock {
    touch-action: pan-x;
    overscroll-behavior-y: none;
  }
  .tour-card {
    left: 12px;
    right: 12px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    width: auto;
  }
  .tour-focus { outline-offset: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .help-button.attention { animation: none; }
}


/* ===== Revenue / prepayment accounting mode ===== */
.revenue-mode {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -8px 0 20px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(12,20,39,.64);
}
.revenue-mode.is-separate {
  border-color: rgba(155,130,255,.42);
  background: linear-gradient(135deg, rgba(155,130,255,.11), rgba(255,116,178,.05));
}
.switch-row {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
}
.switch-copy { min-width: 0; }
.switch-copy b, .switch-copy small { display: block; }
.switch-copy b { color: #f3f5ff; font-size: 13px; }
.switch-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.switch { position: relative; flex: 0 0 48px; width: 48px; height: 28px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0a1121;
  transition: .2s ease;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #8995b5;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
  transition: .2s ease;
}
.switch input:checked + i {
  border-color: rgba(155,130,255,.55);
  background: rgba(155,130,255,.22);
}
.switch input:checked + i::after { transform: translateX(20px); background: var(--violet); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(155,130,255,.14); }
.info-help {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(155,130,255,.35);
  border-radius: 50%;
  background: rgba(155,130,255,.1);
  color: #c9beff;
  font: 800 16px Manrope, sans-serif;
  cursor: pointer;
}
.info-help:hover { background: rgba(155,130,255,.18); color: #fff; }
.info-popover {
  position: absolute;
  z-index: 55;
  top: calc(100% + 8px);
  right: 0;
  width: min(430px, calc(100vw - 40px));
  display: none;
  padding: 16px;
  border: 1px solid var(--line-bright);
  border-radius: 16px;
  background: #111a30;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}
.info-popover.open { display: block; }
.info-popover b { display: block; margin-bottom: 8px; }
.info-popover p { margin: 8px 0 0; color: #c7d0e8; font-size: 12px; line-height: 1.55; }
.mode-summary {
  margin-bottom: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10,16,31,.5);
}
.mode-summary b, .mode-summary span { display: block; }
.mode-summary b { color: #fff; }
.mode-summary span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.prepayment-disclaimer { display: block; margin-top: 12px; line-height: 1.5; }

@media (max-width: 700px) {
  .revenue-mode { align-items: flex-start; }
  .switch-row { align-items: flex-start; }
  .switch { margin-top: 3px; }
  .info-popover { position: fixed; top: 92px; right: 12px; left: 12px; width: auto; }
}
