/* ============================================================
   Life Financial Plan — Styles
   Dark theme, desktop-optimised dashboard
   ============================================================ */

:root {
  --bg-0: #0b1020;
  --bg-1: #0f1730;
  --card: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.55);
  --accent-a: #6d5efc;
  --accent-b: #35d0ff;
  --green: #3dffa0;
  --red: #ff4d4d;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1400px 900px at 8% -5%, rgba(109, 94, 252, 0.18), transparent 55%),
    radial-gradient(900px 700px at 92% 15%, rgba(53, 208, 255, 0.14), transparent 50%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Loading / Error states ───────────────────────────────── */
.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--muted);
  font-size: 15px;
}

.login-state {
  min-height: calc(100vh - 58px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  display: grid;
  gap: 10px;
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.login-card input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.login-card input:focus {
  border-color: rgba(53, 208, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(53, 208, 255, 0.2);
}

.login-card button {
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
}

.login-card button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.login-error {
  margin: 8px 0 0;
  color: #ff9f9f;
  font-size: 13px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent-a);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  color: var(--red);
}
.error-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.error-hint code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Site header ──────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--card-border);
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.accent-text {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.plan-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.plan-meta .sep {
  opacity: 0.4;
}

/* ── Dashboard layout ─────────────────────────────────────── */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Status row ───────────────────────────────────────────── */
.status-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
}

.status-card,
.metric-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Pass/fail border accents */
.status-card.card-pass { border-color: rgba(61, 255, 160, 0.35); }
.status-card.card-fail { border-color: rgba(255, 77, 77, 0.35); }

.status-indicator {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}

.status-indicator.pass {
  background: rgba(61, 255, 160, 0.15);
  color: var(--green);
  border: 2px solid rgba(61, 255, 160, 0.4);
}

.status-indicator.fail {
  background: rgba(255, 77, 77, 0.15);
  color: var(--red);
  border: 2px solid rgba(255, 77, 77, 0.4);
}

.status-info {
  min-width: 0;
}

.status-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.status-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.status-detail {
  font-size: 13px;
  color: var(--accent-b);
  margin-top: 4px;
  font-weight: 500;
}

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

.metric-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  margin-top: 2px;
}

.metric-unit {
  font-size: 15px;
  font-weight: 500;
  margin-left: 2px;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.metric-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Chart section ────────────────────────────────────────── */
.chart-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

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

.chart-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.chart-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: default;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}

.chart-wrap {
  position: relative;
  height: 420px;
  width: 100%;
}

.chart-annotations-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.ann-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.ann-line {
  display: inline-block;
  width: 28px;
  height: 2px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ann-line.dashed-white {
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.6) 0, rgba(255,255,255,0.6) 5px,
    transparent 5px, transparent 9px
  );
}

.ann-line.dashed-cyan {
  background: repeating-linear-gradient(
    90deg,
    rgba(53,208,255,0.7) 0, rgba(53,208,255,0.7) 4px,
    transparent 4px, transparent 8px
  );
}

.fail-note {
  color: var(--red);
  font-weight: 600;
}

/* ── Assumptions footer ───────────────────────────────────── */
.assumptions-footer {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(8px);
}

.assumptions-footer h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.assumptions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px 24px;
}

.assumption-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 8px;
}

.assumption-label {
  color: var(--muted);
  flex-shrink: 0;
}

.assumption-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* ── Year Breakdown (bar click detail) ───────────────────── */
.year-breakdown {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(8px);
}

.year-breakdown-header {
  margin-bottom: 14px;
}

.year-breakdown-header h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.year-breakdown-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.year-breakdown-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
}

.year-breakdown-card h4 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.year-breakdown-rows {
  display: grid;
  gap: 8px;
}

.year-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 6px;
}

.year-breakdown-row.empty {
  color: var(--muted);
  border: 0;
  padding: 2px 0;
}

.year-breakdown-row.summary {
  border-top: 1px solid rgba(255,255,255,0.14);
  border-bottom: 0;
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 600;
}

.year-breakdown-row .inflow {
  color: #7de4ff;
  font-weight: 600;
}

.year-breakdown-row .outflow {
  color: #ff9f9f;
  font-weight: 600;
}

@media (max-width: 1080px) {
  .status-row {
    grid-template-columns: 1fr 1fr;
  }

  .year-breakdown-grid {
    grid-template-columns: 1fr;
  }
}


.link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
}

.link:hover {
  border-bottom-color: rgba(255, 255, 255, 0.75);
}

.footer {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.kbd {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.18);
}

.muted {
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transform: translateY(0);
    animation: rise 500ms ease-out;
  }

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