/* ============================================================
   ClearMyEMI Clone — Premium Responsive Design
   ============================================================ */

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

:root {
  /* Premium Dark Mode Inspired Palette - adaptable */
  --primary: #4F46E5;
  /* Indigo 600 */
  --primary-dark: #3730A3;
  /* Indigo 800 */
  --primary-light: #EEF2FF;
  /* Indigo 50 */

  --accent: #06B6D4;
  /* Cyan 500 */
  --accent-light: #CFFAFE;
  /* Cyan 50 */

  --success: #10B981;
  /* Emerald 500 */
  --success-light: #D1FAE5;
  /* Emerald 50 */
  --success-dark: #059669;
  /* Emerald 600 */

  --warning: #F59E0B;
  /* Amber 500 */
  --danger: #EF4444;
  /* Red 500 */

  /* Surface Colors */
  --bg-color: #F8FAFC;
  /* Slate 50 */
  --surface: #FFFFFF;
  --surface-hover: #F1F5F9;
  /* Slate 100 */

  /* Text Colors */
  --text-main: #0F172A;
  /* Slate 900 */
  --text-muted: #475569;
  /* Slate 600 */
  --text-light: #94A3B8;
  /* Slate 400 */

  /* Borders & Shadows */
  --border: #E2E8F0;
  /* Slate 200 */

  /* Smooth Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.3);

  /* Border Radius */
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Container ── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  /* 24px */
}

/* ── Typography ── */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-main);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* ── Header ── */
.header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: all 0.3s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.5rem;
  /* 72px */
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* 8px */
  font-size: 1.5rem;
  /* 24px */
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.05em;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo-dot {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 0.5rem;
  /* 8px */
}

.nav-link {
  padding: 0.5rem 1rem;
  /* 8px 16px */
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

/* ── Hero ── */
.hero {
  /* Deep, vibrant gradient */
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  padding: 5rem 0 6rem;
  /* 80px 0 96px */
  text-align: center;
  position: relative;
  overflow: hidden;
  color: white;
}

/* Decorative background shapes for the hero */
.hero::before,
.hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
}

.hero::before {
  background: rgba(79, 70, 229, 0.4);
  width: 400px;
  height: 400px;
  top: -100px;
  left: -100px;
}

.hero::after {
  background: rgba(6, 182, 212, 0.3);
  width: 300px;
  height: 300px;
  bottom: -50px;
  right: -50px;
}

.hero .container {
  position: relative;
  z-index: 1;
  /* Bring text above the blur decoration */
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  /* Pill shape */
  font-size: 0.875rem;
  /* 14px */
  font-weight: 600;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  /* Responsive typography */
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #FFFFFF, #E2E8F0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: clamp(1.125rem, 2vw, 1.25rem);
  /* 18px to 20px */
  color: #94A3B8;
  /* Slate 400 */
  max-width: 600px;
  margin: 0 auto;
}

/* ── Calculator Section ── */
.calculator-section {
  padding: 0 0 5rem;
  /* Remove top padding, overlap hero */
  margin-top: -3rem;
  /* Pull up to overlap hero (-48px) */
  position: relative;
  z-index: 10;
  /* Above hero background */
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0 auto 2rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-md);
  width: fit-content;
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  /* 12px 24px */
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

/* Calculator Card */
.calc-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1));
  padding: 2.5rem;
  /* 40px */
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  /* 64px */
  align-items: flex-start;
}

.calc-heading {
  font-size: 1.5rem;
  /* 24px */
  color: var(--text-main);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-heading::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.5rem;
  background: var(--primary);
  border-radius: 4px;
}

/* Input Groups */
.input-group {
  margin-bottom: 2rem;
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.input-label-row label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.input-value-box {
  display: flex;
  align-items: center;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  gap: 0.25rem;
  transition: all 0.2s;
}

.input-value-box:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}

.input-value-box input {
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 1.125rem;
  /* 18px */
  font-weight: 700;
  color: var(--text-main);
  width: 120px;
  text-align: right;
  outline: none;
  /* Hide arrows */
  -moz-appearance: textfield;
}

.input-value-box input::-webkit-outer-spin-button,
.input-value-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.currency,
.suffix {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
}

/* Tenure Box */
.tenure-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tenure-box input {
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  width: 70px;
  text-align: center;
  outline: none;
  transition: all 0.2s;
  -moz-appearance: textfield;
}

.tenure-box input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.tenure-box input::-webkit-outer-spin-button,
.tenure-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tenure-toggle {
  display: flex;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  gap: 0.25rem;
}

.tenure-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tenure-btn:hover {
  color: var(--text-main);
}

.tenure-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  /* Optional: add border to active state */
}

/* Sliders */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  /* Slightly thicker */
  border-radius: 9999px;
  background: linear-gradient(to right, var(--primary) var(--val, 25%), var(--border) var(--val, 25%));
  outline: none;
  cursor: pointer;
  touch-action: none;
  /* Allow the slider to capture horizontal touch swipes on mobile */
  margin: 1rem 0 0.5rem;
  position: relative;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--primary);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: grab;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: var(--shadow-glow);
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--primary);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s;
}

.slider::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: var(--shadow-glow);
}

.slider-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* EMI Type (Car) */
.input-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: block;
}

.emi-type-select {
  display: flex;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  gap: 0.25rem;
  width: 100%;
  /* Fill container */
}

.emi-type-btn {
  flex: 1;
  /* Equal width */
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.emi-type-btn:hover {
  color: var(--text-main);
}

.emi-type-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Calculate Button */
.calculate-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  /* 16px 24px */
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 1.125rem;
  /* 18px */
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.calculate-btn::after {
  content: '→';
  font-size: 1.25rem;
  transition: transform 0.2s ease;
}

.calculate-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.5);
  transform: translateY(-2px);
}

.calculate-btn:hover::after {
  transform: translateX(4px);
}

.calculate-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

/* ── Results Panel (Right Side) ── */
.calc-results {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: 100%;
}

/* Result Cards - Stack vertically for cleaner look on desktop */
.result-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.result-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
  /* Slight hover effect */
}

/* Specific Card Styling */
.emi-card {
  border-left: 4px solid var(--primary);
  background: linear-gradient(to right, var(--primary-light), var(--surface));
}

.interest-card {
  border-left: 4px solid var(--warning);
}

.total-card {
  border-left: 4px solid var(--success);
}

.result-info {
  display: flex;
  flex-direction: column;
}

.result-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  display: none;
  /* Hide icon for cleaner look, text is enough */
}

.result-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.result-value {
  font-size: 1.5rem;
  /* 24px */
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  /* Align numbers in fonts */
}

/* Highlight the main EMI value */
.emi-card .result-value {
  color: var(--primary);
  font-size: 2rem;
  /* 32px */
}

/* Pie Chart Container */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  flex-grow: 1;
  /* Take up remaining space */
  display: flex;
  flex-direction: column;
}

.chart-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  text-align: center;
}

.pie-chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  flex-grow: 1;
  justify-content: center;
}

.pie-chart-wrapper canvas {
  max-width: 220px;
  max-height: 220px;
  width: 100%;
  /* Responsive canvas */
}

.pie-legend {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.legend-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.principal-dot {
  background: var(--primary);
}

.interest-dot {
  background: var(--warning);
}

.legend-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.legend-pct {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

/* ── Optimization Strategies Section ── */
.optimization-section {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 3rem;
  margin-bottom: 2.5rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.optimization-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(to right, var(--primary), var(--accent));
}

.optimization-title {
  font-size: 1.75rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  text-align: center;
}

.optimization-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 3rem;
  max-width: 600px;
  margin-inline: auto;
}

.opt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.opt-card {
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}

.opt-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--primary-light);
}

.opt-card.selected:not(.opt-base) {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
  background: linear-gradient(135deg, var(--surface), #F0FDF4);
}

/* Fix grid to put base card and last card on new row if needed */
.opt-base {
  background: linear-gradient(to right, var(--primary-dark), var(--primary));
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.opt-base:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.4);
}

.opt-base .opt-title {
  color: white;
}

.opt-base .opt-label {
  color: rgba(255, 255, 255, 0.7);
}

.opt-base .opt-value {
  color: white;
}

.opt-base .opt-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.opt-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.opt-icon {
  font-size: 1.25rem;
  background: var(--surface);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.opt-base .opt-icon {
  color: initial;
}

/* keep emoji color */

.opt-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}

.opt-badge {
  background: var(--success);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.opt-radio {
  display: flex;
  align-items: center;
}

.opt-radio label {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.opt-radio input {
  display: none;
}

.opt-card.selected .opt-radio label {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.opt-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.opt-stats.highlight {
  background: var(--success-light);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--success);
}

.opt-card.selected .opt-stats.highlight {
  background: var(--surface);
}

.opt-stat {
  display: flex;
  flex-direction: column;
}

.opt-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.opt-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.success-text {
  color: var(--success-dark);
}

.opt-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.opt-ctrl-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.opt-input-sm {
  width: 60px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 700;
  font-family: inherit;
  font-size: 1rem;
  color: var(--primary);
  outline: none;
  transition: border-color 0.2s;
}

.opt-input-sm:focus {
  border-color: var(--primary);
}

.opt-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
}

.opt-footer.large-footer {
  padding-top: 1.5rem;
  margin-top: 3.5rem;
  /* offset for missing controls */
}

/* ── Bar Chart & Schedule Wrappers ── */
.data-views {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Bar Chart */
.bar-chart-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  border: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.bar-chart-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2rem;
}

.bar-chart-wrapper {
  position: relative;
  height: 350px;
  /* Slightly taller */
  width: 100%;
}

/* Payment Schedule */
.schedule-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  border: 1px solid var(--border);
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.schedule-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.schedule-toggle {
  display: flex;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  gap: 0.25rem;
}

.schedule-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.schedule-btn:hover {
  color: var(--text-main);
}

.schedule-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  scrollbar-width: thin;
  /* Firefox */
}

/* Custom Scrollbar for table wrapper */
.table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--bg-color);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--text-light);
  border-radius: 4px;
}


.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: right;
  min-width: 600px;
  /* Ensure table doesn't squish too much */
}

.schedule-table th {
  background: var(--bg-color);
  color: var(--text-muted);
  padding: 1rem 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  text-align: center;
}

.schedule-table th:nth-child(2),
.schedule-table td:nth-child(2) {
  text-align: left;
}

.schedule-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.schedule-table td:first-child {
  font-weight: 600;
  color: var(--text-muted);
}

.schedule-table td:nth-child(2) {
  color: var(--text-muted);
  font-weight: 500;
}

.schedule-table tbody tr {
  transition: background-color 0.15s;
}

.schedule-table tbody tr:hover {
  background-color: var(--surface-hover);
}

.year-row {
  background-color: var(--primary-light) !important;
}

.year-row td {
  color: var(--primary-dark) !important;
  font-weight: 700 !important;
}


/* ── Info Section ── */
.info-section {
  padding: 5rem 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 5rem;
}

.info-section-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 3rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.info-card {
  background: var(--bg-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.info-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.info-card h2 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.formula-box {
  background: var(--surface);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.formula {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 1rem;
  color: var(--primary);
  font-weight: 700;
}

.formula-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.formula-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.formula-list strong {
  color: var(--text-main);
  background: var(--surface);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  min-width: 24px;
  text-align: center;
}

.loan-type-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}

.loan-type-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.loan-type-icon {
  font-size: 1.5rem;
  background: var(--surface);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.loan-type-item div strong {
  color: var(--text-main);
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.loan-type-item div p {
  font-size: 0.85rem;
  margin: 0;
}

/* ── Footer ── */
.footer {
  background: var(--text-main);
  color: #94A3B8;
  /* Slate 400 */
  padding: 3rem 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
}

.footer-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-text {
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: #CBD5E1;
  /* Slate 300 */
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: white;
}

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

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

.result-value.updated {
  animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ── Responsive Design ── */

@media (min-width: 1280px) {
  .container {
    padding: 0 2rem;
  }
}

@media (max-width: 1024px) {
  .calc-grid {
    gap: 2rem;
  }

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

  .info-card:last-child {
    grid-column: span 2;
    flex-direction: row;
    gap: 2rem;
  }

  .info-card:last-child h2 {
    flex-basis: 30%;
  }

  .loan-type-list {
    flex-direction: row;
    margin-top: 0;
    flex: 1;
  }

  .loan-type-item {
    flex: 1;
  }

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

@media (max-width: 860px) {
  .calc-card {
    padding: 1.5rem;
  }

  .calc-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .calc-results {
    position: relative;
  }

  .result-cards {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .result-card {
    flex: 1;
    min-width: 200px;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .pie-chart-wrapper {
    flex-direction: row;
    justify-content: center;
  }

  .pie-legend {
    flex-direction: column;
    width: auto;
    border-top: none;
    border-left: 1px solid var(--border);
    padding-left: 1.5rem;
    padding-top: 0;
  }

  .bar-chart-card,
  .schedule-card,
  .optimization-section {
    padding: 1.5rem;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 14px;
  }

  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
    gap: 1rem;
  }

  .nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .hero {
    padding: 3rem 0 4rem;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .calculator-section {
    margin-top: -2rem;
  }

  .tabs {
    flex-direction: column;
    width: 100%;
  }

  .calc-card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .input-group {
    padding: 1rem;
  }

  .input-label-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .input-value-box,
  .tenure-box {
    width: 100%;
    justify-content: space-between;
  }

  .tenure-box {
    flex-wrap: wrap;
  }

  .tenure-box input {
    flex: 1;
  }

  .result-cards {
    flex-direction: column;
  }

  .result-card {
    flex-direction: row;
    align-items: center;
  }

  .pie-chart-wrapper {
    flex-direction: column;
  }

  .pie-legend {
    flex-direction: row;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    padding-left: 0;
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
  }

  .bar-chart-card,
  .schedule-card,
  .optimization-section {
    padding: 1rem !important;
  }

  .schedule-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .schedule-toggle {
    width: 100%;
  }

  .schedule-btn {
    flex: 1;
    text-align: center;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-card:last-child {
    grid-column: span 1;
    flex-direction: column;
  }

  .loan-type-list {
    flex-direction: column;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .opt-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {

  .input-value-box input,
  .tenure-box input {
    font-size: 1rem;
  }

  .pie-chart-wrapper canvas {
    max-width: 180px;
    max-height: 180px;
  }
}