@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

:root {
  --primary: #1a3a5c;
  --primary-light: #2d5a8c;
  --accent: #e8a020;
  --accent2: #2ecc8f;
  --bg: #f4f6f9;
  --card: #ffffff;
  --card-alt: #f8fafc;
  --text: #1a2535;
  --muted: #6b7a8d;
  --border: #e2e8f0;
  --shadow: 0 2px 16px rgba(26,58,92,0.08);
  --shadow-lg: 0 12px 40px rgba(26,58,92,0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-bg: #1a3a5c;
}

[data-theme="dark"] {
  --primary: #4a90d9;
  --primary-light: #6ba3e0;
  --accent: #f5b73d;
  --accent2: #34d399;
  --bg: #0f1623;
  --card: #1a2535;
  --card-alt: #222f42;
  --text: #e8edf4;
  --muted: #94a3b8;
  --border: #2d3a4f;
  --shadow: 0 2px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --nav-bg: #14202e;
}

html { scroll-behavior: smooth; }

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* NAV */
nav {
  background: var(--nav-bg);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

.nav-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

.nav-links a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.hamburger { display: none; cursor: pointer; color: #fff; font-size: 1.5rem; }

/* HERO (homepage only) */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0f2540 100%);
  color: white;
  padding: 4rem 2rem 5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(232,160,32,0.08);
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -40px;
  width: 250px; height: 250px;
  border-radius: 50%;
  background: rgba(46,204,143,0.07);
}

.hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero h1 span { color: var(--accent); }

.hero p {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.75);
  max-width: 520px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

/* TOOL GRID (homepage) */
.tools-section { padding: 3rem 2rem; max-width: 1100px; margin: 0 auto; }

.section-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
}

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

.tool-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  border: 1.5px solid var(--border);
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(26,58,92,0.12);
}

.tool-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}

.tool-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.tool-card p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

/* CALCULATOR PAGE */
.calc-page { max-width: 820px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }

.page-header { margin-bottom: 2rem; }
.page-header .back { 
  color: var(--muted); font-size: 13px; text-decoration: none; 
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 1rem;
}
.page-header .back:hover { color: var(--primary); }

.page-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  color: var(--primary);
}

.page-header p { color: var(--muted); margin-top: 6px; font-size: 0.95rem; }

/* CALC CARD */
.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* INPUTS */
.input-group { margin-bottom: 1.5rem; }
.input-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within { border-color: var(--primary); }

.input-prefix, .input-suffix {
  padding: 0 14px;
  background: var(--card-alt);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  height: 46px;
  display: flex;
  align-items: center;
  border-right: 1.5px solid var(--border);
  white-space: nowrap;
}
.input-suffix { border-right: none; border-left: 1.5px solid var(--border); }

.input-wrap input[type=number] {
  flex: 1;
  border: none;
  padding: 0 14px;
  height: 46px;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: transparent;
  outline: none;
  -moz-appearance: textfield;
}
.input-wrap input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

.input-wrap input[type=range] {
  flex: 1;
  margin: 0 14px;
}

/* TWO COLUMN INPUTS */
.input-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* RESULTS */
.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 1.5rem; }

.result-card {
  background: var(--card-alt);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1.5px solid var(--border);
  text-align: center;
}

.result-card.highlight {
  background: var(--primary);
  border-color: var(--primary);
}

.result-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.result-card.highlight .result-label { color: rgba(255,255,255,0.65); }

.result-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.result-card.highlight .result-value { color: var(--accent); font-size: 1.4rem; }

/* CHART */
.chart-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1rem 0;
}

.donut-wrap { position: relative; }
.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-pct {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}
.donut-pct-label { font-size: 10px; color: var(--muted); }

.legend { display: flex; flex-direction: column; gap: 12px; }
.legend-item { display: flex; align-items: center; gap: 10px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-text { font-size: 13px; color: var(--text); }
.legend-text strong { font-weight: 600; }

/* TABLE */
.table-section { margin-top: 1.5rem; }
.table-section h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--primary);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--primary);
  color: rgba(255,255,255,0.85);
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table th:first-child { border-radius: 8px 0 0 8px; }
.data-table th:last-child { border-radius: 0 8px 8px 0; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: #f8fafc; }
.data-table tr:hover td { background: #eef2f7; }
.table-scroll { max-height: 260px; overflow-y: auto; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }

/* AD SLOTS */
.ad-slot {
  background: var(--card-alt);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  margin: 1.5rem 0;
  letter-spacing: 0.03em;
}

.ad-slot-banner { height: 90px; }
.ad-slot-rect { height: 250px; max-width: 336px; margin: 0 auto; }

/* CALC BUTTON */
.calc-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  letter-spacing: 0.03em;
}
.calc-btn:hover { background: #0f2540; transform: translateY(-1px); }

/* FOOTER */
footer {
  background: var(--nav-bg);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 2rem;
  font-size: 13px;
  margin-top: 4rem;
}
footer a { color: var(--accent); text-decoration: none; }
footer strong { color: rgba(255,255,255,0.9); }

/* RELATED TOOLS */
.related-section { margin-top: 2rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 1rem; }
.related-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.related-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.related-card .icon { font-size: 1.4rem; }

/* MOBILE */
@media (max-width: 640px) {
  nav { padding: 0 1rem; }
  .nav-links { display: none; }
  .hamburger { display: block; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .input-row-2 { grid-template-columns: 1fr; }
  .hero { padding: 2.5rem 1rem 3rem; }
  .calc-card { padding: 1.25rem; }
}

/* CONTENT PAGES (About, Privacy, etc & guides) */
.content-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}
.content-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.8rem 0 0.8rem;
}
.content-card h2:first-child { margin-top: 0; }
.content-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.4rem 0 0.6rem;
}
.content-card p { color: var(--text); margin-bottom: 1rem; font-size: 1rem; }
.content-card ul, .content-card ol { margin: 0 0 1rem 1.5rem; color: var(--text); }
.content-card li { margin-bottom: 0.5rem; line-height: 1.7; }
.content-card a { color: var(--primary); }
.content-card strong { font-weight: 600; color: var(--primary); }

/* FAQ */
.faq-item {
  border-bottom: 1.5px solid var(--border);
  padding: 1.2rem 0;
}
.faq-item:last-child { border-bottom: none; }
.faq-q {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}
.faq-a { color: var(--muted); line-height: 1.7; }

/* GUIDE SECTION on calc pages */
.guide-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 2rem;
  margin-top: 1.5rem;
  line-height: 1.8;
}
.guide-section h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.5rem 0 0.7rem;
}
.guide-section h2:first-child { margin-top: 0; }
.guide-section p { color: var(--text); margin-bottom: 1rem; }
.guide-section ul { margin: 0 0 1rem 1.5rem; color: var(--text); }
.guide-section li { margin-bottom: 0.5rem; }
.guide-section .formula {
  background: #f8fafc;
  border-left: 4px solid var(--accent);
  border-radius: 0;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
}

/* BLOG */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.blog-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}
.blog-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(26,58,92,0.12); border-color: var(--accent); }
.blog-card-img { height: 140px; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.blog-card-body { padding: 1.25rem; }
.blog-card-body h3 { font-family: 'Syne', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; }
.blog-card-body p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }
.blog-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.75rem; }

footer { line-height: 2; }
.footer-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.footer-links a { color: rgba(255,255,255,0.7); text-decoration: none; font-size: 13px; }
.footer-links a:hover { color: var(--accent); }

/* ===== HIGH-TECH UPGRADES ===== */

/* Theme toggle button */
.theme-toggle {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.25s ease;
  margin-left: 8px;
}
.theme-toggle:hover { background: rgba(255,255,255,0.22); transform: scale(1.08); }

.nav-right { display: flex; align-items: center; }

/* Select dark mode fix */
select {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Smooth fade-in animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.calc-page > * { animation: fadeUp 0.5s ease backwards; }
.calc-page > *:nth-child(1) { animation-delay: 0.05s; }
.calc-page > *:nth-child(2) { animation-delay: 0.1s; }
.calc-page > *:nth-child(3) { animation-delay: 0.15s; }
.calc-page > *:nth-child(4) { animation-delay: 0.2s; }
.calc-page > *:nth-child(5) { animation-delay: 0.25s; }

.hero h1 { animation: fadeUp 0.7s ease; }
.hero p { animation: fadeUp 0.7s ease 0.15s backwards; }

.tool-card { animation: scaleIn 0.5s ease backwards; }
.tool-grid .tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-grid .tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-grid .tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-grid .tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-grid .tool-card:nth-child(5) { animation-delay: 0.25s; }
.tool-grid .tool-card:nth-child(6) { animation-delay: 0.3s; }

/* Result value count-up pulse */
.result-value { transition: transform 0.2s ease; }
.result-card.highlight .result-value { animation: pulse 0.4s ease; }
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Action buttons (PDF/Share) */
.action-row { display: flex; gap: 12px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.action-btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.action-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.action-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.action-btn.primary:hover { background: var(--primary-light); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Install PWA button */
.install-banner {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: 300px;
  animation: fadeUp 0.4s ease;
}
.install-banner.show { display: block; }
.install-banner p { font-size: 0.85rem; color: var(--text); margin-bottom: 10px; }
.install-banner-btns { display: flex; gap: 8px; }
.install-banner button {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', sans-serif;
}
.install-yes { background: var(--accent); color: #1a2535; flex: 1; }
.install-no { background: transparent; color: var(--muted); border: 1.5px solid var(--border) !important; }

/* Tool card hover icon bounce */
.tool-card:hover .tool-icon { animation: bounce 0.5s ease; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Card entrance for calc cards */
.calc-card { animation: fadeUp 0.5s ease backwards; }

/* Better range slider */
input[type=range] {
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--card);
}

/* Glow effect on focus */
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,160,32,0.15);
}

/* PRINT / PDF STYLES */
@media print {
  nav, footer, .ad-slot, .action-row, .install-banner, .related-section, .theme-toggle, .nav-right { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .calc-page { padding: 0; }
  .calc-card, .result-card, .content-card, .guide-section { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .page-header h1 { color: #000 !important; }
  [data-theme="dark"] { --bg: #fff; --card: #fff; --text: #000; }
}
