/* ============================================
   CALCNOW DESIGN SYSTEM
   Modern Calculator Site — Ad-Optimized Layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-alt: #f1f3f7;
  --border: #e2e5eb;
  --border-focus: #6366f1;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --info: #3b82f6;
  --info-soft: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Accessibility: skip link */
.skip-link { position: absolute; top: -100%; left: 16px; padding: 8px 16px; background: var(--accent); color: #fff; border-radius: var(--radius-sm); z-index: 999; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* === HEADER / NAV === */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

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

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
  font-weight: 700;
}

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

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* === PAGE LAYOUT (ad-optimized 3-col) === */
.page-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 32px;
}

.main-content { min-width: 0; }

/* === AD PLACEHOLDERS === */
.ad-slot {
  background: var(--surface-alt);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-slot-sidebar {
  width: 160px;
  min-height: 600px;
  position: sticky;
  top: 96px;
}

.ad-slot-banner {
  width: 100%;
  height: 90px;
  margin-bottom: 24px;
}

.ad-slot-inline {
  width: 100%;
  height: 250px;
  margin: 32px 0;
}

/* === BREADCRUMB === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

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

/* === CALCULATOR CARD === */
.calc-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calc-header {
  padding: 32px 32px 24px;
  border-bottom: 1px solid var(--border);
}

.calc-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}

.calc-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.calc-body {
  padding: 32px;
}

/* === FORM ELEMENTS === */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.unit-toggle {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.unit-toggle button {
  padding: 8px 18px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.unit-toggle button.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* === RESULTS === */
.result-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: none;
}

.result-section.visible { display: block; }

.result-hero {
  text-align: center;
  padding: 28px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.result-hero .result-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.result-hero .result-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}

.result-hero .result-unit {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.result-item {
  padding: 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}

.result-item .ri-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.result-item .ri-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.result-bar {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  margin: 16px 0;
  overflow: hidden;
}

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

/* Status colors */
.status-good { color: var(--success); }
.status-warning { color: var(--warning); }
.status-danger { color: var(--danger); }
.bg-good { background: var(--success); }
.bg-warning { background: var(--warning); }
.bg-danger { background: var(--danger); }

/* === INFO SECTION (SEO CONTENT) === */
.info-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-top: 32px;
}

.info-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.info-section h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 24px 0 12px;
}

.info-section p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 12px;
  line-height: 1.7;
}

.info-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.875rem;
}

.info-section th,
.info-section td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.info-section th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === RELATED CALCULATORS === */
.related-calcs {
  margin-top: 32px;
}

.related-calcs h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.related-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.related-grid a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.related-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* === FOOTER === */
.site-footer {
  max-width: 1200px;
  margin: 48px auto 0;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
  list-style: none;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-links a:hover { color: var(--accent); }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 1fr;
    padding: 20px 16px;
  }
  .ad-slot-sidebar { display: none; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .calc-header { padding: 24px 20px 20px; }
  .calc-body { padding: 20px; }
  .header-inner { padding: 0 16px; }
  .nav-links { display: none; }
  .mobile-menu-btn { display: flex; }
  .info-section { padding: 24px 20px; }
  .result-hero .result-value { font-size: 2rem; }
  .site-footer { flex-direction: column; gap: 12px; text-align: center; }
}

@media (max-width: 480px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .calc-header h1 { font-size: 1.375rem; }
  .result-hero .result-value { font-size: 1.75rem; }
  .related-grid { grid-template-columns: 1fr; }
}

/* === MOBILE MENU === */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.5rem;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 99;
  padding: 12px 16px;
}

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

.mobile-nav a {
  display: block;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.mobile-nav a:hover,
.mobile-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* === RESULT ANIMATIONS === */
.result-section.visible {
  display: block;
  animation: fadeSlideUp 0.35s ease-out;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-hero .result-value {
  animation: countPop 0.3s ease-out;
}

@keyframes countPop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

/* === INPUT VALIDATION STATES === */
.form-group input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.form-group input:valid:not(:placeholder-shown) {
  border-color: var(--success);
}

/* === PRINT === */
@media print {
  .site-header, .site-footer, .ad-slot, .related-calcs, .mobile-menu-btn, .mobile-nav, .btn { display: none !important; }
  .page-layout { grid-template-columns: 1fr; }
  .result-section { display: block !important; border: 1px solid #ccc; }
  .calc-card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}

/* === SLIDER === */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  border: none;
  margin: 8px 0;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
  border: 3px solid white;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
  border: 3px solid white;
}

input[type="range"]:focus {
  outline: none;
}

/* === FORMULA BOX === */
.formula-box {
  background: #1e1b2e;
  color: #e2e8f0;
  padding: 20px 24px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.8;
  margin: 16px 0;
  overflow-x: auto;
}

.formula-box .highlight { color: #a78bfa; font-weight: 600; }

/* === UTILITY === */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-sm { margin-top: 8px; }
.mb-sm { margin-bottom: 8px; }
.mt-md { margin-top: 16px; }
.mb-md { margin-bottom: 16px; }

/* === TOOLTIP === */
.tooltip {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--text-muted);
}
.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.tooltip:hover::after { opacity: 1; }

/* === NOTICE / DISCLAIMER === */
.notice {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.6;
  margin-top: 16px;
}
.notice-info { background: var(--info-soft); color: var(--info); border: 1px solid #bfdbfe; }
.notice-warning { background: var(--warning-soft); color: #92400e; border: 1px solid #fde68a; }

/* === TABLE STRIPES === */
.info-section tr:nth-child(even) {
  background: var(--surface-alt);
}

/* === SEO HEADING ANCHORS === */
.info-section h2,
.info-section h3 {
  scroll-margin-top: 80px;
}

/* Finance decision tools */
.tool-shell{max-width:960px;margin:40px auto;padding:0 24px}.tool-hero{text-align:center;margin-bottom:28px}.tool-hero h1{font-size:clamp(2rem,5vw,3rem);line-height:1.1;margin-bottom:12px}.tool-hero p{max-width:720px;margin:auto;color:var(--text-secondary)}.tool-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:28px}.tool-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.tool-fields label:not(.check){font-size:.85rem;font-weight:700;margin-bottom:-10px}.tool-fields input,.tool-fields select{width:100%;padding:12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text-primary);font:inherit}.tool-fields .check{display:flex;gap:8px;align-items:center}.tool-result{margin-top:24px;background:var(--accent-soft);border-radius:var(--radius);padding:20px}.result-list div{display:flex;justify-content:space-between;gap:20px;padding:10px 0;border-bottom:1px solid var(--border)}.result-list div:last-child{border:0}.tool-copy{margin-top:32px}.tool-copy h2{margin:28px 0 10px}.tool-copy p,.tool-copy li{color:var(--text-secondary)}.tool-copy ul{padding-left:22px}.tool-note{margin-top:24px;padding:16px;border-left:4px solid var(--warning);background:var(--warning-soft);font-size:.9rem}.cluster-links{display:flex;flex-wrap:wrap;gap:10px;margin-top:24px}.cluster-links a{padding:8px 12px;border:1px solid var(--border);border-radius:999px;text-decoration:none;color:var(--accent);font-weight:700;font-size:.85rem}@media(max-width:640px){.tool-fields{grid-template-columns:1fr}.tool-card{padding:20px}}
