/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface2: #f0f1f6;
  --border: #e2e5ef;
  --text: #1a1d2e;
  --text2: #5a6075;
  --text3: #9198b0;
  --accent: #5b7fff;
  --accent2: #4a6cf7;
  --blue: #5b7fff;
  --purple: #8b5cf6;
  --green: #22c55e;
  --coral: #f97316;
  --amber: #f59e0b;
  --teal: #14b8a6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 20px rgba(91,127,255,0.07);
  --shadow-lg: 0 8px 40px rgba(91,127,255,0.13);
  --transition: all 0.18s ease;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface2: #22263a;
  --border: #2e3250;
  --text: #e8eaf5;
  --text2: #8e94b0;
  --text3: #5a6075;
  --shadow: 0 2px 20px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #5b7fff 0%, #8b5cf6 100%);
  box-shadow: 0 2px 20px rgba(91,127,255,0.25);
}
.header .container {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 2rem;
  max-width: 1100px; margin: auto;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px);
}
.logo-icon.small { width: 26px; height: 26px; border-radius: 7px; }
.logo-text { color: white; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.3px; }
.nav { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav-link {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.85rem; font-weight: 500;
  padding: 6px 14px; border-radius: 50px;
  transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.2);
  color: white;
}
.theme-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white; border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
  flex-shrink: 0;
}
.theme-btn:hover { background: rgba(255,255,255,0.25); }

/* ===== CONTAINER ===== */
.container { max-width: 1100px; margin: auto; padding: 0 2rem; }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, #5b7fff 0%, #8b5cf6 100%);
  color: white; text-align: center;
  padding: 3.5rem 2rem 4rem;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: white; font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 5px 16px; border-radius: 50px;
  margin-bottom: 1.2rem;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800; line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -1px;
}
.gradient-text {
  background: linear-gradient(to right, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { font-size: 1.05rem; color: rgba(255,255,255,0.8); max-width: 500px; margin: auto; line-height: 1.7; }

/* ===== MAIN LAYOUT ===== */
.main { padding: 3rem 2rem; }

.calc-section { display: none; }
.calc-section.active { display: block; animation: fadeUp 0.35s ease; }

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

/* ===== CALC CARD ===== */
.calc-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  max-width: 440px;
  margin: auto;
  transition: background 0.3s, border-color 0.3s;
}
.calc-card.wide { max-width: 680px; }

.calc-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.calc-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.calc-icon.blue { background: #eff3ff; color: var(--blue); }
.calc-icon.purple { background: #f3f0ff; color: var(--purple); }
.calc-icon.green { background: #f0fdf4; color: var(--green); }
.calc-icon.coral { background: #fff7ed; color: var(--coral); }
.calc-icon.amber { background: #fffbeb; color: var(--amber); }
.calc-icon.teal { background: #f0fdfa; color: var(--teal); }
[data-theme="dark"] .calc-icon.blue   { background: #1a2040; color: #7ba5ff; }
[data-theme="dark"] .calc-icon.purple { background: #1e1838; color: #a78bfa; }
[data-theme="dark"] .calc-icon.green  { background: #0e2218; color: #4ade80; }
[data-theme="dark"] .calc-icon.coral  { background: #2a1500; color: #fb923c; }
[data-theme="dark"] .calc-icon.amber  { background: #211500; color: #fbbf24; }
[data-theme="dark"] .calc-icon.teal   { background: #002a28; color: #2dd4bf; }

.calc-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.calc-desc  { font-size: 0.82rem; color: var(--text3); margin-top: 2px; }

/* ===== DISPLAY ===== */
.display-wrap {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  text-align: right;
  min-height: 80px;
  display: flex; flex-direction: column; justify-content: flex-end;
  border: 1px solid var(--border);
}
.display-expr { font-size: 0.82rem; color: var(--text3); min-height: 1.2em; }
.display-val {
  font-size: 2.4rem; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -1px;
}

/* ===== KEYPAD ===== */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.sci-keypad {
  grid-template-columns: repeat(5, 1fr);
}

.btn {
  border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 1.05rem; font-weight: 600;
  padding: 0; height: 62px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  user-select: none;
  font-family: inherit;
}
.btn:active { transform: scale(0.94); }

.btn-num {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-num:hover { background: var(--border); }

.btn-fn {
  background: #e8ecff;
  color: #5b7fff;
  border: 1px solid #d0d8ff;
}
.btn-fn:hover { background: #d0d8ff; }
[data-theme="dark"] .btn-fn { background: #1e2548; color: #7ba5ff; border-color: #2e3a6e; }
[data-theme="dark"] .btn-fn:hover { background: #2e3a6e; }

.btn-op {
  background: #f3f0ff;
  color: var(--purple);
  border: 1px solid #e0d9ff;
  font-size: 1.25rem;
}
.btn-op:hover { background: #e0d9ff; }
[data-theme="dark"] .btn-op { background: #1e1838; color: #a78bfa; border-color: #2e2458; }
[data-theme="dark"] .btn-op:hover { background: #2e2458; }

.btn-eq {
  background: linear-gradient(135deg, #5b7fff, #8b5cf6);
  color: white; font-size: 1.35rem;
  box-shadow: 0 4px 14px rgba(91,127,255,0.4);
}
.btn-eq:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(91,127,255,0.5); }

.btn-wide { grid-column: span 2; }

.btn-sci {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  font-size: 0.88rem; font-weight: 600;
  height: 50px;
}
.btn-sci:hover { background: var(--border); color: var(--text); }

/* ===== SCI MODE ===== */
.sci-mode { display: flex; gap: 8px; margin-bottom: 0.75rem; }
.mode-btn {
  padding: 4px 14px; border-radius: 50px; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text3); cursor: pointer; transition: var(--transition);
}
.mode-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ===== HISTORY ===== */
.history-wrap {
  margin-top: 1rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  max-height: 140px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.history-item {
  font-size: 0.8rem; color: var(--text3);
  text-align: right; padding: 4px 6px;
  border-radius: 6px; cursor: pointer; transition: var(--transition);
}
.history-item:hover { background: var(--surface2); color: var(--text); }

/* ===== PERCENTAGE CALCULATOR ===== */
.pct-tabs {
  display: flex; gap: 4px; margin-bottom: 1.5rem;
  background: var(--surface2); padding: 4px; border-radius: var(--radius-sm);
}
.tab {
  flex: 1; padding: 8px 4px; border: none; background: transparent;
  font-size: 0.8rem; font-weight: 600; color: var(--text2);
  border-radius: 8px; cursor: pointer; transition: var(--transition);
  font-family: inherit;
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,0.08); }

.pct-panel { display: none; }
.pct-panel.active { display: block; }

.field-label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.95rem; font-weight: 500; color: var(--text2);
  margin-bottom: 1rem; line-height: 2.2;
}
.field-input {
  width: 90px; padding: 8px 10px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  background: var(--surface2); text-align: center;
  outline: none; font-family: inherit; transition: var(--transition);
}
.field-input:focus { border-color: var(--accent); background: var(--surface); }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.82rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.form-field input, .form-field select {
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 1rem; outline: none; font-family: inherit;
  transition: var(--transition);
}
.form-field input:focus, .form-field select:focus { border-color: var(--accent); background: var(--surface); }

/* ===== UNIT TOGGLE ===== */
.unit-toggle { display: flex; gap: 8px; margin-bottom: 1.25rem; }
.unit-btn {
  padding: 8px 16px; border-radius: 50px; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text2);
  font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: var(--transition);
  font-family: inherit;
}
.unit-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.hidden { display: none !important; }

/* ===== CALC BUTTON ===== */
.calc-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #5b7fff, #8b5cf6);
  color: white; border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: var(--transition);
  box-shadow: 0 4px 14px rgba(91,127,255,0.35);
  margin-bottom: 1.25rem;
}
.calc-btn:hover { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(91,127,255,0.45); }
.calc-btn:active { transform: scale(0.98); }

/* ===== RESULT BOX ===== */
.result-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
  display: none;
}
.result-box.show { display: block; animation: fadeUp 0.25s ease; }
.result-label { font-size: 0.82rem; color: var(--text3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.result-value { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
.result-sub { font-size: 0.85rem; color: var(--text2); margin-top: 6px; }

/* ===== BMI SCALE ===== */
.bmi-scale { margin-top: 1.5rem; }
.scale-bar { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: var(--radius-sm); overflow: hidden; }
.scale-seg {
  padding: 10px 6px; text-align: center;
  font-size: 0.72rem; font-weight: 600; line-height: 1.4;
}
.scale-seg.underweight { background: #bfdbfe; color: #1e40af; }
.scale-seg.normal { background: #bbf7d0; color: #15803d; }
.scale-seg.overweight { background: #fde68a; color: #92400e; }
.scale-seg.obese { background: #fecaca; color: #991b1b; }

/* ===== AGE RESULT ===== */
.age-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 1.25rem;
}
.age-card {
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 1rem; text-align: center;
}
.age-num { font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.age-lbl { font-size: 0.78rem; color: var(--text3); margin-top: 2px; }
.age-extra { margin-top: 1rem; font-size: 0.88rem; color: var(--text2); text-align: center; }

/* ===== CURRENCY ===== */
.currency-row {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.currency-row .form-field { flex: 1; min-width: 90px; }
.swap-btn {
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 50%; width: 40px; height: 40px; font-size: 1.2rem;
  cursor: pointer; color: var(--accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0; transition: var(--transition);
  align-self: flex-end; margin-bottom: 2px;
}
.swap-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.rate-note { font-size: 0.77rem; color: var(--text3); margin-top: 8px; }

/* ===== PINK ICON ===== */
.calc-icon.pink { background: #fdf2f8; color: #ec4899; }
.calc-icon.rose { background: #fff1f2; color: #f43f5e; }
[data-theme="dark"] .calc-icon.pink { background: #2d1028; color: #f472b6; }
[data-theme="dark"] .calc-icon.rose { background: #2d0a10; color: #fb7185; }

/* ===== THREE COLUMN FORM ===== */
.form-grid.three-col { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 680px) { .form-grid.three-col { grid-template-columns: 1fr 1fr; } }

/* ===== MORTGAGE RESULT ===== */
.mort-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 1.25rem;
}
.mort-card {
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 1rem; text-align: center;
}
.mort-num { font-size: 1.3rem; font-weight: 800; color: var(--accent); line-height: 1.2; }
.mort-lbl { font-size: 0.73rem; color: var(--text3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.mort-breakdown {
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 1.1rem; margin-bottom: 1rem;
}
.mort-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.mort-row:last-child { border-bottom: none; }
.mort-row-label { color: var(--text2); }
.mort-row-value { font-weight: 600; color: var(--text); }
.amort-toggle {
  font-size: 0.82rem; color: var(--accent); cursor: pointer;
  text-align: center; padding: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; transition: var(--transition);
  background: var(--surface2);
}
.amort-toggle:hover { background: var(--border); }
.amort-table-wrap { max-height: 220px; overflow-y: auto; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.amort-table th {
  background: var(--surface2); color: var(--text2); font-weight: 600;
  padding: 6px 8px; text-align: right; position: sticky; top: 0;
  border-bottom: 1px solid var(--border);
}
.amort-table th:first-child { text-align: left; }
.amort-table td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--border); color: var(--text2); }
.amort-table td:first-child { text-align: left; color: var(--text); font-weight: 500; }
.amort-table tr:hover td { background: var(--surface2); }

/* ===== PREGNANCY PANELS ===== */
.preg-panel { display: none; }
.preg-panel.active { display: block; }

.preg-timeline {
  margin-top: 1.25rem;
}
.trimester-bar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 1rem;
}
.trim-seg {
  padding: 10px 8px; text-align: center;
  font-size: 0.75rem; font-weight: 600; line-height: 1.4;
}
.trim-seg.t1 { background: #dbeafe; color: #1d4ed8; }
.trim-seg.t2 { background: #d1fae5; color: #065f46; }
.trim-seg.t3 { background: #fde8f8; color: #86198f; }
.trim-seg.active-trim { outline: 3px solid var(--accent); outline-offset: -3px; }

.preg-dates {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 1.1rem; margin-bottom: 1rem;
}
.preg-date-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.88rem;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.preg-date-row:last-child { border-bottom: none; }
.preg-date-label { color: var(--text2); }
.preg-date-val { font-weight: 600; color: var(--text); }
.preg-highlight { color: var(--accent) !important; font-size: 1rem !important; }

.week-badge {
  text-align: center; padding: 1rem;
  background: linear-gradient(135deg, #ec4899, #f97316);
  border-radius: var(--radius-sm); color: white; margin-bottom: 1rem;
}
.week-badge-num { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.week-badge-lbl { font-size: 0.85rem; opacity: 0.9; margin-top: 2px; }
.week-badge-sub { font-size: 0.78rem; opacity: 0.75; margin-top: 4px; }

/* ===== OVULATION RESULT ===== */
.ov-summary {
  margin-top: 1.25rem;
}
.fertile-window {
  background: linear-gradient(135deg, #fdf2f8, #fff1f2);
  border: 1.5px solid #fbb6ce; border-radius: var(--radius-sm);
  padding: 1.1rem; text-align: center; margin-bottom: 1rem;
}
[data-theme="dark"] .fertile-window { background: linear-gradient(135deg, #2d1028, #2d0a10); border-color: #9d174d; }
.fertile-title { font-size: 0.78rem; color: #be185d; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.fertile-dates { font-size: 1.4rem; font-weight: 800; color: #ec4899; margin: 4px 0; }
.fertile-sub { font-size: 0.82rem; color: #9d174d; }

.ov-day-box {
  background: linear-gradient(135deg, #f43f5e, #ec4899);
  border-radius: var(--radius-sm); padding: 1rem; text-align: center;
  color: white; margin-bottom: 1rem;
}
.ov-day-num { font-size: 2rem; font-weight: 800; }
.ov-day-lbl { font-size: 0.85rem; opacity: 0.85; }

.ov-calendar {
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 1.1rem;
}
.ov-cal-title { font-size: 0.8rem; font-weight: 600; color: var(--text2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.ov-cycles { display: flex; flex-direction: column; gap: 6px; }
.ov-cycle-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.83rem; padding: 6px 8px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
}
.ov-cycle-label { color: var(--text2); font-weight: 500; }
.ov-cycle-val { font-weight: 600; }
.ov-cycle-row.peak .ov-cycle-val { color: #f43f5e; }
.ov-cycle-row.fertile .ov-cycle-val { color: #ec4899; }
.ov-cycle-row.period .ov-cycle-val { color: var(--blue); }
.ov-cycle-row.next .ov-cycle-val { color: var(--text3); }

/* ===== FOOTER ===== */
.footer {
  background: linear-gradient(135deg, #5b7fff 0%, #8b5cf6 100%);
  color: white; text-align: center; padding: 2rem;
  margin-top: 3rem;
}
.footer-logo { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 0.5rem; font-weight: 700; font-size: 1rem; }
.footer-copy { font-size: 0.8rem; opacity: 0.7; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 680px) {
  .header .container { padding: 0.6rem 1rem; }
  .nav { gap: 2px; }
  .nav-link { padding: 5px 9px; font-size: 0.78rem; }
  .hero { padding: 2rem 1rem 2.5rem; }
  .main { padding: 1.5rem 1rem; }
  .calc-card { padding: 1.25rem; }
  .calc-card.wide { max-width: 100%; }
  .sci-keypad { grid-template-columns: repeat(4, 1fr); }
  .btn-sci:nth-child(-n+10) { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .age-grid { grid-template-columns: repeat(3, 1fr); }
  .currency-row { flex-direction: column; }
  .swap-btn { width: 100%; border-radius: var(--radius-sm); height: 36px; }
}
