/* ==========================================================================
   EMI Master - Professional Calculator Website
   Design system: clean, trustworthy, AdSense-friendly layout
   ========================================================================== */

:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #e3f2fd;
  --accent: #26a69a;
  --text: #2c3e50;
  --text-muted: #64748b;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(15, 40, 80, 0.08);
  --shadow-lg: 0 6px 24px rgba(15, 40, 80, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  max-width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.brand:hover {
  text-decoration: none;
  color: #fff;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--primary);
  font-weight: 800;
}

.main-nav ul {
  display: flex;
  list-style: none;
  gap: 4px;
}

.main-nav a {
  color: rgba(255, 255, 255, 0.92);
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.95rem;
}

.main-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
  text-decoration: none;
  color: #fff;
}

.main-nav a.active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 1.2rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.theme-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-size: 1.05rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, #1976d2 100%);
  color: #fff;
  padding: 48px 16px 56px;
  text-align: center;
}

.hero h1 {
  font-size: 2.3rem;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero p {
  font-size: 1.12rem;
  max-width: 700px;
  margin: 0 auto 24px;
  color: rgba(255, 255, 255, 0.9);
}

.hero-compact {
  padding: 34px 16px 36px;
}

.hero-compact h1 {
  font-size: 1.9rem;
  margin-bottom: 8px;
}

.hero-compact p {
  margin-bottom: 0;
}

.hero-search {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}

.hero-search input {
  flex: 1;
  padding: 13px 18px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  outline: none;
}

.hero-search button {
  padding: 13px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.hero-search button:hover {
  filter: brightness(1.08);
}

/* ===== Layout: content + sidebar ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 28px;
  padding: 24px 32px 56px;
  max-width: 100%;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
}

.sidebar-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.sidebar-card h3 {
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  padding: 11px 16px;
  font-weight: 700;
}

.sidebar-card ul {
  list-style: none;
}

.sidebar-card li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92rem;
}

.sidebar-card li:last-child a {
  border-bottom: none;
}

.sidebar-card li a:hover {
  background: var(--primary-light);
  text-decoration: none;
  color: var(--primary-dark);
}

.sidebar-card li a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.sidebar-icon {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* ===== Sidebar category accordion ===== */
.cat-group .cat-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.cat-group .cat-toggle:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.cat-arrow {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.cat-group.open .cat-arrow {
  transform: rotate(180deg);
}

.cat-items {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: #f8fafc;
}

.cat-group.open .cat-items {
  max-height: 520px;
  overflow-y: auto;
}

.cat-items li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 46px;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.cat-items li:last-child a {
  border-bottom: none;
}

.cat-items li a:hover {
  color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}

.cat-items li a.active {
  color: var(--primary-dark);
  font-weight: 600;
  background: var(--primary-light);
}

/* ===== Main content ===== */
.main-content {
  min-width: 0;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.page-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ===== Premium design enhancements ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
  }

  50% {
    box-shadow: 0 8px 28px rgba(21, 101, 192, 0.45);
  }
}

.card,
.content-section,
.calc-card,
.result-panel.show {
  animation: fadeInUp 0.45s ease both;
}

.content-section:nth-of-type(2) {
  animation-delay: 0.05s;
}

.content-section:nth-of-type(3) {
  animation-delay: 0.1s;
}

.content-section:nth-of-type(4) {
  animation-delay: 0.15s;
}

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(21, 101, 192, 0.12), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(16, 185, 129, 0.08), transparent 50%),
    linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.hero::before {
  width: 420px;
  height: 420px;
  top: -160px;
  right: -120px;
}

.hero::after {
  width: 260px;
  height: 260px;
  bottom: -110px;
  left: -80px;
}

.hero h1,
.hero p,
.hero-search {
  position: relative;
  z-index: 1;
}

.result-main {
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.result-item {
  backdrop-filter: blur(4px);
  transition: transform 0.2s, background 0.2s;
}

.result-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.18);
}

.calc-card {
  position: relative;
  overflow: hidden;
}

.calc-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #10b981);
  opacity: 0;
  transition: opacity 0.25s;
}

.calc-card:hover::after {
  opacity: 1;
}

.calc-card .icon {
  transition: transform 0.25s ease;
}

.calc-card:hover .icon {
  transform: scale(1.12);
}

.btn-primary {
  animation: pulseGlow 3s ease-in-out infinite;
}

.related-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
}

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

.related-icon {
  font-size: 1.4rem;
}

.quick-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.fact-chip {
  background: linear-gradient(135deg, var(--primary-light), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(21, 101, 192, 0.2);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  display: flex;
  gap: 6px;
  align-items: center;
}

.fact-chip strong {
  font-weight: 700;
}

.toc-card ol {
  margin: 6px 0 0 20px;
  column-count: 2;
  column-gap: 28px;
}

.toc-card li {
  margin-bottom: 6px;
  break-inside: avoid;
}

.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 10px;
}

.pros,
.cons {
  border-radius: 10px;
  padding: 16px;
}

.pros {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.cons {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.pros h3,
.cons h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.tips-box {
  border-left: 4px solid #f59e0b;
}

.tips-box li {
  color: var(--text-muted);
}

.form-actions {
  justify-content: flex-end;
}

/* ===== Smart insights panel ===== */
.insights-panel {
  animation: fadeInUp 0.45s ease both;
}

.insights-empty {
  color: var(--text-muted);
  font-size: 0.92rem;
  padding: 8px 2px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.insight-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.insight-card.insight-primary {
  background: linear-gradient(135deg, var(--primary-light), rgba(16, 185, 129, 0.08));
  grid-column: span 2;
  border: 1px solid rgba(21, 101, 192, 0.2);
}

.insight-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.insight-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.insight-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.insight-bar {
  height: 14px;
  background: rgba(21, 101, 192, 0.12);
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.insight-bar .bar-interest {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 8px;
  transition: width 0.5s ease;
}

.insight-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

[data-theme="dark"] .insight-card {
  border-color: #2a3a55;
}

[data-theme="dark"] .insight-value {
  color: #9cc9f5;
}

[data-theme="dark"] .insight-card.insight-primary {
  background: linear-gradient(135deg, #16233c, rgba(16, 185, 129, 0.06));
}

/* ===== Ad placeholders ===== */
.ad-slot {
  background: var(--card-bg);
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.8rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}

.ad-slot-responsive {
  height: 120px;
}

.ad-slot-sidebar {
  height: 260px;
}

.ad-slot-label {
  letter-spacing: 1px;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.card p {
  color: var(--text-muted);
  margin-bottom: 14px;
}

.card p:last-child {
  margin-bottom: 0;
}

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.input-wrap {
  position: relative;
}

.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrap .prefix {
  left: 14px;
}

.input-wrap .suffix {
  right: 14px;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
  font-family: var(--font);
}

.input-wrap .prefix+input {
  padding-left: 42px;
}

.input-wrap .suffix+input,
.form-group input+.suffix {
  padding-right: 42px;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
  background: #fff;
}

.form-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-value {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  padding: 12px 26px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  font-family: var(--font);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

/* ===== Result panel ===== */
.result-panel {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  padding: 28px;
  color: #fff;
  margin-bottom: 24px;
  display: none;
}

.result-panel.show {
  display: block;
}

.result-panel h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.result-main {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 20px;
  word-break: break-word;
}

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

.result-item {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.result-item .label {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 3px;
}

.result-item .value {
  font-size: 1.15rem;
  font-weight: 700;
}

.result-item .value.positive {
  color: #a5d6a7;
}

.result-item .value.negative {
  color: #ef9a9a;
}

.result-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.result-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: var(--font);
}

.result-actions button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.payoff-note {
  margin-top: 14px;
  background: rgba(165, 214, 167, 0.18);
  border: 1px solid rgba(165, 214, 167, 0.45);
  color: #c8e6c9;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
}

.payoff-note.show {
  display: block;
}

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
  max-height: 480px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 640px;
}

thead th {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #f8fafc;
}

tbody td.num,
thead th.num {
  text-align: right;
}

tfoot td {
  padding: 10px 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

/* ===== Calculator grid (home) ===== */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.calc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

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

.calc-card .icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.calc-card h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.calc-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
  margin-bottom: 14px;
}

.calc-card a {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.92rem;
}

/* ===== Info / content sections ===== */
.content-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.content-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.content-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 18px 0 8px;
}

.content-section p {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.content-section ul,
.content-section ol {
  margin: 0 0 14px 22px;
  color: var(--text-muted);
}

.content-section li {
  margin-bottom: 6px;
}

.content-section code {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.definition {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
}

.definition p {
  margin-bottom: 0;
  color: var(--text);
}

/* ===== FAQ ===== */
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-q {
  padding: 14px 18px;
  font-weight: 600;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-q:hover {
  background: var(--primary-light);
}

.faq-q .arrow {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.faq-item.open .arrow {
  transform: rotate(90deg);
}

.faq-a {
  padding: 0 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
  color: var(--text-muted);
}

.faq-item.open .faq-a {
  padding: 4px 18px 14px;
  max-height: 500px;
}

/* ===== Compare (loan payoff) ===== */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}

.compare-card {
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
}

.compare-card.without {
  background: var(--card-bg);
}

.compare-card.with {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.compare-card h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.compare-card .amount {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.compare-card.without .amount {
  color: var(--text);
}

.compare-card ul {
  list-style: none;
  font-size: 0.88rem;
  display: grid;
  gap: 8px;
}

.compare-card.with ul {
  color: rgba(255, 255, 255, 0.9);
}

.compare-card ul strong {
  color: inherit;
}

.save-banner {
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.1), rgba(38, 166, 154, 0.12));
  border: 1px solid rgba(22, 163, 74, 0.4);
  border-radius: var(--radius);
  padding: 18px 22px;
  color: #166534;
  font-weight: 600;
  font-size: 0.95rem;
  display: none;
}

/* ===== Footer ===== */
.site-footer {
  background: #1e293b;
  color: #cbd5e1;
  margin-top: 40px;
}

.footer-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 40px 32px 24px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
}

.footer-col h4 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 14px;
}

.footer-col p {
  font-size: 0.9rem;
  color: #94a3b8;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 8px;
}

.footer-col a {
  color: #cbd5e1;
  font-size: 0.9rem;
}

.footer-col a:hover {
  color: #fff;
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid #334155;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 32px;
  text-align: center;
  font-size: 0.82rem;
  color: #94a3b8;
}

.footer-bottom a {
  color: #cbd5e1;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Back to top ===== */
.back-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 99;
}

.back-top.show {
  opacity: 1;
  visibility: visible;
}

/* ===== 404 ===== */
.notfound {
  text-align: center;
  padding: 80px 20px;
}

.notfound .code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.notfound h1 {
  margin: 12px 0 8px;
  font-size: 1.6rem;
}

.notfound p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ===== Wide desktop ===== */
@media (min-width: 1500px) {
  .form-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .result-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1900px) {
  .form-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Dark / Night mode ===== */
[data-theme="dark"] {
  --primary: #5aa2f0;
  --primary-dark: #2b7fd6;
  --primary-light: #1c2f4a;
  --accent: #3ec6b7;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --border: #334155;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #0b1e3a 0%, #123c7a 55%, #1b4f96 100%);
}

[data-theme="dark"] .brand-logo {
  background: #1c2f4a;
  color: #7db8f5;
}

[data-theme="dark"] .sidebar-card h3 {
  background: var(--primary-dark);
}

[data-theme="dark"] .sidebar-card li a,
[data-theme="dark"] .cat-group .cat-toggle {
  color: var(--text);
}

[data-theme="dark"] .sidebar-card li a:hover,
[data-theme="dark"] .cat-group .cat-toggle:hover,
[data-theme="dark"] .cat-items li a:hover,
[data-theme="dark"] .cat-items li a.active {
  background: var(--primary-light);
  color: #9cc9f5;
}

[data-theme="dark"] .ad-slot {
  background: #1e293b;
  border-color: #334155;
  color: #64748b;
}

[data-theme="dark"] .form-group input[type="number"],
[data-theme="dark"] .form-group input[type="text"],
[data-theme="dark"] .form-group select {
  background: #0f172a;
  color: var(--text);
  border-color: #334155;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus {
  background: #16223a;
  border-color: var(--primary);
}

[data-theme="dark"] .form-group label {
  color: #cbd5e1;
}

[data-theme="dark"] thead th {
  background: #16233c;
  color: #9cc9f5;
}

[data-theme="dark"] tbody td {
  border-bottom-color: #2a3a55;
}

[data-theme="dark"] tbody tr:hover {
  background: #24344d;
}

[data-theme="dark"] tfoot td {
  background: #16233c;
  color: #9cc9f5;
}

[data-theme="dark"] .faq-q {
  background: #24344d;
}

[data-theme="dark"] .faq-q:hover {
  background: #1c2f4a;
}

[data-theme="dark"] .definition {
  background: #16233c;
}

[data-theme="dark"] .cat-items {
  background: #16233c;
}

[data-theme="dark"] .btn-outline {
  background: transparent;
  color: #9cc9f5;
  border-color: var(--primary);
}

[data-theme="dark"] .btn-outline:hover {
  background: var(--primary-light);
}

[data-theme="dark"] .result-item {
  background: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .calc-card,
[data-theme="dark"] .content-section,
[data-theme="dark"] .card {
  border-color: #2a3a55;
}

[data-theme="dark"] .calc-card:hover {
  border-color: var(--primary);
}

[data-theme="dark"] .compare-card.without {
  border-color: #2a3a55;
}

[data-theme="dark"] .save-banner {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.4);
}

[data-theme="dark"] .payoff-note {
  background: rgba(165, 214, 167, 0.12);
}

[data-theme="dark"] .content-section code {
  background: #1c2f4a;
  color: #9cc9f5;
}

[data-theme="dark"] .footer-bottom {
  border-top-color: #2a3a55;
}

[data-theme="dark"] .notfound .code {
  color: var(--primary);
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    order: 2;
  }

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

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--primary-dark);
    padding: 12px;
  }

  .main-nav.open {
    display: block;
  }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .main-nav a {
    display: block;
    padding: 12px 16px;
  }

  .hero h1 {
    font-size: 1.7rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .hero-search {
    flex-direction: column;
  }

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

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

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

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

  .result-main {
    font-size: 1.9rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* Chart (histogram) */
.chart-box {
  margin-top: 20px;
  padding: 14px 14px 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-box .chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.chart-box canvas {
  display: block;
  width: 100%;
  height: 240px;
}

/* ===== Currency selector ===== */
.lang-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: rgba(255, 255, 255, 0.14);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='white' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 8px 32px 8px 14px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: 10px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.lang-select:hover {
  background-color: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.85);
}

.lang-select:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.lang-select option {
  color: var(--text);
  background: var(--card-bg);
  font-weight: 600;
  padding: 4px;
}

@media (max-width: 900px) {
  .lang-select {
    max-width: 118px;
  }
}