* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 45%, #dbeafe 100%);
  background-attachment: fixed;
  color: #0f172a;
  line-height: 1.5;
  min-height: 100vh;
}

/* Per-page theme accents (driven by .theme-* on .app) */
.theme-home { --accent: #2563eb; --accent-2: #7c3aed; }
.theme-emi  { --accent: #2563eb; --accent-2: #06b6d4; }
.theme-eb   { --accent: #f59e0b; --accent-2: #ef4444; }
.theme-tax  { --accent: #16a34a; --accent-2: #0ea5e9; }

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  position: relative;
}

.lang-switch {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  gap: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  font-size: 0.85rem;
}

.lang-switch button {
  border: none;
  background: transparent;
  color: #475569;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.lang-switch button.active {
  background: var(--accent);
  color: #fff;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
}

header p {
  margin: 4px 0 20px;
  color: #64748b;
}

.layout {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 340px 1fr;
    align-items: start;
  }

  .results {
    display: grid;
    gap: 20px;
  }

  .schedule-card {
    grid-column: 1 / -1;
  }
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.loan-tabs,
.segmented {
  display: flex;
  gap: 6px;
}

.loan-tabs {
  margin-bottom: 18px;
}

.loan-tabs button,
.segmented button {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.loan-tabs button.active,
.segmented button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.field-value {
  color: #1d4ed8;
  font-variant-numeric: tabular-nums;
}

.field-value .unit {
  color: #64748b;
  font-weight: 400;
}

.input-box {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px 6px;
  background: #fff;
}

.input-box .unit {
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
}

.input-box input {
  width: 100px;
  border: none;
  outline: none;
  font-size: 0.95rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 3px 0;
  background: transparent;
}

.input-box input:focus {
  outline: none;
}

input[type='range'] {
  width: 100%;
  accent-color: #2563eb;
}

input[type='number'] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
}

.field-scale {
  display: flex;
  justify-content: space-between;
  color: #64748b;
  font-size: 0.75rem;
}

.hint {
  color: #64748b;
  font-size: 0.8rem;
  margin: 4px 0 0;
}

.summary-list {
  margin: 0;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed #e2e8f0;
}

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

.summary-item dt {
  color: #64748b;
  font-size: 0.9rem;
}

.summary-item dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-item.accent dd {
  font-size: 1.4rem;
  color: var(--accent);
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.chart-center-value {
  font-size: 1.4rem;
  font-weight: 700;
  fill: #0f172a;
}

.chart-center-label {
  font-size: 0.7rem;
  fill: #64748b;
}

.chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

.chart-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

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

.legend-dot.blue {
  background: #2563eb;
}

.legend-dot.amber {
  background: #f59e0b;
}

.schedule-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.schedule-head h2 {
  margin: 0;
}

.segmented.small button {
  flex: none;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #e2e8f0;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  color: #64748b;
  font-weight: 600;
}

.placeholder {
  padding: 40px 20px;
  text-align: center;
  color: #64748b;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.hero {
  text-align: center;
  padding: 36px 20px;
  margin: 8px 0 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #db2777 100%);
  background-size: 200% 200%;
  animation: heroShift 12s ease infinite;
  color: #fff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.25);
}

@keyframes heroShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hero h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.hero p {
  margin: 10px 0 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  opacity: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Themed banner for inner calculator pages (EMI / EB / Tax) */
.app > header:not(.hero) {
  text-align: center;
  padding: 30px 20px;
  margin: 8px 0 26px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.25);
}

.app > header:not(.hero) h1 {
  margin: 0;
  font-size: 2rem;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.app > header:not(.hero) p {
  margin: 8px 0 0;
  color: #fff;
  opacity: 0.95;
  font-size: 1.05rem;
}

.landing {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.calc-card {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: 5px solid #cbd5e1;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.calc-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.calc-card.emi {
  --c: #2563eb;
  --c2: #06b6d4;
  border-top-color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 8%, #fff), #fff);
}

.calc-card.eb {
  --c: #f59e0b;
  --c2: #ef4444;
  border-top-color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 8%, #fff), #fff);
}

.calc-card.tax {
  --c: #16a34a;
  --c2: #0ea5e9;
  border-top-color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 8%, #fff), #fff);
}

.calc-card.tax .calc-icon {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.calc-card.tax .calc-cta {
  color: #15803d;
}

.calc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  font-size: 1.8rem;
  margin-bottom: 14px;
}

.calc-card.emi .calc-icon {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.calc-card.eb .calc-icon {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.calc-card h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.calc-card p {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
  flex: 1;
}

.calc-cta {
  display: inline-block;
  align-self: flex-start;
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--c, #2563eb), var(--c2, #7c3aed));
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* CTA pill color is handled by the --c / --c2 gradient above */

.eb-section {
  margin-top: 36px;
  border-top: 1px solid #e2e8f0;
  padding-top: 24px;
}

.slab-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.slab-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.slab-row input {
  flex: 1 1 64px;
  min-width: 0;
  width: auto;
  padding: 8px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
}

.slab-sep {
  color: #64748b;
  font-size: 0.85rem;
}

.slab-remove {
  flex: 0 0 32px;
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 8px;
  width: 32px;
  height: 34px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.add-btn {
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  align-self: flex-start;
}

footer {
  margin-top: 32px;
  text-align: center;
  color: #64748b;
  font-size: 0.8rem;
}

/* Income tax compare */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.compare-col {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.compare-col.best {
  border-color: #16a34a;
  background: #f0fdf4;
}

.compare-name {
  font-size: 0.85rem;
  color: #64748b;
}

.compare-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 4px;
}

.compare-col.best .compare-val {
  color: #15803d;
}

.field.is-disabled {
  opacity: 0.45;
}

.field.is-disabled input {
  pointer-events: none;
}

/* EB info card: fixed charges + 500-unit cliff */
.info-card {
  margin-top: 22px;
}

.info-card h2 {
  font-size: 1.05rem;
  margin: 4px 0 10px;
  color: #0f172a;
}

.info-card h2.cliff-title {
  margin-top: 22px;
  color: #b45309;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.info-table th, .info-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  text-align: left;
}

.info-table th {
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

.info-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.info-card p {
  margin: 12px 0 0;
  color: #475569;
  line-height: 1.55;
  font-size: 0.95rem;
}

.cliff-compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0 0;
}

.cliff-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.cliff-tag {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.cliff-tag.tier1 { background: #dcfce7; color: #15803d; }
.cliff-tag.tier2 { background: #fee2e2; color: #b91c1c; }

.cliff-note {
  background: #f1f5f9;
  border-left: 3px solid #38bdf8;
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  color: #334155;
}

@media (max-width: 560px) {
  .cliff-row { flex-direction: column; align-items: flex-start; }
}