:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

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

.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-trigger-btn:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.kbd-shortcut {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

/* Page Layout */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.page-intro {
  margin-bottom: 2rem;
  text-align: left;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 800px;
}

/* Calculator Grid */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .calc-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

/* Form Controls */
.input-group {
  margin-bottom: 1.35rem;
}

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

.input-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.input-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  pointer-events: none;
}

.input-suffix {
  position: absolute;
  right: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  pointer-events: none;
}

.text-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.15s ease;
}

.text-input.has-prefix {
  padding-left: 2rem;
}

.text-input.has-suffix {
  padding-right: 2.25rem;
}

.text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Custom Range Slider */
.slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #cbd5e1;
  border-radius: 3px;
  outline: none;
  margin-top: 0.6rem;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

.slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* Preset Buttons */
.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.preset-btn {
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: #bfdbfe;
}

/* Toggle Switch / Tab Buttons */
.tab-group {
  display: flex;
  background-color: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Result Card Styles */
.result-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.hero-metric {
  text-align: center;
  padding: 1.25rem;
  background-color: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.hero-metric-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-dark);
  margin-bottom: 0.35rem;
}

.hero-metric-value {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.1;
}

.hero-metric-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Breakdown Rows */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-weight: 500;
}

.breakdown-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.breakdown-value {
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* Action Toolbar */
.action-toolbar {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.btn-secondary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #1e293b;
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 100;
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* Educational Content Section Below Fold */
.edu-content {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.edu-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.edu-subtitle {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.75rem 0 0.75rem;
}

.edu-text {
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.edu-table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.edu-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.edu-table th {
  background-color: #f1f5f9;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
}

.edu-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: #334155;
}

.edu-table tr:last-child td {
  border-bottom: none;
}

/* FAQ Accordion */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background-color: #ffffff;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-answer {
  padding: 0 1.25rem 1rem;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
}

.faq-item.open .faq-answer {
  display: block;
}

/* Search Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5rem;
}

.modal-backdrop.open {
  display: flex;
}

.search-modal-box {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.search-modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-modal-input {
  width: 100%;
  font-size: 1.05rem;
  border: none;
  outline: none;
  color: var(--text-main);
}

.search-results-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-main);
  transition: background-color 0.1s ease;
}

.search-result-item:hover, .search-result-item.selected {
  background-color: var(--primary-light);
}

.search-result-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.search-result-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background-color: #ffffff;
  border-top: 1px solid var(--border);
  padding: 3rem 1.25rem 2rem;
  margin-top: 4rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.footer-col-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.footer-link-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--primary);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Print Rules */
@media print {
  .site-header, .search-trigger-btn, .action-toolbar, .preset-pills, .slider-input, .faq-question svg, .site-footer {
    display: none !important;
  }
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }
  .card, .result-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}
