:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f6faf8;
  --ink: #121816;
  --muted: #6b746f;
  --line: #d8e1dc;
  --soft-line: #dfe5e2;
  --green: #4caf62;
  --green-dark: #1f7f45;
  --green-soft: #eaf6ee;
  --blue: #5d86e8;
  --purple: #7b61d1;
  --orange: #ee7c2d;
  --red: #d24b40;
  --yellow: #c9a227;
  --warning-soft: #fff4cc;
  --input-bg: #ffffff;
  --button-text: #ffffff;
  --good: #7aa52d;
  --shadow: 0 14px 34px rgba(20, 32, 27, 0.08);
  --radius: 14px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #101512;
  --surface: #171f1b;
  --surface-soft: #1d2822;
  --ink: #f1f6f3;
  --muted: #a4b0aa;
  --line: #314039;
  --soft-line: #2a3731;
  --green: #65c878;
  --green-dark: #7be090;
  --green-soft: #203428;
  --blue: #81a2ff;
  --purple: #aa94ff;
  --orange: #f2a05f;
  --red: #ff796f;
  --yellow: #e4c44a;
  --warning-soft: #332b12;
  --input-bg: #111814;
  --button-text: #101512;
  --good: #b5cf5a;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  padding: 0 28px;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.dashboard-shell {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 0 28px;
  display: grid;
  gap: 18px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(720px, 0.95fr) minmax(520px, 1.05fr);
  gap: 16px;
  align-items: stretch;
}

.overview-left {
  display: grid;
  align-content: start;
  gap: 16px;
}

.hero,
.summary-card,
.kpi-strip,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  min-height: 166px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 22px;
  align-items: center;
  padding: 20px;
}

.overview-left > * {
  align-self: start;
}

.eyebrow,
.summary-card span,
.kpi-strip span,
.section-title h2,
.progress-card > span,
.projection-result span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.eyebrow {
  color: var(--ink);
  font-size: 14px;
  margin: 0 0 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(38px, 3.6vw, 54px);
  line-height: 0.95;
  letter-spacing: 0;
}

.delta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 18px;
}

.delta,
.summary-card small {
  font-weight: 800;
  font-size: 14px;
}

.trend-positive,
.summary-card small.trend-positive,
.kpi-strip strong.trend-positive,
.kpi-strip small.trend-positive {
  color: var(--green);
}

.trend-negative,
.summary-card small.trend-negative,
.kpi-strip strong.trend-negative,
.kpi-strip small.trend-negative {
  color: var(--red);
}

.hero-side {
  display: grid;
  gap: 10px;
}

.month-control,
.data-source,
.paste-fallback {
  display: grid;
  gap: 8px;
}

.month-control label,
.data-source label,
.controls label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.data-source,
.paste-fallback {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  padding: 10px;
}

.data-source summary,
.paste-fallback summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.load-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.load-row input,
.hero > div,
.summary-card {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input,
select {
  min-height: 40px;
}

textarea {
  min-height: 104px;
  resize: vertical;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(76, 175, 98, 0.14);
}

input[type="range"] {
  min-height: auto;
  padding: 0;
  accent-color: var(--green-dark);
}

button {
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--green-dark);
  color: var(--button-text);
  cursor: pointer;
}

.theme-toggle {
  grid-auto-flow: column;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.theme-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: inset -4px -3px 0 var(--surface);
}

[data-theme="dark"] .theme-icon {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(228, 196, 74, 0.18);
}

button:hover {
  filter: brightness(1.05);
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#status {
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-grid.category-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 12px;
}

.summary-card.light {
  background: var(--surface-soft);
}

.summary-card span,
.kpi-strip span {
  color: var(--ink);
  font-size: 13px;
}

.summary-card strong {
  font-size: clamp(25px, 2.3vw, 36px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.summary-card small:not(.rating-great):not(.rating-good):not(.rating-fair):not(.rating-poor):not(.trend-positive):not(.trend-negative) {
  color: var(--ink);
}

.summary-card small.rating-great {
  color: var(--green);
}

.summary-card small.rating-good {
  color: var(--good);
}

.summary-card small.rating-fair {
  color: var(--orange);
}

.summary-card small.rating-poor {
  color: var(--red);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.section-title::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}

.section-title h2 {
  font-size: 17px;
  color: var(--ink);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi-strip article {
  min-height: 132px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  border-right: 1px solid var(--soft-line);
  text-align: center;
}

.kpi-strip article:last-child {
  border-right: 0;
}

.kpi-strip strong {
  font-size: clamp(24px, 2.3vw, 38px);
  line-height: 1.05;
}

.kpi-strip small {
  color: var(--ink);
  font-weight: 700;
}

.section-grid {
  display: grid;
  gap: 16px;
}

.three-panel {
  grid-template-columns: 1fr 1fr 1fr;
}

.projection-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.34fr) minmax(0, 0.66fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px 20px;
}

.trend-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 17px;
  line-height: 1.2;
  margin-bottom: 5px;
}

.panel p {
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span,
.legend label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trend-toggles label {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: var(--surface-soft);
  cursor: pointer;
  user-select: none;
}

.trend-toggles input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.trend-toggles label:has(input:not(:checked)) {
  opacity: 0.45;
}

.legend i,
.breakdown-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend .net {
  background: var(--green-dark);
}

.legend .financial {
  background: var(--purple);
}

.legend .assets {
  background: var(--blue);
}

.legend .debt {
  background: var(--orange);
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.breakdown-list {
  display: grid;
  gap: 10px;
  padding-top: 8px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 15px;
}

.breakdown-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-row span:last-child {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.donut-wrap {
  position: relative;
  width: min(260px, 100%);
  aspect-ratio: 1;
  margin: 4px auto 0;
}

.donut-wrap canvas {
  width: 100%;
  height: 100% !important;
}

.donut-wrap strong {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  font-size: 21px;
}

.milestone-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) repeat(2, minmax(260px, 0.75fr));
  gap: 16px;
}

.milestone-list-panel {
  grid-row: span 2;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  background: var(--warning-soft);
  color: var(--ink);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.milestone-list {
  display: grid;
  gap: 8px;
}

.milestone-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--soft-line);
}

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

.milestone-status {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--green-dark);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.milestone-row.pending .milestone-status {
  border-color: var(--muted);
  color: var(--muted);
}

.milestone-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.milestone-row small,
.milestone-row span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.milestone-row span:last-child {
  text-align: right;
}

.milestone-progress,
.progress-track {
  background: var(--soft-line);
  overflow: hidden;
  border-radius: 999px;
}

.milestone-progress {
  height: 7px;
  margin-top: 7px;
}

.milestone-progress i,
.progress-track i {
  display: block;
  height: 100%;
  background: var(--green-dark);
}

.milestone-progress i {
  width: var(--progress);
}

.milestone-row:not(.pending) .milestone-progress i {
  width: 100%;
}

.progress-card {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 190px;
}

.progress-card > span {
  color: var(--muted);
  font-size: 12px;
}

.progress-card strong {
  color: var(--green-dark);
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1;
}

.progress-card small,
.progress-card p {
  color: var(--muted);
}

.progress-card b {
  color: var(--green-dark);
}

.progress-track {
  height: 18px;
}

.progress-track i {
  width: 0;
}

.controls {
  display: grid;
  gap: 11px;
  align-content: start;
  min-height: 476px;
}

.projection-result {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 14px;
  background: var(--green-soft);
  min-height: 108px;
}

.projection-result span {
  color: var(--muted);
  font-size: 12px;
}

.projection-result strong {
  font-size: 27px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.projection-result small {
  color: var(--muted);
}

.forecast-panel {
  min-height: 476px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.chart-frame {
  min-width: 0;
  overflow: hidden;
}

.forecast-chart-frame {
  height: 280px;
}

.forecast-chart-frame canvas {
  height: 280px !important;
}

.accounts-panel {
  margin-bottom: 10px;
}

.account-filters {
  display: grid;
  grid-template-columns: minmax(150px, 0.18fr) minmax(180px, 0.2fr) minmax(260px, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.account-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

td.number,
th.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1260px) {
  .overview-grid,
  .three-panel,
  .projection-grid,
  .milestone-grid {
    grid-template-columns: 1fr;
  }

  .milestone-list-panel {
    grid-row: auto;
  }

  .kpi-strip,
  .summary-grid,
  .summary-grid.category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    padding: 0 14px;
  }

  .dashboard-shell {
    padding: 14px 0;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .summary-grid,
  .summary-grid.category-grid,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .kpi-strip article {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .kpi-strip article:last-child {
    border-bottom: 0;
  }

  .panel-header,
  .legend,
  .account-filters {
    flex-direction: column;
  }

  .account-filters {
    grid-template-columns: 1fr;
  }

  .panel,
  .summary-card {
    padding: 16px;
  }
}
