:root {
  --ink: #e8f1f8;
  --muted: #8aa3b8;
  --dim: #5d7589;
  --sale: #3ecf9a;
  --coll: #5eb0ff;
  --warn: #f0b429;
  --danger: #ff6b6b;
  --panel: rgba(12, 28, 44, 0.55);
  --line: rgba(148, 180, 210, 0.16);
  --glow: rgba(94, 176, 255, 0.35);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: #061018;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #1a4a73 0%, transparent 55%),
    radial-gradient(80% 50% at 100% 20%, rgba(62, 207, 154, 0.12), transparent 45%),
    radial-gradient(70% 40% at 0% 60%, rgba(94, 176, 255, 0.1), transparent 40%),
    linear-gradient(180deg, #0a1c2c 0%, #061018 42%, #040b12 100%);
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.09) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.2;
  mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 18px 48px;
  padding-top: max(20px, env(safe-area-inset-top));
}

.mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  animation: rise 0.7s ease both;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, #f4fbff 10%, #7ec8ff 55%, #3ecf9a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand h1 {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.as-of {
  font-size: 0.7rem;
  color: var(--dim);
  text-align: right;
  max-width: 42%;
}

.periods {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
  animation: rise 0.7s ease 0.08s both;
}
.periods::-webkit-scrollbar { display: none; }

.views {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  animation: rise 0.65s ease both;
}

.views button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font: 600 0.78rem/1 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}

.views button.active {
  background: linear-gradient(135deg, rgba(94, 176, 255, 0.22), rgba(62, 207, 154, 0.12));
  border-color: rgba(94, 176, 255, 0.5);
  color: #f2f8ff;
  box-shadow: 0 0 28px var(--glow);
}

.periods button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font: 500 0.72rem/1 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s ease;
}

.periods button.active {
  background: rgba(94, 176, 255, 0.18);
  border-color: rgba(94, 176, 255, 0.45);
  color: #dff0ff;
  box-shadow: 0 0 24px var(--glow);
}

.hero {
  margin-bottom: 22px;
  animation: rise 0.75s ease 0.14s both;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.hero-value {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 11vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: #f7fbff;
}

.hero-delta {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
}
.hero-delta.up { color: var(--sale); }
.hero-delta.down { color: var(--danger); }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}

.split .label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot.sale { background: var(--sale); box-shadow: 0 0 10px var(--sale); }
.dot.coll { background: var(--coll); box-shadow: 0 0 10px var(--coll); }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

.split .val {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.split .meta {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--dim);
}

.bar {
  margin-top: 18px;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  display: flex;
  background: rgba(255,255,255,0.06);
}

.bar-sale { background: var(--sale); transition: width 0.6s ease; }
.bar-coll { background: var(--coll); transition: width 0.6s ease; }
.bar-warn { background: var(--warn); transition: width 0.6s ease; }

.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 10px;
  align-items: center;
}

.funnel-row .flabel {
  font-size: 0.72rem;
  color: var(--muted);
}

.funnel-track {
  height: 10px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--coll), #9fd0ff);
  min-width: 2px;
}

.funnel-row .fmeta {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.funnel-row .fsub {
  grid-column: 2 / -1;
  font-size: 0.65rem;
  color: var(--dim);
  margin-top: -4px;
}

.badge.overdue {
  color: #2a1008;
  background: var(--danger);
}

.badge.open {
  color: #1a1400;
  background: var(--warn);
}

.signals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
  animation: rise 0.75s ease 0.2s both;
}

.signal {
  padding: 14px 14px 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
}

.signal .k {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.signal .v {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.signal .s {
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--muted);
}

.block {
  margin-bottom: 30px;
  animation: rise 0.8s ease both;
}

.block-head {
  margin-bottom: 14px;
}

.block-head h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.block-head p {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--dim);
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding-top: 8px;
}
.chart-year {
  height: 160px;
}
.chart-forecast {
  height: 150px;
  margin-top: 14px;
}
.chart-note {
  margin-top: 10px;
  font-size: 0.65rem;
  color: var(--dim);
  line-height: 1.4;
}
.empty-chart {
  color: var(--dim);
  font-size: 0.85rem;
  padding: 24px 0;
}

.month {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.month .cols {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 110px;
}

.month .cols span {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.month .cols .s { background: linear-gradient(180deg, #6aefbf, var(--sale)); }
.month .cols .c { background: linear-gradient(180deg, #9fd0ff, var(--coll)); }

.month .lbl {
  font-size: 0.58rem;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.cash-grid {
  display: grid;
  gap: 0;
}

.cash-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.cash-row .k { color: var(--muted); font-size: 0.85rem; }
.cash-row .v {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}
.cash-row .v.warn { color: var(--warn); }
.cash-row .v.bad { color: var(--danger); }
.cash-row .v.good { color: var(--sale); }

.rank {
  list-style: none;
  counter-reset: rank;
}

.rank li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.rank li::before {
  content: counter(rank, decimal-leading-zero);
  font-size: 0.72rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.rank .name {
  font-size: 0.9rem;
  text-transform: capitalize;
}

.rank .sub {
  font-size: 0.68rem;
  color: var(--dim);
}

.rank .amt {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}

.list .row, .tape .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list .name, .tape .name {
  font-size: 0.88rem;
  line-height: 1.35;
}

.list .sub, .tape .sub {
  margin-top: 3px;
  font-size: 0.68rem;
  color: var(--dim);
}

.list .amt, .tape .amt {
  font-family: var(--font-display);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}
.badge.sale { color: #0b2a1f; background: var(--sale); }
.badge.collection { color: #071825; background: var(--coll); }

.foot {
  margin-top: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.68rem;
  color: var(--dim);
}

.state {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(4, 11, 18, 0.92);
  padding: 24px;
  text-align: center;
}
.state[hidden] {
  display: none !important;
}
.state p {
  font-family: var(--font-display);
  font-size: 1.2rem;
  max-width: 280px;
  line-height: 1.4;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
