:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --bg-soft: #fbf8f2;
  --surface: rgba(255, 252, 247, 0.86);
  --surface-strong: #fffdf9;
  --text: #1f2430;
  --muted: #6a6f7d;
  --border: rgba(78, 62, 44, 0.12);
  --border-strong: rgba(78, 62, 44, 0.2);
  --shadow: 0 22px 60px rgba(92, 72, 48, 0.12);
  --positive: #127a56;
  --negative: #b8473b;
  --accent: #1f5fa5;
  --accent-soft: #dce9f8;
  --neutral: #916a1a;
  --sand: #ead7ba;
  --mint: #d8efe5;
  --rose: #f7ddd8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 95, 165, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(194, 146, 64, 0.16), transparent 30%),
    linear-gradient(180deg, #f9f4eb 0%, #f4eee3 44%, #efe6d8 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(12px);
}

body::before {
  width: 340px;
  height: 340px;
  top: -80px;
  right: -100px;
  background: rgba(31, 95, 165, 0.1);
}

body::after {
  width: 280px;
  height: 280px;
  bottom: -80px;
  left: -70px;
  background: rgba(194, 146, 64, 0.12);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: rise-in 520ms ease both;
}

.hero,
.tabs,
.summary-grid,
.section-head,
.panel-stack,
.hero-controls,
.next-step-grid {
  display: grid;
  gap: 14px;
}

.hero {
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
  align-items: center;
  margin-bottom: 16px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(255, 253, 249, 0.94), rgba(247, 240, 227, 0.92)),
    var(--surface);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -40px;
  top: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 95, 165, 0.14), transparent 72%);
}

.hero h1,
.card h2,
.card h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  line-height: 0.96;
  max-width: 12ch;
}

.card h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.card h3 {
  font-size: 1.08rem;
}

.eyebrow,
.label,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
}

.hero-copy {
  margin: 12px 0 0;
  max-width: 58ch;
  color: #4f5563;
  font-size: 1.02rem;
  line-height: 1.65;
}

.hero-controls {
  align-items: center;
  justify-items: end;
}

.tabs {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-bottom: 16px;
  padding: 10px;
  background: rgba(255, 250, 242, 0.9);
}

.tab-btn {
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 13px 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 95, 165, 0.16);
  color: var(--text);
}

.tab-btn.active {
  background: linear-gradient(180deg, #1f5fa5, #1b4f88);
  color: #fff9f0;
  border-color: rgba(31, 95, 165, 0.3);
  box-shadow: 0 12px 30px rgba(31, 95, 165, 0.24);
}

.panel-stack {
  gap: 16px;
}

.hidden {
  display: none;
}

.split-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.three-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.summary-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(78, 62, 44, 0.08);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  border-radius: 24px 0 0 24px;
  background: rgba(78, 62, 44, 0.16);
}

.summary-card strong {
  font-size: clamp(1.12rem, 1.6vw, 1.72rem);
  letter-spacing: -0.03em;
}

.compact-grid .card {
  padding: 14px;
}

.tone-neutral::before {
  background: rgba(145, 106, 26, 0.45);
}

.tone-positive::before {
  background: rgba(18, 122, 86, 0.5);
}

.tone-negative::before {
  background: rgba(184, 71, 59, 0.5);
}

.tone-accent::before {
  background: rgba(31, 95, 165, 0.5);
}

.tone-neutral strong {
  color: var(--neutral);
}

.tone-positive strong {
  color: var(--positive);
}

.tone-negative strong {
  color: var(--negative);
}

.tone-accent strong {
  color: var(--accent);
}

.sheet-input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  padding: 11px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.sheet-input:focus,
.plan-input:focus,
.yearsheet-input:focus {
  outline: 3px solid rgba(31, 95, 165, 0.16);
  border-color: rgba(31, 95, 165, 0.3);
}

.compact-input {
  min-width: 168px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  border: 1px solid rgba(31, 95, 165, 0.2);
  background: linear-gradient(180deg, #1f5fa5, #1d4f84);
  color: #fffaf2;
  box-shadow: 0 14px 28px rgba(31, 95, 165, 0.18);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(31, 95, 165, 0.1);
}

.dense-card {
  padding-top: 14px;
}

.compact-head {
  margin-bottom: 12px;
}

.inline-control {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.section-head {
  gap: 10px;
}

.section-head.wrap {
  align-items: center;
}

.section-head-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeline-legend-card {
  padding: 14px 18px;
  background:
    linear-gradient(135deg, rgba(255, 250, 242, 0.95), rgba(246, 238, 225, 0.85)),
    var(--surface);
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.timeline-pill,
.timeline-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
}

.timeline-pill {
  padding: 8px 13px;
  font-size: 0.85rem;
}

.timeline-mini {
  width: fit-content;
  padding: 3px 8px;
  font-size: 0.72rem;
}

.timeline-pill--past,
.timeline-mini--past {
  background: rgba(184, 71, 59, 0.12);
  color: var(--negative);
}

.timeline-pill--today,
.timeline-mini--today {
  background: rgba(145, 106, 26, 0.14);
  color: var(--neutral);
}

.timeline-pill--future,
.timeline-mini--future {
  background: rgba(18, 122, 86, 0.14);
  color: var(--positive);
}

.date-stack {
  display: grid;
  gap: 5px;
}

.yearsheet-row--past td {
  background: rgba(247, 221, 216, 0.42);
}

.yearsheet-row--today td {
  background: rgba(234, 215, 186, 0.4);
}

.yearsheet-row--future td {
  background: rgba(216, 239, 229, 0.42);
}

.guv-sheet-table thead th {
  background: #efe4cf;
  color: var(--text);
}

.guv-sheet-table tbody td {
  background: rgba(216, 239, 229, 0.34);
}

.guv-sheet-table tbody td:first-child {
  background: rgba(234, 215, 186, 0.55);
  font-weight: 700;
}

.guv-sheet-table .total-row td {
  background: rgba(239, 228, 207, 0.88);
}

.sticky-head-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: 0 1px 0 rgba(78, 62, 44, 0.12);
}

.yearsheet-table thead th:first-child {
  left: 0;
  z-index: 5;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 20px;
  border: 1px solid rgba(78, 62, 44, 0.08);
  background: rgba(255, 255, 255, 0.52);
}

.wrap-cell {
  white-space: normal;
  min-width: 280px;
}

.project-list {
  display: grid;
  gap: 6px;
}

.project-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid rgba(78, 62, 44, 0.08);
  white-space: nowrap;
}

.dense-table th,
.dense-table td {
  padding: 10px 10px;
  font-size: 0.92rem;
}

thead th {
  color: #5e6472;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(31, 95, 165, 0.04);
}

.total-row td {
  font-weight: 700;
  background: rgba(239, 228, 207, 0.58);
}

.amount-positive {
  color: var(--positive);
  font-weight: 700;
}

.amount-negative {
  color: var(--negative);
  font-weight: 700;
}

.amount-neutral {
  color: var(--text);
  font-weight: 600;
}

.plan-input {
  width: 92px;
  border-radius: 12px;
  border: 1px solid rgba(31, 95, 165, 0.14);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  padding: 7px 9px;
}

.plan-readonly {
  color: #767c89;
}

.yearsheet-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(18, 122, 86, 0.2);
  background: rgba(250, 255, 252, 0.9);
  color: var(--text);
  padding: 7px 9px;
}

.yearsheet-input::placeholder {
  color: rgba(79, 85, 99, 0.52);
}

.yearsheet-input--money {
  min-width: 112px;
}

.yearsheet-input--text {
  min-width: 184px;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .card,
  .tab-btn,
  .primary-btn,
  .ghost-btn,
  tbody tr {
    animation: none;
    transition: none;
  }
}

@media (max-width: 1120px) {
  .hero,
  .split-head,
  .hero-controls {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 24px;
  }

  .hero h1 {
    max-width: 100%;
  }

  .hero-controls,
  .hero-actions,
  .section-head-actions {
    justify-items: start;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 16px, 100%);
    padding: 16px 0 42px;
  }

  .card {
    border-radius: 22px;
    padding: 14px;
  }

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

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

  th,
  td,
  .dense-table th,
  .dense-table td {
    padding: 9px 8px;
  }

  .wrap-cell {
    min-width: 220px;
  }

  .inline-control,
  .compact-input {
    min-width: 0;
    width: 100%;
  }
}
