/* FinCtrl public pages (tools + guides) — shared styles */
:root {
  --bg: #0f0f1a;
  --bg-2: #15152a;
  --surface: #1b1b33;
  --surface-2: #232345;
  --text: #f4f4fb;
  --text-2: #c9c9e0;
  --muted: #8f8fb8;
  --border: #2d2d4a;
  --primary: #7c3aed;
  --primary-2: #3b82f6;
  --primary-soft: rgba(124, 58, 237, 0.16);
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f6ff;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #f1effe;
    --text: #1e1b4b;
    --text-2: #3f3d63;
    --muted: #6b6b8a;
    --border: #e3e1f3;
    --primary-soft: rgba(124, 58, 237, 0.09);
    --shadow: 0 8px 24px rgba(30, 27, 75, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--primary-2); }

img { max-width: 100%; height: auto; }

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
}

.brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 10px;
  border-radius: 8px;
}

.site-nav a:hover { color: var(--text); background: var(--surface-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.btn:hover { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.site-nav .btn { padding: 8px 14px; color: #fff; }

@media (max-width: 560px) {
  .site-nav a.hide-sm { display: none; }
}

/* ===== Page ===== */
main { padding: 32px 0 48px; }

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.breadcrumb a { color: var(--muted); }

h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.35rem;
  margin: 36px 0 10px;
  letter-spacing: -0.01em;
}

h3 { font-size: 1.05rem; margin: 18px 0 6px; }

.lead {
  color: var(--text-2);
  font-size: 1.05rem;
  max-width: 720px;
  margin: 0 0 24px;
}

.prose { max-width: 760px; color: var(--text-2); }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }

/* ===== Calculator ===== */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 820px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 18px; }

.field label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.field label .hint { color: var(--muted); font-weight: 400; }

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
}

.input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-row .affix { color: var(--muted); font-weight: 600; }

.input-row input, .input-row select {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  padding: 11px 0;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--primary);
}

.results .big {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 14px;
}

.results .label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-rows { display: grid; gap: 10px; margin-top: 8px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.stat-row span:first-child { color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.stat-row span:last-child { font-weight: 700; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.c1 { background: var(--primary); }
.dot.c2 { background: var(--primary-2); }
.dot.c3 { background: var(--good); }

.bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  gap: 2px;
  margin: 4px 0 6px;
}

.bar > span { display: block; height: 100%; transition: width 0.25s ease; }
.bar .c1 { background: var(--primary); }
.bar .c2 { background: var(--primary-2); }
.bar .c3 { background: var(--good); }

.note { font-size: 0.85rem; color: var(--muted); margin-top: 12px; }

/* tables */
.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

/* people list (split bill) */
.person {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 40px;
  gap: 8px;
  margin-bottom: 8px;
}

.person .input-row input { font-size: 1rem; padding: 9px 0; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
}

.icon-btn:hover { color: var(--bad); border-color: var(--bad); }

.settle { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }

.settle li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}

.settle li b { font-variant-numeric: tabular-nums; }

/* ===== CTA + cards ===== */
.cta {
  margin-top: 36px;
  border-radius: var(--radius);
  padding: 24px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(124, 58, 237, 0.35), transparent 60%),
    radial-gradient(120% 140% at 100% 100%, rgba(59, 130, 246, 0.3), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cta h2 { margin: 0 0 4px; }
.cta p { margin: 0; color: var(--text-2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}

.tool-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tool-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.tool-card .emoji { font-size: 1.6rem; }
.tool-card h3 { margin: 10px 0 4px; }
.tool-card p { margin: 0; color: var(--text-2); font-size: 0.95rem; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.faq summary { cursor: pointer; font-weight: 600; color: var(--text); }
.faq details p { margin: 10px 0 0; }

.disclaimer {
  margin-top: 28px;
  font-size: 0.85rem;
  color: var(--muted);
  border-left: 3px solid var(--border);
  padding-left: 12px;
}

/* Ad slot spacing (auto ads place themselves; this keeps manual slots tidy) */
.ad-slot { margin: 28px 0; min-height: 0; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ===== Share row under calculators ===== */
.share-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 4px;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.share-label { color: var(--text-2); font-weight: 500; margin-right: auto; }
.share-row .btn { padding: 9px 16px; }
.share-wa { background: #25d366; }
.share-wa:hover { filter: brightness(1.05); }
.share-status { flex-basis: 100%; font-size: 0.85rem; color: var(--muted); }
.share-status:empty { display: none; }

/* Income tax calculator: old vs new side by side */
.regime-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.regime-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-2);
  position: relative;
}
.regime-card.winner { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.regime-card.winner::after {
  content: "Lower tax";
  position: absolute; top: -10px; right: 10px;
  background: var(--good); color: #fff;
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.regime-name { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.regime-tax { font-size: 1.5rem; font-weight: 800; margin: 4px 0; font-variant-numeric: tabular-nums; }
.regime-sub { color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
@media (max-width: 380px) { .regime-compare { grid-template-columns: 1fr; } }
.field label.check-row { display: flex; justify-content: flex-start; align-items: center; gap: 8px; margin: 10px 0 0; font-weight: 500; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }

/* "Get it on Google Play" button (shown only when PLAY_STORE_LIVE is on in shared/open-app.js) */
.play-badge { display: inline-flex; align-items: center; gap: 10px; padding: 8px 18px 8px 14px; border-radius: 10px;
  background: #000; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.28); line-height: 1.1;
  transition: transform .15s, box-shadow .15s; }
.play-badge:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.35); color: #fff; }
.play-badge svg { width: 24px; height: 24px; color: #34d399; flex: none; }
.play-badge small { display: block; font-size: 10px; letter-spacing: .08em; opacity: .85; }
.play-badge strong { display: block; font-size: 17px; font-weight: 600; }
.app-promo { margin: 8px 0 0; padding: 22px 0; background: linear-gradient(135deg, rgba(124,58,237,.14), rgba(59,130,246,.10));
  border-top: 1px solid rgba(124,58,237,.25); }
.app-promo-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.app-promo-logo { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 800; font-size: 18px; background: linear-gradient(135deg, #7c3aed, #3b82f6); }
.app-promo-text { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.app-promo-text strong { font-size: 1.05rem; }
.app-promo-text span { font-size: .9rem; opacity: .8; }

/* Author / updated line on guides */
.byline { margin: -6px 0 22px; font-size: .9rem; color: var(--text-3, #94a3b8); }
.byline a { color: inherit; text-decoration: underline; }
.takeaways { margin: 18px 0 26px; padding: 18px 22px; border-radius: 16px; background: rgba(124,58,237,.10); border: 1px solid rgba(167,139,250,.28); }
.takeaways h2 { margin-top: 0 !important; font-size: 1.1rem; }
.takeaways ul { margin: 0; }
