/* Calculator Euphoria — shared design system */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --text: #1c1f2e;
  --text-muted: #656b7d;
  --border: #e3e5ef;
  --primary: #4338ca;
  --primary-dark: #362d9e;
  --primary-light: #edecfb;
  --accent: #0d9488;
  --accent-light: #e3f6f3;
  --danger: #dc2626;
  --success: #0d9488;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 31, 46, 0.04), 0 8px 24px -12px rgba(28, 31, 46, 0.12);
  --shadow-lg: 0 4px 8px rgba(28, 31, 46, 0.04), 0 16px 40px -16px rgba(28, 31, 46, 0.18);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a24;
  --surface-2: #1e222f;
  --text: #e7e8f2;
  --text-muted: #9aa0b4;
  --border: #2a2e3d;
  --primary: #8b81f2;
  --primary-dark: #a49bff;
  --primary-light: #23204a;
  --accent: #2dd4bf;
  --accent-light: #123531;
  --danger: #f87171;
  --success: #2dd4bf;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.25), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #171a24;
    --surface-2: #1e222f;
    --text: #e7e8f2;
    --text-muted: #9aa0b4;
    --border: #2a2e3d;
    --primary: #8b81f2;
    --primary-dark: #a49bff;
    --primary-light: #23204a;
    --accent: #2dd4bf;
    --accent-light: #123531;
    --danger: #f87171;
    --success: #2dd4bf;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.25), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
[id] { scroll-margin-top: 84px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background 0.15s ease, color 0.15s ease;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.wrap-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

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

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }

code, .num, .result-value, input[type="number"], input[type="text"].numeric {
  font-variant-numeric: tabular-nums;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  color: var(--text) !important;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .brand-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.brand .brand-icon svg { width: 17px; height: 17px; }
.brand .accent { color: var(--primary); }

.site-header nav {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}
.site-header nav a {
  color: var(--text-muted) !important;
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}
.site-header nav a:hover, .site-header nav a.active {
  background: var(--surface-2);
  color: var(--text) !important;
  text-decoration: none;
}

.header-spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .icon-moon { display: none; }
[data-theme="dark"] .icon-btn .icon-sun { display: none; }
[data-theme="dark"] .icon-btn .icon-moon { display: block; }

.nav-toggle { display: none; }

@media (max-width: 780px) {
  .site-header nav {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px 16px;
    gap: 2px;
    box-shadow: var(--shadow-lg);
  }
  .site-header nav.mobile-open { display: flex; }
  .site-header nav a { padding: 11px 12px; }
  .nav-toggle {
    display: flex;
  }
}

/* ---------- Hero / search ---------- */

.hero {
  padding: 56px 0 36px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  margin: 0 0 12px;
}
.hero p.lead {
  color: var(--text-muted);
  font-size: 17px;
  max-width: 560px;
  margin: 0 auto 28px;
}

.search-box {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 15px 16px 15px 46px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.search-box input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.search-box .search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  text-align: left;
  overflow: hidden;
  display: none;
  z-index: 40;
}
.search-results.show { display: block; }
.search-results a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  color: var(--text) !important;
  font-size: 14.5px;
  font-weight: 600;
}
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.search-results .cat-tag {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.search-empty { padding: 14px 16px; color: var(--text-muted); font-size: 14px; }

/* ---------- Category pills ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 28px 0 8px;
}
.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.pill:hover { background: var(--surface-2); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Calculator grid ---------- */

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 32px 0 64px;
}
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text) !important;
}
.calc-card:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.calc-card .calc-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.calc-card .calc-icon svg { width: 21px; height: 21px; }
.calc-card h3 { margin: 0; font-size: 16.5px; }
.calc-card p { margin: 0; color: var(--text-muted); font-size: 14px; }
.calc-card .cat-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent);
}

.section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 12px;
}
.section-heading h2 { font-size: 20px; margin: 0; }
.section-heading span { color: var(--text-muted); font-size: 13.5px; }

/* ---------- Calculator page layout ---------- */

.calc-page-head {
  padding: 36px 0 8px;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.calc-page-head h1 { font-size: clamp(24px, 4vw, 32px); margin: 0 0 10px; }
.calc-page-head p.dek { color: var(--text-muted); font-size: 16px; max-width: 640px; }

.calc-app {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  margin: 24px 0 40px;
}
@media (max-width: 600px) { .calc-app { padding: 20px 16px; } }

.calc-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 760px) {
  .calc-layout { grid-template-columns: 1fr; }
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }

.input-group { position: relative; display: flex; }
.input-group input, .input-group select {
  width: 100%;
  padding: 12px 14px;
  font-size: 15.5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.input-group input:focus, .input-group select:focus,
select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.input-group .suffix, .input-group .prefix {
  display: flex; align-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
}
.input-group .prefix { border-right: none; border-radius: 10px 0 0 10px; }
.input-group .suffix { border-left: none; border-radius: 0 10px 10px 0; }
.input-group .prefix + input, .input-group .prefix + select { border-radius: 0 10px 10px 0; }
.input-group input:has(+ .suffix), .input-group select:has(+ .suffix) { border-radius: 10px 0 0 10px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 460px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary);
  color: #fff !important;
  border: none;
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text) !important;
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

.toggle-group { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.toggle-group button {
  flex: 1; padding: 10px; border: none; background: var(--surface-2); color: var(--text-muted);
  font-weight: 700; font-size: 13.5px; cursor: pointer; border-right: 1px solid var(--border);
}
.toggle-group button:last-child { border-right: none; }
.toggle-group button.active { background: var(--primary); color: #fff; }

/* Results panel */
.result-panel {
  background: linear-gradient(160deg, var(--primary-light), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  position: sticky;
  top: 84px;
}
.result-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.result-value {
  font-size: clamp(32px, 5vw, 42px);
  font-weight: 800;
  color: var(--primary);
  margin: 4px 0 4px;
  word-break: break-word;
}
.result-sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 18px; }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result-list li {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.result-list li:first-child { border-top: none; padding-top: 0; }
.result-list .k { color: var(--text-muted); }
.result-list .v { font-weight: 700; }
.result-list .v.good { color: var(--success); }
.result-list .v.bad { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--accent);
}

/* Data table (amortization / unit table) */
.table-wrap { overflow-x: auto; margin-top: 10px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); }
table.data-table th:first-child, table.data-table td:first-child { text-align: left; }
table.data-table th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

/* Article / content styling below calculators */
.calc-content { margin: 40px 0; }
.calc-content h2 { font-size: 21px; margin: 32px 0 12px; }
.calc-content h3 { font-size: 16.5px; margin: 20px 0 8px; }
.calc-content p, .calc-content li { color: var(--text-muted); font-size: 15px; }
.calc-content .formula {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--text);
  overflow-x: auto;
  margin: 14px 0;
}

.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 16px 0; font-size: 15.5px; font-weight: 700; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-q .chev { transition: transform 0.15s ease; color: var(--text-muted); flex-shrink: 0; }
.faq-item.open .faq-q .chev { transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.2s ease; }
.faq-a p { margin: 0 0 16px; font-size: 14.5px; }
.faq-item.open .faq-a { max-height: 400px; }

.related-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 20px 0 50px;
}

.disclaimer {
  font-size: 12.5px; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-top: 20px;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 30px;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.site-footer .foot-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; margin-bottom: 28px;
}
@media (max-width: 700px) { .site-footer .foot-grid { grid-template-columns: 1fr 1fr; } }
.site-footer h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text); margin: 0 0 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.site-footer a { color: var(--text-muted) !important; }
.site-footer a:hover { color: var(--text) !important; }
.foot-bottom {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding-top: 20px; border-top: 1px solid var(--border);
}

.static-page { padding: 40px 0 70px; }
.static-page h1 { font-size: 30px; margin-bottom: 6px; }
.static-page .updated { color: var(--text-muted); font-size: 13px; margin-bottom: 30px; }
.static-page h2 { font-size: 19px; margin-top: 28px; }
.static-page p, .static-page li { color: var(--text-muted); font-size: 15px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 16px; top: 16px; }
