/* ── CSS Custom Properties ── */
:root {
  /* Brand */
  --brand: #1d9e75;
  --brand-dark: #0f6e56;
  --brand-light: #e1f5ee;
  --accent: #185fa5;
  --accent-light: #e6f1fb;
  --amber: #854f0b;
  --amber-light: #faeeda;

  /* Light mode surfaces */
  --bg-page: #f1efe8;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f6f2;

  /* Light mode text */
  --text-primary: #1a1a18;
  --text-secondary: #5f5e5a;
  --text-muted: #888780;

  /* Light mode borders */
  --border: rgba(30, 30, 20, 0.12);
  --border-strong: rgba(30, 30, 20, 0.22);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;

  /* Sizing */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* Dark mode overrides */
[data-theme="dark"] {
  --bg-page: #1a1a18;
  --bg-primary: #242422;
  --bg-secondary: #2e2e2b;

  --text-primary: #f1efe8;
  --text-secondary: #b4b2a9;
  --text-muted: #888780;

  --border: rgba(255, 255, 240, 0.1);
  --border-strong: rgba(255, 255, 240, 0.2);

  --brand-light: #04342c;
  --accent-light: #042c53;
  --amber-light: #412402;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 56px; /* matches .topbar height so anchor jumps don't tuck content under the sticky header */
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg-page);
  color: var(--text-primary);
  transition:
    background 0.2s,
    color 0.2s;
}

/* ── Top Bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1.5rem;
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border);
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon i {
  color: #fff;
  font-size: 18px;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 14px;
  color: var(--text-secondary);
  transition:
    background 0.15s,
    color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.theme-btn:hover {
  background: var(--bg-page);
}

/* ── Hero ── */
.hero {
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border);
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
}

.hero-inner {
  max-width: 560px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.hero p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.badge-row {
  display: flex;
  /* justify-content: center;
  flex-wrap: wrap; */
  gap: 8px;
  margin-bottom: 1.1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 0.5px solid rgba(29, 158, 117, 0.25);
}

.badge i {
  font-size: 12px;
}

/* ── Main Layout ── */
.main {
  max-width: 740px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

/* ── Cards ── */
.card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title-row .card-title {
  margin-bottom: 0;
}

.row-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Form Fields ── */
.field {
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label,
.field-header label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.field-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 72px;
  text-align: right;
}

/* Number input */
.currency-wrap {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

input[type="number"] {
  width: 100%;
  padding: 9px 12px 9px 28px;
  font-size: 15px;
  font-family: var(--font);
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

input[type="number"]:focus {
  border-color: var(--brand);
}

/* Suppress native number spinner/stepper controls in every browser.
   Sized generously above so nothing native ever has room to appear,
   but this is the belt-and-braces fix that guarantees it regardless. */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* Range slider */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  outline: none;
  cursor: pointer;
  margin-top: 8px;
  accent-color: var(--brand);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 0 1px var(--brand);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg-primary);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Rotary dial (tenure) */
.dial-wrap {
  position: relative;
  width: 168px;
  max-width: 100%;
  margin: 4px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dial {
  display: block;
  width: 168px;
  height: 168px;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.dial:active {
  cursor: grabbing;
}

.dial:focus-visible .dial-track {
  stroke: var(--brand);
  opacity: 0.35;
}

.dial-track {
  stroke: var(--border-strong);
  stroke-width: 10;
  stroke-linecap: round;
}

.dial-progress {
  stroke: var(--brand);
  stroke-width: 10;
  stroke-linecap: round;
  transition: d 0.05s linear;
}

.dial-thumb {
  fill: var(--brand);
  stroke: var(--bg-primary);
  stroke-width: 3;
}

.dial-circle {
  position: relative;
  width: 168px;
  height: 168px;
}

.dial-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.dial-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.dial-unit {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Split "X years Y months" layout, stacked with a tight gap */
.dial-center:has(.dial-split-row) {
  gap: 3px;
}

.dial-split-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.dial-value-sm {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.dial-split-row .dial-unit {
  font-size: 9px;
}

/* Years sits at the dial's widest point — give it real presence,
   and its own vertical center is pinned to the dial's exact center
   via an inline transform offset computed in JS (see centerYearsRow). */
.dial-split-row:first-child .dial-value-sm {
  font-size: 32px;
}

.dial-endlabels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -6px;
}

/* ── Metrics Grid ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.metric {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-primary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
}

.metric-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.metric-value {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.metric-value.green {
  color: var(--brand-dark);
}
.metric-value.amber {
  color: var(--amber);
}
.metric-value.blue {
  color: var(--accent);
}

[data-theme="dark"] .metric-value.green {
  color: #5dcaa5;
}
[data-theme="dark"] .metric-value.amber {
  color: #ef9f27;
}
[data-theme="dark"] .metric-value.blue {
  color: #85b7eb;
}

/* ── Chart ── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  margin-bottom: 0.75rem;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
}

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

thead tr {
  background: var(--bg-secondary);
}

thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 0.5px solid var(--border);
}

tbody tr {
  border-top: 0.5px solid var(--border);
}
tbody tr:nth-child(even) {
  background: var(--bg-secondary);
}

tbody td {
  padding: 9px 12px;
  color: var(--text-primary);
  white-space: nowrap;
}

tbody td.muted {
  color: var(--text-muted);
}
tbody td.green {
  color: var(--brand-dark);
}
tbody td.blue {
  color: var(--accent);
}

[data-theme="dark"] tbody td.green {
  color: #5dcaa5;
}
[data-theme="dark"] tbody td.blue {
  color: #85b7eb;
}

/* Progress bar in table */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 2px;
}

.progress-pct {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 30px;
}

/* Empty state */
.empty-cell {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-cell i {
  display: block;
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ── About / Formula ── */
.about-text {
  font-size: 14px;
  color: var(--text-secondary);
  /* margin-bottom: 0.25rem; */
  line-height: 1.7;
}

.formula-box {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  font-family: "Courier New", monospace;
  font-size: 14px;
  color: var(--brand-dark);
  margin: 0.25rem 0;
  word-break: break-word;
}

[data-theme="dark"] .formula-box {
  color: #5dcaa5;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .topbar {
    padding: 0 1rem;
  }
  .nav-links {
    display: none;
  }
  .main {
    padding: 1rem 0.75rem;
  }
  .card {
    padding: 1rem;
  }
  .hero {
    padding: 1.75rem 1rem 1.5rem;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
  .metric-value {
    font-size: 16px;
  }
}

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

/* ── Floating Theme Toggle (FAB) ── */
.fab-theme {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0.5px solid var(--border-strong);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  transition:
    background 0.2s,
    transform 0.15s,
    box-shadow 0.15s;
}

.fab-theme:hover {
  background: var(--bg-secondary);
  transform: scale(1.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

.fab-theme:active {
  transform: scale(0.96);
}

[data-theme="dark"] .fab-theme {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  gap: 3px;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 3px;
}

.mode-btn {
  padding: 5px 11px;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--bg-primary);
  color: var(--brand-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="dark"] .mode-btn.active {
  color: #5dcaa5;
}

.mode-btn:not(.active):hover {
  color: var(--text-primary);
}

/* EMI hint text */
.emi-hint {
  font-size: 12px;
  margin-top: 6px;
  min-height: 18px;
  color: var(--text-muted);
}

/* ── Smooth transitions ── */
.card,
.metric,
.topbar,
.hero,
.footer,
body {
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.15s;
}
