:root {
  color-scheme: light dark;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.8);
  --bg-card: rgba(0, 0, 0, 0.02);
  --bg-card-hover: rgba(0, 0, 0, 0.05);
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-light: rgba(0, 0, 0, 0.03);
  --bg-hover-strong: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.1);
  --border-light: rgba(0, 0, 0, 0.08);
  --border-active: rgba(139, 92, 246, 0.8);
  --accent-purple: #7c3aed;
  --accent-teal: #0d9488;
  --accent-blue: #2563eb;
  --accent-pink: #db2777;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --gradient-hero: linear-gradient(135deg,
      #f8fafc 0%,
      #ede9fe 50%,
      #f8fafc 100%);
  --gradient-accent: linear-gradient(135deg, #7c3aed, #0d9488);
  --gradient-card: linear-gradient(135deg,
      rgba(139, 92, 246, 0.05),
      rgba(20, 184, 166, 0.02));
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg-primary: #05070f;
  --bg-secondary: #0d1117;
  --bg-header: rgba(13, 17, 23, 0.8);
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-light: rgba(255, 255, 255, 0.03);
  --bg-hover-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.6);
  --accent-purple: #8b5cf6;
  --accent-teal: #14b8a6;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --text-inverse: #ffffff;
  --gradient-hero: linear-gradient(135deg,
      #0d1117 0%,
      #1a0a2e 50%,
      #0d1117 100%);
  --gradient-accent: linear-gradient(135deg, #8b5cf6, #14b8a6);
  --gradient-card: linear-gradient(135deg,
      rgba(139, 92, 246, 0.1),
      rgba(20, 184, 166, 0.05));
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #05070f;
    --bg-secondary: #0d1117;
    --bg-header: rgba(13, 17, 23, 0.8);
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-light: rgba(255, 255, 255, 0.03);
    --bg-hover-strong: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.08);
    --border-active: rgba(139, 92, 246, 0.6);
    --accent-purple: #8b5cf6;
    --accent-teal: #14b8a6;
    --accent-blue: #3b82f6;
    --accent-pink: #ec4899;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --text-inverse: #ffffff;
    --gradient-hero: linear-gradient(135deg,
        #0d1117 0%,
        #1a0a2e 50%,
        #0d1117 100%);
    --gradient-accent: linear-gradient(135deg, #8b5cf6, #14b8a6);
    --gradient-card: linear-gradient(135deg,
        rgba(139, 92, 246, 0.1),
        rgba(20, 184, 166, 0.05));
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Ambient Background ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 10%,
      rgba(139, 92, 246, 0.12) 0%,
      transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 80%,
      rgba(20, 184, 166, 0.1) 0%,
      transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 50%,
      rgba(59, 130, 246, 0.06) 0%,
      transparent 60%);
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
}

/* ── Theme Dropdown ── */
.theme-dropdown-container {
  position: relative;
}

.theme-toggle-btn {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 0.2s ease,
              border-color 0.2s ease,
              color 0.2s ease;
}

.theme-toggle-btn:active {
  transform: scale(0.9);
}

.theme-toggle-btn i {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover i {
  transform: rotate(15deg) scale(1.1);
}

.theme-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 140px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.95);
  transform-origin: top right;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s ease;
}

.theme-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s ease;
}

.theme-option:hover {
  background: var(--bg-hover-strong);
  transform: translateX(2px);
}

.theme-option i {
  color: var(--text-muted);
  width: 16px;
  text-align: center;
  transition: transform 0.2s ease;
}

/* ── Header ── */
header {
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
}

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 72px 24px 48px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 20px;
  padding: 6px 16px;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.hero h1 .gradient-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

/* ── Loan Type Tabs ── */
.tabs-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 48px;
  padding: 0 24px;
}

.tabs {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
}

.tab-btn {
  padding: 9px 20px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

/* ── Calculator Layout ── */
.calc-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-container {
    grid-template-columns: 1fr;
  }
}

/* ── Glass Card ── */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: var(--shadow-glow);
}

/* ── Section Label ── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-purple);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Input Group ── */
.input-group {
  margin-bottom: 32px;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.input-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-value-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-prefix {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.input-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  text-align: right;
  font-family: inherit;
  width: auto;
  min-width: 60px;
  max-width: 140px;
}

.input-suffix {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Slider ── */
.range-wrap {
  position: relative;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-accent);
  border: 3px solid var(--bg-primary);
  box-shadow:
    0 0 0 3px rgba(139, 92, 246, 0.3),
    0 4px 12px rgba(139, 92, 246, 0.4);
  transition: var(--transition);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow:
    0 0 0 6px rgba(139, 92, 246, 0.25),
    0 4px 16px rgba(139, 92, 246, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #14b8a6);
  border: 3px solid var(--bg-primary);
  cursor: pointer;
}

.slider-minmax {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.slider-minmax span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Result Summary ── */
.result-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 32px;
}

.result-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.result-card.emi::before {
  background: var(--gradient-accent);
}

.result-card.interest::before {
  background: linear-gradient(135deg, #ec4899, #f97316);
}

.result-card.total::before {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}

.result-card.gst::before {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.result-card.gst .result-amount {
  color: #10b981;
}

.result-card.cost::before {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.result-card.cost .result-amount {
  color: #f59e0b;
}

.result-card:hover {
  background: var(--bg-hover-strong);
}

.tooltip-wrap:hover {
  transform: translateY(-2px);
}

.result-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.result-amount {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.result-card.emi .result-amount {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-card.interest .result-amount {
  color: #f97316;
}

.result-card.total .result-amount {
  color: #60a5fa;
}

.result-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Right Panel ── */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Donut Chart ── */
.chart-wrapper {
  position: relative;
  padding: 24px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

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

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

.donut-center-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.donut-center-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.legend-dot-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.legend-name {
  color: var(--text-secondary);
}

.legend-value {
  font-weight: 600;
  color: var(--text-primary);
}

.legend-pct {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ── Amortization Table ── */
.amort-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.amort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.amort-title {
  font-size: 20px;
  font-weight: 700;
}

.toggle-amort {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-amort:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.download-btn:hover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.18);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.download-btn:active {
  transform: translateY(0);
}

/* ── Processing Fee Toggle ── */
.fee-type-toggle {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.fee-type-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.fee-type-btn.active {
  background: rgba(139, 92, 246, 0.25);
  color: var(--accent-purple);
}

.fee-type-btn:hover:not(.active) {
  background: var(--bg-hover-strong);
  color: var(--text-secondary);
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: rgba(139, 92, 246, 0.1);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

thead th:first-child {
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--bg-light);
  transition: background 0.2s;
}

tbody tr:hover {
  background: var(--bg-light);
}

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

tbody td {
  padding: 12px 16px;
  text-align: right;
  color: var(--text-secondary);
}

tbody td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

tbody td.principal {
  color: var(--accent-teal);
  font-weight: 500;
}

tbody td.interest {
  color: #f97316;
  font-weight: 500;
}

tbody td.balance {
  color: var(--text-muted);
}

tfoot td {
  padding: 14px 16px;
  text-align: right;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.08);
  border-top: 1px solid var(--border);
  color: var(--text-primary);
}

tfoot td:first-child {
  text-align: left;
  color: var(--accent-purple);
}

/* ── Progress bar inside table ── */
.bar-wrap {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-in {
  animation: fadeInUp 0.5s ease forwards;
}

.result-amount {
  animation: countUp 0.3s ease;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  max-width: 1200px;
  margin: 32px auto;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

footer a {
  color: var(--accent-purple);
  text-decoration: none;
}

/* ── Rate Summary Strip ── */
.rate-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.rate-strip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  flex: 1;
  min-width: 160px;
}

.rate-strip-item:first-child {
  padding-left: 0;
}

.rate-strip-item:last-child {
  padding-right: 0;
}

.rate-strip-label {
  font-size: 12px;
  color: var(--accent-purple);
  font-weight: 500;
  line-height: 1.3;
  max-width: 100px;
}

.rate-strip-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.rate-strip-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .result-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .header-inner {
    padding: 0 16px;
    height: 56px;
    gap: 8px;
  }

  .logo-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 8px;
  }

  .logo-text {
    font-size: 15px;
  }

  .header-badge {
    font-size: 10px;
    padding: 3px 10px;
  }

  .share-btn {
    padding: 6px 10px;
    font-size: 11px;
    gap: 5px;
  }

  .share-btn svg {
    width: 12px;
    height: 12px;
  }

  .hero {
    padding: 40px 16px 28px;
  }

  .hero p {
    font-size: 14px;
    margin-bottom: 28px;
  }

  .tabs-wrapper {
    margin-bottom: 32px;
    padding: 0 16px;
  }

  .tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .tab-btn {
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
    gap: 4px;
  }

  .calc-container {
    padding: 0 16px 60px;
    gap: 16px;
  }

  .glass-card {
    padding: 20px 16px;
  }

  .section-label {
    font-size: 10px;
    margin-bottom: 20px;
  }

  .input-group {
    margin-bottom: 24px;
  }

  .input-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .input-label {
    font-size: 13px;
  }

  .input-value {
    font-size: 18px;
    max-width: 110px;
  }

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

  .result-card {
    padding: 14px 10px;
  }

  .result-label {
    font-size: 10px;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
  }

  .result-amount {
    font-size: 16px;
  }

  .result-sub {
    font-size: 9px;
  }

  /* Make 5th card full width so 2+2+1 layout */
  .result-card:last-child {
    grid-column: span 2;
  }

  /* Processing Fee - stack toggle & value */
  .fee-type-toggle {
    order: -1;
  }

  /* Rate Strip - vertical stack */
  .rate-strip {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  .rate-strip-item {
    width: 100%;
    flex: none;
    padding: 12px 16px;
    min-width: unset;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
  }

  .rate-strip-item:last-child {
    border-bottom: none;
  }

  .rate-strip-item:first-child {
    padding-left: 16px;
  }

  .rate-strip-item:last-child {
    padding-right: 16px;
  }

  .rate-strip-divider {
    display: none;
  }

  .rate-strip-label {
    max-width: unset;
  }

  /* Amortization header */
  .amort-section {
    padding: 0 16px 60px;
  }

  .amort-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .amort-title {
    font-size: 17px;
  }

  .amort-header>div {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .download-btn,
  .toggle-amort {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
  }

  /* Donut chart */
  .chart-wrapper {
    padding: 20px 16px;
  }

  .donut-wrap {
    width: 160px;
    height: 160px;
    margin-bottom: 16px;
  }

  .donut-center-value {
    font-size: 13px;
  }

  .legend-item {
    font-size: 12px;
  }

  /* Footer */
  footer {
    padding: 20px 16px;
    font-size: 12px;
  }
}

/* Extra-small screens */
@media (max-width: 380px) {
  .header-badge {
    display: none;
  }

  .result-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .result-card:last-child {
    grid-column: span 1;
  }

  .result-amount {
    font-size: 18px;
  }

  .result-label {
    font-size: 10px;
  }

  .tab-btn {
    font-size: 11px;
    padding: 9px 6px;
  }
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* ── Share Button ── */
.share-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.share-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.share-btn:hover {
  border-color: var(--accent-purple);
  color: var(--text-inverse);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}

.share-btn:hover::before {
  opacity: 1;
}

.share-btn span {
  position: relative;
  z-index: 1;
}

.share-btn svg {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.share-btn.copied {
  border-color: var(--accent-teal);
  color: var(--accent-teal);
  background: rgba(20, 184, 166, 0.12);
}

.share-btn.copied::before {
  opacity: 0 !important;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 184, 166, 0.15);
  border: 1px solid rgba(20, 184, 166, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #2dd4bf;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* -- Switch Toggle -- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .4s;
  border-radius: 24px;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider {
  background-color: var(--accent-purple);
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
}
/* For No Cost EMI, use teal */
#noCostEmiContainer .switch input:checked + .slider {
  background-color: #10b981;
}

/* Adjust result-grid for foreclosure layout */
.fc-grid {
  grid-template-columns: repeat(3, 1fr) !important;
}
@media (max-width: 600px) {
  .fc-grid {
    grid-template-columns: repeat(1, 1fr) !important;
  }
}


/* -- Custom Tooltip -- */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 14px;
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-line;
  border-radius: 10px;
  box-shadow: var(--shadow-glow);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  pointer-events: none;
  min-width: 220px;
  text-align: center;
}

[data-tooltip]::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  border-width: 6px;
  border-style: solid;
  border-color: var(--border-active) transparent transparent transparent;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}


/* -- Tooltip Wrapper -- */
.tooltip-wrap {
  position: relative;
  display: block;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Smooth Expandable Sections ── */
.expandable {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.expandable-inner {
  overflow: hidden;
  min-height: 0;
}

.expandable.expanded {
  grid-template-rows: 1fr;
  opacity: 1;
}
