:root {
  --navy: #1f3a5f;
  --navy-2: #16273f;
  --gold: #c8a24b;
  --gold-dark: #a8842f;
  --ink: #1c2430;
  --muted: #5b6673;
  --line: #e3e8ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ok: #10714f;
  --ok-bg: #e7f6ef;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --err: #9a2233;
  --err-bg: #fdecef;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(20, 39, 63, .07), 0 12px 32px rgba(20, 39, 63, .06);
  --maxw: 900px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand .mark { width: 30px; height: 30px; flex: 0 0 auto; }
.brand small { display: block; font-weight: 400; font-size: .72rem; color: #b9c6d8; letter-spacing: .3px; }
.header-nav a { color: #d7e0ec; text-decoration: none; font-size: .92rem; margin-inline-start: 18px; }
.lang-switch, .tool-switch { border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.tool-switch { border-color: rgba(200,162,75,.55); color: var(--gold) !important; }
.header-nav a:hover { color: #fff; }

/* Hero */
.hero { background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%); color: #fff; padding: 8px 0 40px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 12px 0 8px; line-height: 1.2; }
.hero p.lead { font-size: 1.08rem; color: #d7e0ec; max-width: 640px; margin: 0 0 16px; }
.badge { display: inline-block; background: rgba(200,162,75,.16); color: var(--gold); border: 1px solid rgba(200,162,75,.4); padding: 4px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; }

/* Card / calculator */
.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-top: -28px;
  position: relative;
}
section { padding: 40px 0; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); color: var(--navy); margin: 0 0 6px; }
.section-intro { color: var(--muted); margin: 0 0 22px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .94rem; }
.help { color: var(--muted); font-size: .82rem; font-weight: 400; }
input, select {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

#contractTypeRow, #noticeRow { display: none; }
#contractTypeRow.relevant, #noticeRow.relevant { display: flex; }

.actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 10px;
  padding: 12px 22px; transition: transform .04s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #241c00; }
.btn-primary:hover { background: var(--gold-dark); color: #fff; }
.btn-ghost { background: #eef1f6; color: var(--navy); }
.btn-ghost:hover { background: #e2e7ef; }

/* Result */
#result { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 22px; }
.result-title { margin: 0 0 8px; color: var(--navy); }
.result-amount { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 800; color: var(--ok); letter-spacing: -.5px; }
.result-amount.zero { color: var(--muted); }
.result-sub { margin: 2px 0 18px; color: var(--muted); }
.result-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.result-table th, .result-table td { text-align: start; padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.result-table th { color: var(--muted); font-weight: 600; width: 46%; }
.result-table td { color: var(--ink); }
.result-table tr.row-total th, .result-table tr.row-total td { border-top: 2px solid var(--navy); border-bottom: 0; font-size: 1.02rem; color: var(--navy); }
.callout { background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: 10px; padding: 14px 16px; margin-top: 18px; font-size: .94rem; }
.flag { color: var(--warn); font-weight: 600; }
.result-basis { background: var(--ok-bg); border-left: 4px solid var(--ok); border-left: none; border-inline-start: 4px solid var(--ok); padding: 12px 14px; border-radius: 8px; font-size: .94rem; }
.result-warn { background: var(--warn-bg); border-left: 4px solid var(--gold-dark); border-left: none; border-inline-start: 4px solid var(--gold-dark); color: var(--warn); padding: 12px 14px; border-radius: 8px; margin-top: 12px; font-size: .92rem; }
.result-note { color: var(--muted); font-size: .84rem; margin-top: 14px; }
.result-error { background: var(--err-bg); border-left: 4px solid var(--err); border-left: none; border-inline-start: 4px solid var(--err); color: var(--err); padding: 12px 16px; border-radius: 8px; }
.result-error ul { margin: 8px 0 0; padding-inline-start: 18px; }

/* Explanatory content */
.prose { max-width: 760px; }
.prose p { margin: 0 0 14px; }
.formula-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: .95rem; }
.formula-table th, .formula-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: start; }
.formula-table thead th { background: var(--navy); color: #fff; font-weight: 600; }
.formula-table tbody tr:last-child td { border-bottom: 0; }
.formula-table caption { caption-side: bottom; color: var(--muted); font-size: .82rem; padding-top: 10px; text-align: start; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.mini { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px; }
.mini h3 { margin: 0 0 6px; color: var(--navy); font-size: 1.05rem; }
.mini p { margin: 0; color: var(--muted); font-size: .92rem; }
.mini .num { font-weight: 800; color: var(--gold-dark); }

/* FAQ */
details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px; margin-bottom: 10px; }
details[open] { border-color: var(--gold); }
summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; color: var(--navy); }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; float: right; float: inline-end; color: var(--gold-dark); font-weight: 700; font-size: 1.2rem; }
details[open] summary::after { content: "–"; }
details p { margin: 0 0 14px; color: var(--ink); }

/* Legal */
.legal { background: #eef1f6; border-radius: var(--radius); padding: 22px 24px; }
.legal h2 { margin-top: 0; }
.disclaimer { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 14px 16px; color: var(--muted); font-size: .88rem; }

/* Ads — reserved height avoids layout shift (CLS); label keeps
   a clear boundary between ads and content per AdSense policy. */
.ad-box {
  margin: 26px auto 0;
  min-height: 120px;
  background: #eef1f6;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px 10px;
  text-align: center;
}
.ad-label {
  display: block;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9aa6b4;
  margin-bottom: 6px;
}
.ad-box .adsbygoogle { min-height: 90px; }

/* Sticky mobile anchor ad — full-width bar fixed to the bottom of the
   viewport, mobile only. The dismiss tab sits above the bar (never over
   the ad itself), and body.has-sticky-ad pads the page so no content is
   ever hidden behind the bar (Better Ads / AdSense sticky-ad rules). */
.sticky-ad {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(20, 39, 63, .14);
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding: 5px 0 calc(5px + env(safe-area-inset-bottom, 0px));
}
.sticky-ad .adsbygoogle { display: block; width: 100%; height: 50px; }
.sticky-ad-close {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 24px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #fff;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 -3px 10px rgba(20, 39, 63, .10);
}
@media (max-width: 640px) {
  .sticky-ad { display: block; }
  body.has-sticky-ad { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* Scrollable tables on narrow screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .formula-table { min-width: 560px; }

/* Footer */
.site-footer { background: var(--navy-2); color: #b9c6d8; padding: 28px 0; font-size: .88rem; margin-top: 20px; }
.site-footer a { color: #d7e0ec; }
.site-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .cards { grid-template-columns: 1fr; }
  /* On mobile, keep only the tool + language switcher pills in the header */
  .header-nav a:not(.lang-switch):not(.tool-switch) { display: none; }
  .site-header .container { flex-wrap: wrap; row-gap: 8px; }
  .lang-switch, .tool-switch { padding: 9px 14px; display: inline-block; }
  .result-table th { width: 52%; }

  section { padding: 30px 0; }
  .container { padding: 0 14px; }
  .calc-card { padding: 20px 16px; margin-top: -20px; }
  .hero { padding-bottom: 34px; }

  /* Comfortable touch targets (44px+) and no iOS input zoom (16px font) */
  input, select { padding: 13px 12px; font-size: 16px; min-height: 48px; }
  .btn { width: 100%; padding: 15px 22px; min-height: 50px; font-size: 1.02rem; }
  .actions { gap: 10px; }

  .result-amount { font-size: 2.1rem; }
  .result-table { font-size: .92rem; }
  details { padding: 2px 14px; }
  summary { padding: 13px 0; }
}
