/*
 * Overview page.
 *
 * Layout follows the order of the questions a person actually has: is this
 * working (verdict), what did I get (hero), what is happening (everything
 * else). Structure is carried by grid and gap, never by per-element margins
 * that silently collapse or double.
 */

/* ---------------------------------------------------------------- hero -- */

.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

.hero-saved {
  background:
    radial-gradient(
      120% 100% at 0% 0%,
      rgba(46, 230, 168, 0.09),
      transparent 62%
    ),
    var(--surface);
  display: flex;
  flex-direction: column;
}

.big {
  font-size: clamp(44px, 7vw, 68px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--saved);
  text-shadow: 0 0 44px var(--saved-glow);
  margin-top: 6px;
}

.big-unit {
  color: var(--ink-2);
  font-size: 14px;
  margin-top: 8px;
}

.saved-side {
  display: flex;
  gap: 30px;
  margin: 20px 0 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.ss-value {
  display: block;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.ss-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  font-size: 12.5px;
  margin-top: 2px;
}

.hero-foot {
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 16px 0 0;
}

/* The before/after comparison: two bars, ONE scale. */
.cmp {
  margin-top: 20px;
  display: grid;
  gap: 9px;
}

.cmp-row {
  display: grid;
  grid-template-columns: 84px 1fr 58px;
  align-items: center;
  gap: 11px;
  font-size: 12.5px;
}

.cmp-label {
  color: var(--ink-3);
  text-align: right;
}

.cmp-track {
  height: 16px;
  background: var(--surface-3);
  border-radius: 5px;
  overflow: hidden;
}

.cmp-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.is-without .cmp-fill {
  background: var(--spent-dim);
  border-right: 2px solid var(--spent);
}

.is-with .cmp-fill {
  background: linear-gradient(90deg, var(--saved-dim), var(--saved));
}

.cmp-value {
  color: var(--ink-2);
  font-weight: 600;
}

.is-without .cmp-value {
  color: var(--spent);
}

.is-with .cmp-value {
  color: var(--saved);
}

/* --------------------------------------------------------------- graph -- */

.hero-graph {
  display: flex;
  flex-direction: column;
}

.constellation {
  flex: 1;
  min-height: 190px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  margin: 4px 0 10px;
}

.constellation .graph-3d-help,
.constellation .graph-3d-reset {
  display: none;
}

.node-dot {
  animation: breathe 5.5s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.42s);
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 1;
  }
}

.graph-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.gs-value {
  display: block;
  font-size: 19px;
  font-weight: 650;
  color: var(--ink);
}

.gs-label {
  color: var(--ink-3);
  font-size: 11.5px;
}

.graph-link {
  margin-top: 15px;
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
}

.graph-link:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------- accounting -- */

.accounting {
  margin-bottom: var(--gap);
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.source-chip {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
  flex: none;
  font-size: 11px;
  padding: 5px 10px;
}

.accounting-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.accounting-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 4px;
  padding: 14px;
}

.accounting-label,
.accounting-detail,
.accounting-note {
  color: var(--ink-3);
  font-size: 11.5px;
}

.accounting-value {
  font-size: 24px;
}

.accounting-note {
  line-height: 1.55;
  margin: 12px 0 0;
}

.saved-cell {
  color: var(--saved);
}

.client-accounting {
  margin-bottom: var(--gap);
}

.client-ledger {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.client-ledger-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(190px, 1.5fr) repeat(5, minmax(105px, 0.7fr));
  padding: 10px 8px;
}

.client-ledger-row:last-child {
  border-bottom: 0;
}

.client-ledger-row > div {
  display: grid;
  gap: 3px;
}

.client-ledger-row span {
  color: var(--ink-3);
  font-size: 10.5px;
}

.client-ledger-row strong {
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .client-ledger-row {
    grid-template-columns: 1fr 1fr;
  }

  .client-ledger-row > div:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .accounting-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading-row {
    display: block;
  }

  .source-chip {
    display: inline-block;
    margin-top: 10px;
  }
}

@media (max-width: 480px) {
  .accounting-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- kpis -- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-3);
  font-size: 12.5px;
  margin: 0 0 8px;
}

.kpi-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1;
}

.empty-span {
  grid-column: 1 / -1;
}

/* -------------------------------------------------------------- panels -- */

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

@media (max-width: 820px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.panels .card,
.timeline-card {
  margin-bottom: 0;
}

section.card {
  margin-bottom: var(--gap);
}

.chart {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 22px;
  align-items: center;
}

@media (max-width: 560px) {
  .chart {
    grid-template-columns: 1fr;
  }
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.legend li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend .name {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend .val {
  color: var(--ink);
  font-weight: 600;
}

.legend .pct {
  color: var(--ink-3);
  min-width: 30px;
  text-align: right;
}

.chart-blank {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.chart-blank .ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 12px solid var(--surface-3);
  margin: 0 auto 12px;
}

/* ------------------------------------------------------------ timeline -- */

.timeline {
  max-height: 330px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}

.event {
  display: grid;
  grid-template-columns: 8px minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.event:hover {
  background: var(--surface-2);
}

.ev-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--graph);
}

.ev-name {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-copy {
  min-width: 0;
}

.ev-detail {
  display: block;
  color: var(--ink-3);
  font-size: 11.5px;
  margin-top: 1px;
}

@media (max-width: 700px) {
  .event {
    grid-template-columns: 8px 1fr auto;
  }

  .ev-meta {
    display: none;
  }
}

.ev-meta {
  color: var(--saved);
  font-size: 12px;
}

.ev-time {
  color: var(--ink-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- table -- */

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.table tr:last-child td {
  border-bottom: none;
}

.table .right {
  text-align: right;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.provider-table {
  margin-top: 18px;
}

.table-note {
  color: var(--ink-3);
  font-size: 11.5px;
}

.table-note a {
  color: var(--graph);
}

/* ---------------------------------------------------------------- misc -- */

.footer-note {
  margin-top: 26px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
}

.error {
  background: rgba(242, 84, 91, 0.1);
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: var(--gap);
  font-size: 13.5px;
}
