:root {
  --bg: #0d1220;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-strong: #131c2f;
  --panel-soft: rgba(255, 255, 255, 0.04);
  --text: #e5ecf7;
  --muted: #98a6c3;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #8b5cf6;
  --accent-2: #d946ef;

--accent-rgb: 139, 92, 246;
--accent-2-rgb: 217, 70, 239;
--accent-soft: rgba(139, 92, 246, 0.12);
--accent-soft-strong: rgba(139, 92, 246, 0.2);
--accent-glow-1: rgba(217, 70, 239, 0.18);
--accent-glow-2: rgba(139, 92, 246, 0.22);
--accent-border-soft: rgba(216, 180, 254, 0.18);
--accent-border-soft-2: rgba(216, 180, 254, 0.16);
--accent-text-soft: #d8b4fe;
--accent-code: #f5d0fe;

  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

body[data-theme="purple"] {
  --accent: #8b5cf6;
  --accent-2: #d946ef;
  --accent-rgb: 139, 92, 246;
  --accent-2-rgb: 217, 70, 239;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --accent-soft-strong: rgba(139, 92, 246, 0.2);
  --accent-glow-1: rgba(217, 70, 239, 0.18);
  --accent-glow-2: rgba(139, 92, 246, 0.22);
  --accent-border-soft: rgba(216, 180, 254, 0.18);
  --accent-border-soft-2: rgba(216, 180, 254, 0.16);
  --accent-text-soft: #d8b4fe;
  --accent-code: #f5d0fe;
}

body[data-theme="blue"] {
  --accent: #3b82f6;
  --accent-2: #06b6d4;
  --accent-rgb: 59, 130, 246;
  --accent-2-rgb: 6, 182, 212;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-soft-strong: rgba(59, 130, 246, 0.2);
  --accent-glow-1: rgba(6, 182, 212, 0.16);
  --accent-glow-2: rgba(59, 130, 246, 0.22);
  --accent-border-soft: rgba(147, 197, 253, 0.18);
  --accent-border-soft-2: rgba(147, 197, 253, 0.16);
  --accent-text-soft: #93c5fd;
  --accent-code: #bae6fd;
}

body[data-theme="green"] {
  --accent: #22c55e;
  --accent-2: #16a34a;
  --accent-rgb: 34, 197, 94;
  --accent-2-rgb: 22, 163, 74;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --accent-soft-strong: rgba(34, 197, 94, 0.2);
  --accent-glow-1: rgba(34, 197, 94, 0.16);
  --accent-glow-2: rgba(22, 163, 74, 0.22);
  --accent-border-soft: rgba(134, 239, 172, 0.18);
  --accent-border-soft-2: rgba(134, 239, 172, 0.16);
  --accent-text-soft: #86efac;
  --accent-code: #bbf7d0;
}

body[data-theme="red"] {
  --accent: #ef4444;
  --accent-2: #f97316;
  --accent-rgb: 239, 68, 68;
  --accent-2-rgb: 249, 115, 22;
  --accent-soft: rgba(239, 68, 68, 0.12);
  --accent-soft-strong: rgba(239, 68, 68, 0.2);
  --accent-glow-1: rgba(249, 115, 22, 0.16);
  --accent-glow-2: rgba(239, 68, 68, 0.22);
  --accent-border-soft: rgba(252, 165, 165, 0.18);
  --accent-border-soft-2: rgba(252, 165, 165, 0.16);
  --accent-text-soft: #fca5a5;
  --accent-code: #fecaca;
}

body[data-theme="orange"] {
  --accent: #f97316;
  --accent-2: #facc15;
  --accent-rgb: 249, 115, 22;
  --accent-2-rgb: 250, 204, 21;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --accent-soft-strong: rgba(249, 115, 22, 0.2);
  --accent-glow-1: rgba(250, 204, 21, 0.14);
  --accent-glow-2: rgba(249, 115, 22, 0.22);
  --accent-border-soft: rgba(253, 186, 116, 0.18);
  --accent-border-soft-2: rgba(253, 186, 116, 0.16);
  --accent-text-soft: #fdba74;
  --accent-code: #fed7aa;
}

body[data-theme="teal"] {
  --accent: #14b8a6;
  --accent-2: #06b6d4;
  --accent-rgb: 20, 184, 166;
  --accent-2-rgb: 6, 182, 212;
  --accent-soft: rgba(20, 184, 166, 0.12);
  --accent-soft-strong: rgba(20, 184, 166, 0.2);
  --accent-glow-1: rgba(6, 182, 212, 0.15);
  --accent-glow-2: rgba(20, 184, 166, 0.22);
  --accent-border-soft: rgba(153, 246, 228, 0.18);
  --accent-border-soft-2: rgba(153, 246, 228, 0.16);
  --accent-text-soft: #99f6e4;
  --accent-code: #ccfbf1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--accent-glow-1), transparent 30%),
    radial-gradient(circle at top right, var(--accent-glow-2), transparent 35%),
    linear-gradient(180deg, #0b1020 0%, #10172b 100%);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 32px auto 48px;
}

.hero,
.card {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero {
  border-radius: var(--radius-lg);
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-text-soft);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 700;
}

h1, h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
}

.hero-copy,
.card-header p,
.note-block p,
.field span,
.allocation-label {
  color: var(--muted);
}

.hero-copy {
  max-width: 560px;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.6;
  text-wrap: balance;
}

.hero-badge {
  min-width: 220px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-2-rgb), 0.12));
  border: 1px solid var(--accent-border-soft);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-badge span {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-badge strong {
  font-size: 1.05rem;
}

.layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.card {
  border-radius: var(--radius-lg);
  padding: 26px;
}

.card-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.card-header h2 {
  font-size: 1.3rem;
}

.card-header p {
  margin: 6px 0 0;
  font-size: 0.95rem;
}

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

.input-grid {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(var(--accent-rgb), 0.12);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  color: #c8d4ea;
  font-weight: 600;
}

.input-wrap {
  position: relative;
}

input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;

  /* STRONGER BORDER */
  border: 1px solid rgba(var(--accent-rgb), 0.35);

  /* ~25% BRIGHTER BACKGROUND */
  background: rgba(255, 255, 255, 0.14);

  color: var(--text);
  font-size: 1rem;
  outline: none;

  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;

  /* STRONGER BASE GLOW */
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

input:focus {
  border-color: rgba(var(--accent-2-rgb), 0.95);

  /* EVEN BRIGHTER ON FOCUS */
  background: rgba(255, 255, 255, 0.18);

  box-shadow:
    0 0 0 3px rgba(var(--accent-rgb), 0.22),
    0 0 26px rgba(var(--accent-rgb), 0.25),
    0 0 40px rgba(var(--accent-rgb), 0.15);
}

input::placeholder {
  color: rgba(229, 236, 247, 0.5);
}

.currency-wrap input {
  padding-left: 34px;
}

.suffix-wrap input {
  padding-right: 44px;
}

.prefix,
.suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.prefix { left: 14px; }
.suffix { right: 14px; }

.allocation-header {
  margin-top: 4px;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.allocation-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.allocation-status strong {
  font-size: 1.15rem;
}

.allocation-status.good strong { color: var(--good); }
.allocation-status.warn strong { color: var(--warn); }
.allocation-status.bad strong { color: var(--bad); }

.allocation-meter {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 14px;
}

.allocation-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.budget-meter-fill {
  background: linear-gradient(90deg, #22c55e, #14b8a6);
}

.allocations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.allocation-group {
  margin-bottom: 16px;
}

.allocation-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.08),
    0 0 24px rgba(var(--accent-rgb), 0.08);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

.allocation-group-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-2-rgb), 0.55);
  background: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 0 0 3px rgba(var(--accent-rgb), 0.14),
    0 0 30px rgba(var(--accent-rgb), 0.12);
}

.allocation-group-toggle.is-open {
  border-color: rgba(var(--accent-2-rgb), 0.7);
  background: rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0 0 3px rgba(var(--accent-rgb), 0.16),
    0 0 34px rgba(var(--accent-rgb), 0.14);
}

.allocation-group-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.allocation-group-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
}

.allocation-group-subtitle {
  font-size: 0.85rem;
  color: #c8d4ea;
  font-weight: 600;
}

.allocation-group-chevron {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--accent-text-soft);
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.allocation-group-body {
  display: none;
  margin-top: 14px;
}

.allocation-group-body.is-open {
  display: block;
}

.allocation-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.allocation-card {
  padding: 16px;
  border-radius: 18px;

  /* BRIGHTER BACKGROUND */
  background: rgba(255, 255, 255, 0.09);

  /* STRONGER BORDER */
  border: 1px solid rgba(var(--accent-rgb), 0.18);

  /* VERY SUBTLE GLOW */
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.06);
}

.allocation-card.is-disabled {
  opacity: 0.62;
}

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

.allocation-card-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.allocation-card h3 {
  margin: 0;
  font-size: 1rem;
}

.allocation-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}



.allocation-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.allocation-card .field {
  gap: 6px;
}

.validation-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}

.validation {
  min-height: 24px;
  font-size: 0.95rem;
  font-weight: 600;
}

.validation.good { color: var(--good); }
.validation.warn { color: var(--warn); }
.validation.bad { color: var(--bad); }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.summary-stat {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.summary-stat strong {
  font-size: 1.2rem;
}

.note-block {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.12), rgba(var(--accent-2-rgb), 0.08));
  border: 1px solid var(--accent-border-soft-2);
}

.note-block strong {
  display: block;
  margin-bottom: 8px;
}

.note-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent-code);
}

.results-card {
  padding-top: 24px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 24, 39, 0.96);
}

th {
  color: #cbd5e1;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(19, 28, 47, 0.98);
}

/* Keep the first column visible while scrolling horizontally */
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(17, 24, 39, 0.98);
  box-shadow: 10px 0 18px rgba(0, 0, 0, 0.18);

  width: 180px;
  min-width: 160px;
  max-width: 200px;

  white-space: normal;
  word-break: break-word;
}

/* Slightly tighter spacing inside first column */
td:first-child,
th:first-child {
  padding-right: 10px;
}

/* Keep the top-left header cell above everything else */
thead th:first-child {
  z-index: 3;
  background: rgba(19, 28, 47, 0.99);
}

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

.result-name {
  font-weight: 700;
}

.result-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.result-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
  font-size: 0.82rem;
}

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

  .hero {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .hero-logo-wrap {
    justify-content: flex-start;
  }

  .theme-switcher {
    justify-content: flex-start;
  }

  .hero-badge {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    margin-top: 20px;
  }

  /* MOBILE: make first column even narrower */
  th:first-child,
  td:first-child {
    width: 140px;
    min-width: 130px;
    max-width: 150px;
  }

  .hero,
  .card {
    padding: 20px;
  }

  .input-grid,
  .allocations,
  .allocation-group-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .card-header,
  .allocation-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .allocation-status {
    align-items: flex-start;
  }

  .allocation-group-toggle {
    padding: 14px 16px;
  }
}
.hero {
  position: relative;
}

.hero-left {
  max-width: 520px;
}

.hero-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo {
  display: block;
  width: clamp(180px, 20vw, 260px);
  height: auto;
  max-width: 100%;
}

.theme-switcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: visible;
  z-index: 1100;
}

.theme-toggle-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.08), var(--shadow);
}

.theme-icon {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}

.theme-toggle-btn:hover .theme-icon {
  transform: scale(1.08);
  transition: transform 0.15s ease;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  transform: none;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 1200;
}

.theme-menu.hidden {
  display: none !important;
}

.theme-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.theme-dot:hover {
  transform: scale(1.1);
}

.theme-dot.active {
  border-color: #ffffff;
}
.theme-purple { background: #8b5cf6; }
.theme-blue { background: #3b82f6; }
.theme-green { background: #22c55e; }
.theme-red { background: #ef4444; }
.theme-orange { background: #f97316; }
.theme-teal { background: #14b8a6; }

@media (min-width: 601px) {
  .theme-menu {
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    transform: none;
  }
}

@media (max-width: 600px) {
  .theme-switcher {
    justify-content: flex-start;
  }

  .theme-menu {
    top: 50%;
    left: calc(100% + 10px);
    right: auto;
    transform: translateY(-50%);

    display: grid;
    grid-template-columns: repeat(3, 24px);
    gap: 10px;

    width: max-content;
    padding: 10px 12px;
    justify-content: start;
    border-radius: 18px;
    max-width: calc(100vw - 90px);
  }
}