/* ==========================================================================
   Досрочка — Понятный и лёгкий дизайн (Dark & Light, Mobile-First)
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg: #080c15;
  --bg-elevated: rgba(17, 24, 39, 0.8);
  --surface-1: #111827;
  --surface-2: #182235;
  --surface-3: #22304a;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --accent-glow: rgba(16, 185, 129, 0.32);

  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.15);
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --rose: #f43f5e;
  --violet: #8b5cf6;

  --shadow-card: 0 20px 50px -20px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-float: 0 14px 34px rgba(0, 0, 0, 0.55);
  --topbar-bg: rgba(8, 12, 21, 0.85);
  --input-bg: #0c1322;
  --slider-track: #24324c;
  --orb-opacity: 0.22;
}

[data-theme="light"] {
  --bg: #f3f6fb;
  --bg-elevated: rgba(255, 255, 255, 0.9);
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: rgba(5, 150, 105, 0.11);
  --accent-glow: rgba(5, 150, 105, 0.22);

  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.11);
  --cyan: #0891b2;
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.11);
  --rose: #e11d48;
  --violet: #7c3aed;

  --shadow-card: 0 14px 36px -16px rgba(15, 23, 42, 0.09), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 12px 30px rgba(15, 23, 42, 0.14);
  --topbar-bg: rgba(243, 246, 251, 0.88);
  --input-bg: #f8fafc;
  --slider-track: #cbd5e1;
  --orb-opacity: 0.1;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.48;
  font-feature-settings: "tnum" 1, "cv02" 1;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden { display: none !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.mb-20 { margin-bottom: 20px; }

.text-emerald { color: var(--accent) !important; }
.text-cyan { color: var(--cyan) !important; }
.text-amber { color: var(--amber) !important; }
.text-blue { color: var(--blue) !important; }
.text-center { text-align: center; }

/* Ambient Background */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(115px);
  opacity: var(--orb-opacity);
}

.orb-1 {
  width: 520px;
  height: 520px;
  top: -180px;
  left: -120px;
  background: radial-gradient(circle, #10b981 0%, transparent 70%);
}

.orb-2 {
  width: 580px;
  height: 580px;
  top: 60px;
  right: -200px;
  background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
}

.orb-3 {
  width: 480px;
  height: 480px;
  bottom: -180px;
  left: 30%;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981 0%, #2563eb 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px var(--accent-glow);
  flex-shrink: 0;
}

.brand-logo svg {
  width: 20px;
  height: 20px;
}

.brand-logo { background: none; box-shadow: none; border-radius: 0; overflow: visible; width: 40px; height: 40px; }
.brand-logo picture, .brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-accent { color: var(--accent); }

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.18s ease;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn-icon-only {
  width: 36px;
  padding: 0;
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

/* Intro Strip & Goal Switcher */
.main-content {
  padding-top: 22px;
  padding-bottom: 32px;
}

.intro-strip {
  margin-bottom: 22px;
}

.intro-top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.hero-title {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 2.5vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

.hero-desc {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-secondary);
  max-width: 600px;
}

.goal-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}

.goal-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 9px 16px;
  border-radius: 11px;
  transition: all 0.18s ease;
}

.goal-btn:hover {
  background: var(--surface-2);
}

.goal-btn.active {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.goal-title {
  font-size: 0.86rem;
  font-weight: 750;
  color: var(--text-primary);
}

.goal-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Program Presets Bar */
.program-bar-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}

.program-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.program-caption {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.macro-mini {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.macro-mini strong {
  color: var(--text-primary);
}

.program-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.program-bar::-webkit-scrollbar { display: none; }

.program-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.program-pill:hover {
  color: var(--text-primary);
  background: var(--surface-3);
}

.program-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-primary);
}

.program-pill strong {
  color: var(--text-primary);
  font-weight: 700;
}

.program-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-emerald { background: #10b981; }
.dot-blue { background: #3b82f6; }
.dot-violet { background: #8b5cf6; }
.dot-cyan { background: #06b6d4; }
.dot-lime { background: #84cc16; }
.dot-amber { background: #f59e0b; }

.program-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.program-hint svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent);
}

/* Two-Column Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(0, 0.97fr);
  gap: 22px;
  align-items: start;
}

.inputs-column,
.results-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 1040px) {
  .results-column {
    position: sticky;
    top: 80px;
  }
}

/* Cards */
.card {
  background: var(--bg-elevated);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.card-highlight {
  border-color: rgba(16, 185, 129, 0.28);
}

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

.card-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  flex-wrap: wrap;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.step-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge-emerald {
  background: var(--accent-soft);
  color: var(--accent);
}

.optional-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

/* Help Tooltip Dot */
.help-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 800;
  vertical-align: middle;
  transition: all 0.15s ease;
}

.help-dot:hover,
.help-dot:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.help-popover {
  position: fixed;
  z-index: 100;
  max-width: 280px;
  padding: 10px 13px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-float);
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--text-primary);
}

/* Segmented Controls */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  gap: 2px;
}

.segmented-control.full-w {
  display: flex;
  width: 100%;
}

.segmented-control.full-w .seg-btn { flex: 1; }

.seg-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.16s ease;
  white-space: nowrap;
}

.seg-btn:hover { color: var(--text-primary); }

.seg-btn.active {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.mini-segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.mini-seg {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.mini-seg.active {
  background: var(--accent);
  color: #fff;
}

/* Form Fields & Smart Numeric Inputs */
.field-group { margin-bottom: 18px; }

.fields-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.field-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-meta {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.field-meta-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-subtle {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-primary);
}

.smart-input-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  height: 48px;
  padding: 0 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.smart-input-box.compact {
  height: 42px;
  border-radius: 11px;
}

.smart-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.smart-input-box.with-steppers { padding: 0 6px; }

.smart-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.14rem;
  font-weight: 750;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.smart-input-box.compact .smart-input { font-size: 0.96rem; }

.input-suffix {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 8px;
  user-select: none;
}

.input-suffix-inline {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
  user-select: none;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.stepper-btn:hover { background: var(--surface-3); }
.stepper-btn:active { transform: scale(0.93); }

/* Range Sliders */
.smart-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 11px 0 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 30%), var(--slider-track) var(--fill, 30%), var(--slider-track) 100%);
  outline: none;
  cursor: pointer;
}

.smart-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.smart-slider::-webkit-slider-thumb:hover,
.smart-slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.smart-slider::-moz-range-thumb {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

/* Quick Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-chips .chip {
  padding: 4px 8px;
  font-size: 0.73rem;
}

.chip {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.chip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.chip-accent {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.32);
  color: var(--blue);
}

.chip-accent:hover { background: rgba(59, 130, 246, 0.2); }

.field-warning {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--amber);
  font-size: 0.78rem;
}

/* Advanced Settings Accordion */
.advanced-wrap {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.advanced-toggle:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.adv-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chevron-icon {
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

.advanced-toggle[aria-expanded="true"] .chevron-icon { transform: rotate(180deg); }

.advanced-panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.adv-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.adv-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.step-rate-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.switch-row input { display: none; }

.switch-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.2s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.switch-row input:checked + .switch-ui { background: var(--accent); }
.switch-row input:checked + .switch-ui::after { transform: translateX(18px); }

.switch-text {
  display: flex;
  flex-direction: column;
  font-size: 0.83rem;
}

.switch-text small {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 2px;
}

.step-rate-fields {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Early Repayment Section */
.btn-text-danger {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--rose);
  padding: 4px 8px;
  border-radius: 8px;
}

.btn-text-danger:hover { background: rgba(244, 63, 94, 0.12); }

.strategy-selector-wrap { margin-bottom: 16px; }

.strategy-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.strategy-card {
  position: relative;
  text-align: left;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.18s ease;
}

.strategy-card:hover { border-color: var(--border-strong); }

.strategy-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.strat-badge {
  align-self: flex-start;
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: #fff;
  margin-bottom: 2px;
}

.strat-badge-best {
  background: var(--blue);
}

.strat-badge-soft {
  background: var(--accent);
}

.strat-title {
  font-size: 0.84rem;
  font-weight: 750;
  color: var(--text-primary);
}

.strat-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.smart-strategy-callout {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.12));
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.early-presets-block { margin-bottom: 14px; }

.presets-caption {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.early-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  padding: 6px 11px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.77rem;
  font-weight: 650;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* Early Repayment Rules List */
.early-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.early-empty {
  padding: 13px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.81rem;
}

.early-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.early-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.early-tag {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.early-remove-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.early-remove-btn:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
}

.early-item-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr;
  gap: 8px;
}

.early-mini-field label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.early-mini-input,
.early-mini-select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 650;
}

.early-mini-input:focus,
.early-mini-select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-add-early {
  width: 100%;
  height: 44px;
  border-radius: 13px;
  border: 1.5px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
}

.btn-add-early:hover {
  background: var(--accent);
  color: #fff;
}

/* Right Column: Results Hero Card */
.results-hero-card {
  background: linear-gradient(165deg, var(--surface-1) 0%, var(--bg-elevated) 100%);
}

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

.kpi-eyebrow {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.primary-payment-value {
  font-size: clamp(1.9rem, 3.2vw, 2.5rem);
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--text-primary);
}

.primary-payment-sub {
  font-size: 0.79rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.freedom-badge {
  text-align: right;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.freedom-label {
  display: block;
  font-size: 0.71rem;
  color: var(--text-secondary);
}

.freedom-date {
  display: block;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
}

.freedom-term {
  display: block;
  font-size: 0.76rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* First Month Split Insight */
.split-insight {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.split-insight-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.split-bar {
  display: flex;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}

.split-bar-principal {
  background: var(--blue);
  transition: width 0.3s ease;
}

.split-bar-interest {
  background: var(--amber);
  transition: width 0.3s ease;
}

/* Savings Spotlight */
.savings-spotlight {
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  transition: all 0.25s ease;
}

.savings-spotlight.has-savings {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.14) 0%, rgba(6, 182, 212, 0.09) 100%);
  border-color: rgba(16, 185, 129, 0.42);
}

.savings-empty-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.savings-empty-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 190px;
}

.savings-empty-text strong {
  font-size: 0.86rem;
  color: var(--text-primary);
}

.savings-empty-text span {
  font-size: 0.77rem;
  color: var(--text-secondary);
  line-height: 1.38;
}

.btn-try-early {
  padding: 9px 14px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-try-early:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.savings-spotlight-header {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
}

.savings-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.savings-headline {
  font-size: 0.88rem;
  font-weight: 750;
}

.savings-efficiency {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.savings-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.savings-metric {
  display: flex;
  flex-direction: column;
}

.sm-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.sm-val {
  font-size: 1.24rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.sm-sub {
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* 3 Clear KPI Tiles */
.kpi-tiles-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-tile {
  padding: 11px 12px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.tile-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.tile-value {
  font-size: 1rem;
  font-weight: 800;
  margin-top: 2px;
}

.tile-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Budget Comfort Line */
.budget-comfort-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.comfort-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.comfort-dot.warn { background: var(--amber); }
.comfort-dot.danger { background: var(--rose); }

/* Stacked Cost Bar */
.cost-bar-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cost-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cost-stacked-bar {
  display: flex;
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}

.cost-seg {
  height: 100%;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.seg-dp { background: #8b5cf6; }
.seg-principal { background: #3b82f6; }
.seg-interest { background: #f59e0b; }
.seg-saved {
  background: repeating-linear-gradient(
    -45deg,
    rgba(16, 185, 129, 0.65),
    rgba(16, 185, 129, 0.65) 5px,
    rgba(16, 185, 129, 0.25) 5px,
    rgba(16, 185, 129, 0.25) 10px
  );
}

.cost-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 9px;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-item b { color: var(--text-primary); }

.legend-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}

/* Interactive Chart Card */
.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.chart-touch-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.chart-stage {
  position: relative;
  width: 100%;
  height: 270px;
  touch-action: pan-y;
}

#mainChartCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 10;
  pointer-events: none;
  min-width: 195px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-float);
  font-size: 0.76rem;
  line-height: 1.45;
}

.tt-title {
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
}

.tt-row strong { color: var(--text-primary); }

/* Donut View */
.donut-stage {
  display: grid;
  grid-template-columns: 195px 1fr;
  gap: 18px;
  align-items: center;
  min-height: 240px;
}

.donut-svg-wrap {
  position: relative;
  width: 195px;
  height: 195px;
  margin: 0 auto;
}

.donut-svg { width: 100%; height: 100%; }

.donut-svg circle {
  transition: stroke-dasharray 0.4s ease, stroke-dashoffset 0.4s ease;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-label { font-size: 0.7rem; color: var(--text-secondary); }
.donut-center-val { font-size: 1.32rem; font-weight: 850; line-height: 1.15; }
.donut-center-sub { font-size: 0.68rem; color: var(--text-muted); }

.donut-details {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.donut-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.8rem;
}

/* Tabbed Tools Hub */
.tools-hub {
  margin-top: 28px;
}

.tools-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.tools-tabs::-webkit-scrollbar { display: none; }

.tool-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.16s ease;
}

.tool-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.tool-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Lab Layout inside Tab */
.lab-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}

.deposit-control-row { margin-bottom: 12px; }

.dep-rate-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.dep-rate-label strong { color: var(--accent); }

.lab-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.lab-box {
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.lab-box.winner {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lab-box-title { font-size: 0.74rem; color: var(--text-secondary); }
.lab-box-val { font-size: 1.15rem; font-weight: 800; margin-top: 3px; }
.lab-box-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.lab-verdict {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.lab-verdict strong { color: var(--text-primary); }

/* Section Shared */
.section-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-title {
  margin: 0 0 6px;
  font-size: clamp(1.18rem, 1.9vw, 1.42rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-desc {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-secondary);
  max-width: 740px;
}

/* Tax Deduction Section */
.tax-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: center;
}

.tax-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

.tax-opt-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tax-results-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tax-cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tax-mini-card {
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.tmc-label { font-size: 0.75rem; color: var(--text-secondary); }
.tmc-val { font-size: 1.2rem; font-weight: 800; margin-top: 3px; }
.tmc-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.tax-total-banner {
  padding: 15px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(59, 130, 246, 0.14));
  border: 1px solid rgba(16, 185, 129, 0.38);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ttb-label { display: block; font-size: 0.76rem; color: var(--text-secondary); }
.ttb-val { font-size: 1.45rem; font-weight: 850; color: var(--accent); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  transition: background 0.16s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

/* Schedule Table */
.schedule-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.schedule-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.table-scroll-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 660px;
}

.schedule-table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.schedule-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.schedule-table tbody tr:hover { background: rgba(148, 163, 184, 0.06); }
.schedule-table tr.has-early-row { background: rgba(16, 185, 129, 0.08); }
.schedule-table .num-col { text-align: right; }

.schedule-table tfoot td {
  background: var(--surface-2);
  font-weight: 800;
  padding: 12px;
  border-top: 2px solid var(--border-strong);
}

.inline-early-input {
  width: 110px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

.inline-early-input::placeholder { color: var(--text-muted); font-weight: 500; }

.inline-early-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.schedule-expand-wrap {
  margin-top: 14px;
  text-align: center;
}

.btn-show-more {
  padding: 10px 22px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.btn-show-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Guide & Docs */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.tip-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.tip-num {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}

.tip-card h3 {
  margin: 0 0 7px;
  font-size: 0.95rem;
  font-weight: 750;
}

.tip-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

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

.doc-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}

.doc-badge {
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.doc-title { margin: 0 0 7px; font-size: 0.95rem; font-weight: 750; }

.doc-desc {
  margin: 0 0 12px;
  font-size: 0.81rem;
  color: var(--text-secondary);
  line-height: 1.46;
  flex: 1;
}

.doc-link { font-size: 0.8rem; font-weight: 700; color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 24px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-copy { color: var(--text-secondary); font-weight: 600; }

/* Mobile Sticky Dock */
.mobile-dock { display: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.83rem;
  font-weight: 700;
  box-shadow: var(--shadow-float);
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 1039px) {
  .workspace-grid,
  .tax-grid,
  .lab-layout {
    grid-template-columns: 1fr;
  }

  .tips-grid,
  .docs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .hide-xs { display: none; }

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

  .goal-switch { width: 100%; }

  .fields-row-2,
  .adv-grid,
  .step-rate-fields,
  .strategy-cards,
  .early-item-grid,
  .lab-comparison-grid,
  .kpi-tiles-grid-3,
  .tips-grid,
  .docs-grid,
  .donut-stage {
    grid-template-columns: 1fr;
  }

  .hero-kpi-top { flex-direction: column; }

  .freedom-badge {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-dock {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-float);
  }

  .mobile-dock-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .md-stat { display: flex; flex-direction: column; }
  .md-label { font-size: 0.64rem; color: var(--text-secondary); }
  .md-val { font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
  .md-divider { width: 1px; height: 22px; background: var(--border); }

  .mobile-dock-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .dock-btn {
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 0.75rem;
    font-weight: 750;
  }

  .dock-btn-accent {
    background: var(--accent);
    color: #fff;
  }
}

/* Print */
@media print {
  .topbar,
  .ambient-bg,
  .program-bar-wrap,
  .goal-switch,
  .early-presets-block,
  .btn-add-early,
  .tools-tabs,
  .schedule-toolbar,
  .schedule-expand-wrap,
  .mobile-dock,
  #btnInjectTaxToEarly {
    display: none !important;
  }

  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  .workspace-grid { grid-template-columns: 1fr 1fr; }
}

#btnShare.is-copied { color: var(--accent); border-color: var(--accent); }

@media (max-width: 720px) {
  .site-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

/* "Изменить ежемесячную доплату" button in savings card */
.savings-edit-btn {
  margin-top: 14px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.savings-edit-btn:hover { background: var(--accent); color: #fff; }
.savings-edit-btn:active { transform: scale(0.98); }
@keyframes earlyFlash {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  40% { box-shadow: 0 0 0 6px var(--accent-glow); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.early-item.flash-highlight { animation: earlyFlash 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .early-item.flash-highlight { animation: none; } }

/* Align term & rate columns */
.fields-row-2 > .field-group { display: flex; flex-direction: column; }
.fields-row-2 .field-label-row { min-height: 30px; }
.fields-row-2 .smart-input-box.with-steppers .smart-input { flex: 1; min-width: 0; text-align: center; }
.fields-row-2 .smart-input-box.with-steppers .input-suffix-inline {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  pointer-events: none;
}
.fields-row-2 .compact-chips { flex-wrap: nowrap; gap: 5px; }
.fields-row-2 .compact-chips .chip { flex: 1 1 0; min-width: 0; padding: 5px 2px; text-align: center; white-space: nowrap; }

/* Clickable income in comfort line */
.comfort-income-link {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.comfort-income-link:hover { text-decoration-style: solid; }
.adv-item.flash-highlight { animation: earlyFlash 1.4s ease-out; border-radius: 12px; }
@media (prefers-reduced-motion: reduce) { .adv-item.flash-highlight { animation: none; } }

/* Matkap chips in down payment */
.matkap-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.matkap-caption { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-right: 2px; }
.matkap-sign { display: inline-block; min-width: 0.7em; font-weight: 800; }
.matkap-row .chip.is-applied { background: var(--blue); border-color: var(--blue); color: #fff; }
.matkap-row .chip.is-applied:hover { filter: brightness(1.08); }

.matkap-stepper {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px; border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.32);
  color: var(--blue);
  font-size: 0.78rem; font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease;
}
.matkap-stepper.is-applied { background: var(--blue); border-color: var(--blue); color: #fff; }
.matkap-label { padding: 0 6px; white-space: nowrap; user-select: none; }
.matkap-btn {
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; color: inherit; background: transparent;
  cursor: pointer; transition: background 0.14s ease;
}
.matkap-btn:hover:not(:disabled) { background: rgba(59, 130, 246, 0.18); }
.matkap-stepper.is-applied .matkap-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.matkap-btn:disabled { opacity: 0.35; cursor: default; }

/* Family mortgage options */
.family-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.family-opts.hidden { display: none; }
.family-opts .mini-seg { padding: 5px 10px; font-size: 0.76rem; }
.family-kids {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 0.78rem; font-weight: 700;
}
.family-kids .matkap-btn:hover:not(:disabled) { background: var(--accent-soft); }
.family-kids-label { padding: 0 6px; min-width: 72px; text-align: center; white-space: nowrap; }
.family-special { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-secondary); cursor: pointer; }
.family-special input { accent-color: var(--accent); width: 15px; height: 15px; }

.adv-grid .adv-item-wide{grid-column:1/-1}
.ndfl-hint{display:block;margin-top:8px;font-size:.8rem;line-height:1.4;color:var(--text-secondary)}
.ndfl-hint strong{color:var(--text-primary)}
.tip-card p + p{margin-top:8px}
.tip-download{display:inline-flex;align-items:center;gap:6px;margin-top:10px;padding:7px 12px;border-radius:10px;background:var(--accent-soft);color:var(--accent);font-weight:700;font-size:.82rem;text-decoration:none;transition:transform .15s ease,filter .15s ease}
.tip-download:hover{transform:translateY(-1px);filter:brightness(.97)}
.payment-path{margin-top:10px;padding:12px 13px;border-radius:12px;background:var(--surface-2);border:1px solid var(--border);animation:ppIn .25s ease}
@keyframes ppIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.pp-title{font-size:.8rem;font-weight:750;color:var(--text-primary);margin-bottom:8px}
.pp-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.pp-item{display:flex;flex-direction:column;gap:2px;padding:7px 9px;border-radius:10px;background:var(--surface-1);border:1px solid var(--border)}
.pp-item.pp-now{border-color:var(--border-strong)}
.pp-label{font-size:.68rem;color:var(--text-secondary);font-weight:600}
.pp-val{font-size:.86rem;font-weight:800;color:var(--text-primary);white-space:nowrap}
.pp-delta{font-size:.7rem;font-weight:700}
.pp-delta.down{color:var(--accent)}
.pp-delta.up{color:var(--rose)}
.pp-note,.pp-empty{margin-top:8px;font-size:.74rem;line-height:1.4;color:var(--text-secondary)}
.pp-empty{margin-top:0}
.pp-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;flex-wrap:wrap}
.pp-head .pp-title{margin-bottom:0}
.pp-list{display:flex;flex-direction:column;gap:4px;max-height:300px;overflow:auto;padding-right:2px}
.pp-line{display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:4px 10px;padding:6px 10px;border-radius:9px;background:var(--surface-1);border:1px solid var(--border)}
.pp-line.pp-now{border-color:var(--border-strong)}
.pp-m{font-size:.76rem;color:var(--text-secondary);font-weight:600}
.pp-line .pp-delta{min-width:74px;text-align:right}
.pp-early{grid-column:1/-1;font-size:.68rem;color:var(--accent);font-weight:700}
.pp-delta{color:var(--text-muted)}
.pp-more{margin-top:6px;width:100%;padding:7px;border-radius:9px;border:1px dashed var(--border-strong);background:transparent;color:var(--text-primary);font-weight:650;font-size:.78rem;cursor:pointer}
.pp-more:hover{border-color:var(--accent);color:var(--accent)}
.pp-line{grid-template-columns:minmax(0,1fr) 92px 104px}
.pp-line .pp-val{text-align:right}
.pp-line .pp-delta{min-width:0}
@media (max-width:480px){.pp-line{grid-template-columns:minmax(0,1fr) 84px 92px;padding:6px 8px}.pp-m{font-size:.72rem}}
.btn-add-early + .early-presets-block{margin-top:16px}
.early-presets-block + .payment-path{margin-top:4px}
.pay-delta{display:block;font-size:11px;font-weight:700;line-height:1.2;margin-top:2px;color:var(--text-muted);white-space:nowrap}
.pay-delta.pay-down{color:var(--accent)}
.pay-delta.pay-up{color:var(--rose)}
/* Early payment cards: strong highlight */
.early-item{--ei:var(--accent);position:relative;background:linear-gradient(135deg,color-mix(in srgb,var(--ei) 14%,var(--surface-1)),color-mix(in srgb,var(--ei) 5%,var(--surface-1)));border:1.5px solid color-mix(in srgb,var(--ei) 45%,transparent);border-left:5px solid var(--ei);box-shadow:0 6px 18px -8px color-mix(in srgb,var(--ei) 55%,transparent);padding:14px 14px 14px 16px}
.early-item .early-tag{display:inline-flex;align-items:center;gap:6px;background:var(--ei);color:#fff;font-size:.8rem;padding:5px 11px;border-radius:999px;box-shadow:0 2px 6px -2px color-mix(in srgb,var(--ei) 70%,transparent)}
.early-item .early-mini-input,.early-item .early-mini-select{background:var(--surface-1);border-color:color-mix(in srgb,var(--ei) 30%,var(--border))}
.early-item .early-mini-field label{color:color-mix(in srgb,var(--ei) 60%,var(--text-secondary));font-weight:700}
.early-item .early-remove-btn{background:var(--surface-1)}
.early-list{display:flex;flex-direction:column;gap:12px}
.lab-verdict.lab-empty{display:flex;flex-direction:column;align-items:flex-start;gap:12px;padding:16px;background:var(--accent-soft);border:1.5px dashed var(--accent);font-size:.9rem}
.lab-empty-btn{height:42px;padding:0 18px;border-radius:12px;background:var(--accent);color:#fff;font-weight:700;font-size:.9rem;box-shadow:0 6px 16px -8px var(--accent);transition:transform .15s ease}
.lab-empty-btn:hover{transform:translateY(-1px)}
@keyframes attnPulse{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 0%,transparent)}30%,70%{box-shadow:0 0 0 6px color-mix(in srgb,var(--accent) 35%,transparent)}}
.btn-add-early.attn-pulse{animation:attnPulse 1.2s ease 2}
#sectionEarly{scroll-margin-top:84px}
.lab-layout:has(.lab-empty){align-items:stretch}
.lab-layout:has(.lab-empty) > div:last-child{display:flex;flex-direction:column}
.lab-verdict.lab-empty{flex:1;justify-content:center;margin:0}
.lab-layout:has(.lab-empty) .deposit-control-row{margin-bottom:0}

/* Lab chart: prepay vs deposit */
.lab-chart-wrap{margin-top:24px;padding:18px 18px 10px;border:1px solid var(--border);border-radius:18px;background:var(--surface-2)}
.lab-chart-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 16px}
.lab-chart-title{margin:0;font-size:1.05rem;color:var(--text-primary)}
.lab-chart-legend{display:flex;gap:14px;font-size:.85rem;color:var(--text-secondary)}
.lab-chart-legend span{display:inline-flex;align-items:center;gap:6px}
.lab-chart-note{margin:6px 0 10px;font-size:.85rem;color:var(--text-secondary);line-height:1.45}
.lct-sw{display:inline-block;width:12px;height:12px;border-radius:4px;flex:none}
.lct-pre{background:var(--accent)}.lct-dep{background:var(--blue)}
.lab-chart{position:relative}
.lab-chart-svg{display:block;max-width:100%;overflow:visible;touch-action:pan-y}
.lab-chart-svg .lc-grid{stroke:var(--border);stroke-width:1;vector-effect:non-scaling-stroke}
.lab-chart-svg .lc-axis{fill:var(--text-secondary);font-size:11px}
.lab-chart-svg .lc-line{fill:none;stroke-width:3;stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke;stroke-dasharray:1;stroke-dashoffset:1;animation:lcDraw 1.1s ease-out forwards}
.lab-chart-svg .lc-pre{stroke:var(--accent)}.lab-chart-svg .lc-dep{stroke:var(--blue);animation-delay:.15s}
.lab-chart-svg .lc-marker{stroke:var(--accent);stroke-width:1.5;stroke-dasharray:5 5;vector-effect:non-scaling-stroke}
.lab-chart-svg .lc-marker-text{fill:var(--accent);font-size:11px;font-weight:600}
.lab-chart-svg .lc-hover{stroke:var(--border-strong);stroke-width:1;vector-effect:non-scaling-stroke}
.lab-chart-svg .lc-dot{stroke:var(--surface-1);stroke-width:2;vector-effect:non-scaling-stroke}
.lab-chart-svg .lc-dot-pre{fill:var(--accent)}.lab-chart-svg .lc-dot-dep{fill:var(--blue)}
.lab-chart-svg .hidden{display:none}
@keyframes lcDraw{to{stroke-dashoffset:0}}
.lab-chart-tip{position:absolute;top:8px;min-width:190px;padding:10px 12px;border-radius:12px;background:var(--surface-1);border:1px solid var(--border);box-shadow:0 8px 24px rgba(0,0,0,.12);font-size:.82rem;line-height:1.4;pointer-events:none;z-index:2}
.lct-year{font-weight:700;margin-bottom:4px;color:var(--text-primary)}
.lct-row{display:flex;align-items:center;gap:6px;color:var(--text-primary);margin-top:4px}
.lct-debt{display:block;padding-left:18px;color:var(--text-secondary);font-size:.78rem}
@media (max-width:640px){.lab-chart-wrap{padding:14px 10px 6px}}
@media (prefers-reduced-motion: reduce){.lab-chart-svg .lc-line{animation:none;stroke-dashoffset:0}}

/* Lab: deposit-then-close race */
.lab-race{margin-top:24px;padding:18px;border-radius:18px;background:linear-gradient(135deg,color-mix(in srgb,var(--blue) 9%,var(--surface-1)),color-mix(in srgb,var(--accent) 9%,var(--surface-1)));border:1px solid var(--border)}
.lab-race-title{font-weight:700;font-size:1.05rem;color:var(--text-primary);margin-bottom:10px}
.lab-race-rows{display:grid;gap:8px}
.lab-race-row{display:flex;gap:10px;align-items:flex-start;color:var(--text-primary);font-size:.92rem;line-height:1.45}
.lab-race-row .lct-sw{margin-top:4px}
.lab-race-verdict,.lab-race p{margin:10px 0 0;font-size:.9rem;color:var(--text-secondary);line-height:1.45}
.lab-race-verdict strong{color:var(--text-primary)}
.lab-chart-svg .lc-marker-dep{stroke:var(--blue)}
.lab-chart-svg .lc-marker-text-dep{fill:var(--blue)}

.lct-debtsw{background:var(--text-secondary);opacity:.6}
.lab-chart-svg .lc-debt{stroke:var(--text-secondary);opacity:.55;stroke-width:2;stroke-dasharray:6 5;animation:none}
.lab-chart-svg .lc-dot-debt{fill:var(--text-secondary)}
.lab-chart-legend{flex-wrap:wrap}

/* Early cards: even stripe and aligned fields */
.early-item{border-left:1.5px solid color-mix(in srgb,var(--ei) 45%,transparent);overflow:hidden;padding:14px 14px 14px 20px}
.early-item::before{content:"";position:absolute;left:0;top:0;bottom:0;width:5px;background:var(--ei)}
.early-item-grid{align-items:end}
.early-item .early-mini-input,.early-item .early-mini-select{height:42px;padding:0 12px;font-size:.95rem;font-weight:650;line-height:1.2;font-family:inherit;box-sizing:border-box;vertical-align:middle}
.early-item .early-mini-select{-webkit-appearance:none;appearance:none;padding-right:34px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:12px;cursor:pointer}
.early-item .early-mini-field label{margin-bottom:6px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.lab-chart-svg .lc-zero{stroke:var(--text-secondary);opacity:.5}
.lab-chart-svg .lc-surplus{fill:var(--accent);opacity:.06}
.lab-chart-svg .lc-surplus-text{fill:var(--text-secondary);font-size:11px}
.lab-chart-svg .lc-zero-dot{fill:var(--accent);stroke:var(--surface-1);stroke-width:2}
.lab-chart-svg .lc-zero-dot.dep{fill:var(--blue)}

.lab-chart-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:4px 0 12px}
.lcs{display:flex;flex-direction:column;gap:2px;padding:10px 12px;border-radius:14px;background:var(--surface-1);border:1px solid var(--border);border-top:3px solid var(--blue)}
.lcs span{font-size:.78rem;color:var(--text-secondary);line-height:1.3}
.lcs strong{font-size:1.1rem;color:var(--text-primary)}
.lcs em{font-style:normal;font-size:.78rem;color:var(--text-secondary)}
.lcs-pre{border-top-color:var(--accent)}
.lcs-neg{border-top-color:var(--rose)}
.lab-chart-svg .lc-bubble rect{fill:var(--blue)}
.lab-chart-svg .lc-bubble.neg rect{fill:var(--rose)}
.lab-chart-svg .lc-bubble text{fill:#fff;font-size:11.5px;font-weight:700}
@media (max-width:640px){.lab-chart-stats{grid-template-columns:1fr}.lcs{flex-direction:row;flex-wrap:wrap;align-items:baseline;column-gap:8px}.lcs span{flex-basis:100%}}

.lab-table-scroll{overflow:auto;max-height:560px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;border:1px solid var(--border);border-radius:14px;background:var(--surface-1)}
.lab-table{width:100%;border-collapse:collapse;font-size:.88rem;font-variant-numeric:tabular-nums}
.lab-table th{position:sticky;top:0;z-index:1;background:var(--surface-2);text-align:right;font-weight:600;font-size:.76rem;color:var(--text-secondary);padding:10px 12px;line-height:1.3;white-space:nowrap;border-bottom:1px solid var(--border)}
.lab-table th:first-child,.lab-table td:first-child{text-align:left}
.lab-table th .lct-sw{width:9px;height:9px;margin-right:5px;vertical-align:middle}
.lab-table td{padding:9px 12px;text-align:right;white-space:nowrap;border-bottom:1px solid var(--border);color:var(--text-primary)}
.lab-table tr:last-child td{border-bottom:0}
.lab-table .lt-date{font-weight:600}
.lab-table .lt-pre b{color:var(--accent)}
.lab-table .lt-int{color:#0f9d8a}
.lab-table .lt-ok{color:var(--accent);font-weight:700}
.lab-table .lt-short{color:var(--rose);font-weight:600}
.lab-table tr.lt-key td{background:color-mix(in srgb,var(--blue) 8%,var(--surface-1))}
.lt-badge{display:inline-block;margin-left:8px;padding:2px 8px;border-radius:999px;font-size:.7rem;font-weight:700;color:#fff;vertical-align:middle}
.lt-badge.dep{background:var(--blue)}.lt-badge.pre{background:var(--accent)}
@media (max-width:640px){.lab-table{font-size:.8rem}.lab-table td,.lab-table th{padding:8px 9px}.lt-badge{display:block;margin:4px 0 0;width:max-content}}
@media (max-width:640px){.lab-table td:first-child,.lab-table th:first-child{position:sticky;left:0;z-index:1;background:var(--surface-1);box-shadow:1px 0 0 var(--border)}.lab-table th:first-child{background:var(--surface-2);z-index:2}.lab-table tr.lt-key td:first-child{background:color-mix(in srgb,var(--blue) 8%,var(--surface-1))}}

.lab-table td{white-space:nowrap}
@media (max-width:640px){.lab-table-scroll{max-height:70vh}.lab-table th:first-child{z-index:3}}
