:root {
  color-scheme: light;
  --page: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --ink: #152421;
  --muted: #566761;
  --line: #cfdad6;
  --teal: #087f72;
  --teal-dark: #075e56;
  --teal-soft: #dff3ee;
  --coral: #c84d42;
  --coral-soft: #fff0ed;
  --gold: #b57b16;
  --navy: #17324d;
  --ok: #19703e;
  --warn: #8b5a05;
  --error: #a92720;
  --shadow: 0 10px 26px rgba(27, 54, 48, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--page); color: var(--ink); }
body, button, input { font: inherit; }
button, input, summary, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--teal-dark); }
button { letter-spacing: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 14px 0 28px; }
.topbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 5px; }
.brand-text { min-width: 0; }
.brand-name, .brand-sub { display: block; overflow-wrap: anywhere; }
.brand-name { font-size: 15px; font-weight: 800; line-height: 1.15; }
.brand-sub { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.2; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.nav-link { min-height: 38px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 12px; color: var(--navy); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.nav-link:hover { border-color: var(--teal); color: var(--teal-dark); }

.language-menu { position: relative; z-index: 40; }
.language-menu > summary { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); box-shadow: 0 3px 10px rgba(23, 50, 77, .08); cursor: pointer; list-style: none; }
.language-menu > summary::-webkit-details-marker { display: none; }
.language-menu[open] > summary { border-color: var(--teal); outline: 3px solid rgba(8, 127, 114, .12); }
.language-menu-list { position: absolute; top: 46px; right: 0; width: 54px; display: grid; grid-template-columns: 1fr; gap: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 16px 32px rgba(23, 50, 77, .16); padding: 6px; }
.language-menu-list a { width: 40px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 6px; text-decoration: none; }
.language-menu-list a:hover, .language-menu-list a[aria-current="true"] { border-color: #a8c9c1; background: var(--teal-soft); }
.flag-circle { position: relative; width: 26px; height: 26px; display: block; overflow: hidden; border: 1px solid rgba(21, 36, 33, .17); border-radius: 50%; box-shadow: 0 1px 2px rgba(21, 36, 33, .1); }
.flag-en { background: repeating-linear-gradient(to bottom, #b22234 0 2px, #fff 2px 4px); }
.flag-en::before { content: ""; position: absolute; left: 0; top: 0; width: 12px; height: 13px; background: #3c3b6e; }
.flag-de { background: linear-gradient(to bottom, #151515 0 33.33%, #d00000 33.33% 66.66%, #ffce00 66.66%); }
.flag-fr { background: linear-gradient(to right, #002395 0 33.33%, #fff 33.33% 66.66%, #ed2939 66.66%); }
.flag-es { background: linear-gradient(to bottom, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75%); }
.flag-zh { background: #de2910; }
.flag-zh::before { content: ""; position: absolute; left: 5px; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: #ffde00; }
.flag-ru { background: linear-gradient(to bottom, #fff 0 33.33%, #0039a6 33.33% 66.66%, #d52b1e 66.66%); }
.flag-bg { background: linear-gradient(to bottom, #fff 0 33.33%, #00966e 33.33% 66.66%, #d62612 66.66%); }

.tool-intro { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(360px, .96fr); min-height: 278px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.tool-intro > div { align-self: center; padding: 28px 30px; }
.tool-intro picture { min-width: 0; height: 100%; background: #dbe6e2; }
.tool-intro picture img { width: 100%; height: 100%; min-height: 278px; display: block; object-fit: cover; }
.eyebrow, .section-label { margin: 0 0 7px; color: var(--coral); font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, h4, p { overflow-wrap: anywhere; }
h1 { max-width: 720px; margin: 0; color: var(--navy); font-size: 34px; line-height: 1.08; letter-spacing: 0; }
.lead { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.trust { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.trust span { border-left: 3px solid var(--teal); background: var(--surface-soft); padding: 6px 8px; color: #314943; font-size: 12px; font-weight: 700; }
.legal-callout { margin: 12px 0; border: 1px solid #e9c6bf; border-left: 4px solid var(--coral); border-radius: 6px; background: var(--coral-soft); padding: 11px 13px; color: #6c2b27; font-size: 13px; line-height: 1.5; }

.workspace { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); padding: 20px; }
.workspace-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); align-items: end; gap: 24px; }
.workspace-heading h2, .content-section h2 { margin: 0; color: var(--navy); letter-spacing: 0; }
.workspace-heading h2 { font-size: 23px; line-height: 1.2; }
.workspace-heading > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.mode-switch { width: fit-content; display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 2px; margin: 18px 0 12px; border: 1px solid var(--line); border-radius: 7px; background: #e8efec; padding: 3px; }
button, .file-button span { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; padding: 0 13px; cursor: pointer; color: var(--ink); font-size: 13px; font-weight: 750; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(8, 127, 114, .25); outline-offset: 2px; }
.mode-switch button { min-width: 0; background: transparent; color: var(--muted); }
.mode-switch button[aria-pressed="true"] { border-color: #b9cfca; background: var(--surface); color: var(--teal-dark); box-shadow: 0 1px 4px rgba(23, 50, 77, .08); }
.calculator-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .75fr); gap: 12px; align-items: stretch; }
.trip-panel, .results-panel, .timeline-panel { border: 1px solid var(--line); border-radius: 7px; background: #fbfdfc; }
.trip-panel, .results-panel { padding: 15px; }
.control-row { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 10px; margin-bottom: 14px; }
label { min-width: 0; display: grid; gap: 5px; color: #334b45; font-size: 12px; font-weight: 750; }
input[type="date"], input[type="number"] { width: 100%; min-height: 40px; border: 1px solid #bfcfc9; border-radius: 6px; background: var(--surface); padding: 7px 9px; color: var(--ink); font-size: 14px; }
.trip-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid #e0e7e4; }
.trip-heading h3, .results-panel h3, .timeline-heading h3 { margin: 0; color: var(--navy); font-size: 17px; line-height: 1.25; }
.primary { background: var(--teal); color: #fff; }
.primary:hover { background: var(--teal-dark); }
.secondary, .file-button span { border-color: #c3d2cd; background: var(--surface); color: var(--navy); }
.secondary:hover, .file-button:hover span { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-soft); }
.trip-list { display: grid; gap: 7px; margin-top: 10px; }
.trip-row { display: grid; grid-template-columns: minmax(126px, 1fr) minmax(126px, 1fr) minmax(125px, auto) minmax(92px, auto) 40px; align-items: end; gap: 7px; border-bottom: 1px solid #dde6e2; padding: 0 0 9px; }
.ongoing-control { min-height: 40px; display: flex; align-items: center; gap: 7px; padding: 0 5px; white-space: normal; }
.ongoing-control input { width: 17px; height: 17px; flex: 0 0 17px; margin: 0; accent-color: var(--teal); }
.trip-duration { min-height: 40px; display: flex; align-items: center; color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.25; }
.remove-trip { width: 40px; min-width: 40px; padding: 0; border-color: #e4c5c1; background: var(--surface); color: var(--error); font-size: 22px; line-height: 1; }
.remove-trip:hover { background: var(--coral-soft); }
.action-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.file-button { display: block; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.issue-list { margin: 12px 0 0; padding: 0; list-style: none; }
.issue-list li { margin-top: 5px; border-left: 3px solid; padding: 6px 9px; font-size: 12px; line-height: 1.4; }
.issue-list .error { border-color: var(--error); background: var(--coral-soft); color: #74251f; }
.issue-list .warning { border-color: var(--gold); background: #fff7e5; color: #65430b; }
.status-box { min-height: 72px; margin: 9px 0 12px; display: flex; align-items: center; border: 1px solid #c8d5d0; border-left: 4px solid var(--teal); border-radius: 6px; background: var(--surface-soft); padding: 10px; color: #28443d; font-size: 13px; line-height: 1.45; }
.status-box[data-state="error"] { border-color: #e5bbb6; border-left-color: var(--error); background: var(--coral-soft); color: #74251f; }
.status-box[data-state="ok"] { border-left-color: var(--ok); }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.metric-grid > div { min-height: 90px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid #d9e2de; border-radius: 6px; background: var(--surface); padding: 10px; }
.metric-grid strong { color: var(--navy); font-size: 20px; line-height: 1.15; overflow-wrap: anywhere; }
.metric-grid span { color: var(--muted); font-size: 11px; line-height: 1.3; }
.window-summary { min-height: 36px; margin: 10px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.overstay-panel { border-top: 1px solid #e1e8e5; padding-top: 9px; }
.overstay-panel h4 { margin: 0; color: var(--error); font-size: 13px; }
.overstay-panel ul { margin: 7px 0 0; padding-left: 18px; color: #71322c; font-size: 12px; }
.copy-report { width: 100%; margin-top: 8px; }

.timeline-panel { margin-top: 12px; padding: 14px; }
.timeline-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 12px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; display: block; border: 1px solid #bdcbc6; border-radius: 2px; background: #e6ece9; }
.legend .historical { background: var(--navy); border-color: var(--navy); }
.legend .proposed { background: var(--teal); border-color: var(--teal); }
.legend .over { background: var(--coral); border-color: var(--coral); }
.legend .reference { outline: 2px solid var(--gold); outline-offset: 1px; }
.timeline { display: grid; grid-template-columns: repeat(30, minmax(6px, 1fr)); gap: 3px; margin-top: 11px; }
.timeline-day { min-width: 0; height: 12px; display: block; border: 1px solid #ced8d4; border-radius: 2px; background: #e7edeb; }
.timeline-day.historical { border-color: var(--navy); background: var(--navy); }
.timeline-day.proposed { border-color: var(--teal); background: var(--teal); }
.timeline-day.over { border-color: var(--coral); background: var(--coral); }
.timeline-day.reference { outline: 2px solid var(--gold); outline-offset: 1px; }
.timeline-panel > p { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.content-section { margin-top: 26px; }
.content-section > section { padding: 25px 4px; border-top: 1px solid var(--line); }
.content-section > section:first-child { border-top: 0; }
.content-section h2 { font-size: 23px; line-height: 1.22; }
.content-section p, .content-section li { color: #465b55; font-size: 15px; line-height: 1.68; }
.content-section p { max-width: 920px; margin: 10px 0 0; }
.content-section ul, .content-section ol { max-width: 980px; margin: 13px 0 0; padding-left: 23px; }
.content-section li + li { margin-top: 7px; }
.rule-section { border-left: 4px solid var(--teal); padding-left: 18px !important; background: #f0f7f4; }
.numbered-steps ol { counter-reset: steps; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; padding-left: 28px; }
.table-wrap { width: 100%; margin-top: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; min-width: 680px; border-collapse: collapse; color: #314943; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #dfe7e4; text-align: left; vertical-align: top; line-height: 1.45; }
thead th { background: var(--navy); color: #fff; font-size: 12px; }
tbody th { width: 24%; color: var(--navy); font-weight: 750; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.worked-example { display: grid; grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr); gap: 24px; align-items: start; }
.worked-example .table-wrap { margin-top: 0; }
.content-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr); gap: 28px; align-items: start; }
.content-split ul { margin-top: 0; }
.privacy-section { border-left: 4px solid var(--ok); padding-left: 18px !important; background: #eff8f2; }
.limitations-section { border-left: 4px solid var(--coral); padding-left: 18px !important; background: var(--coral-soft); }
.sources-section ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; padding: 0; list-style: none; }
.sources-section li { border-left: 3px solid var(--teal); padding: 5px 0 5px 10px; }
.sources-section a, .sources-section span { display: block; }
.sources-section a { font-weight: 750; }
.sources-section span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.faq-list { margin-top: 12px; border-top: 1px solid var(--line); }
.faq-list details { border-bottom: 1px solid var(--line); }
.faq-list summary { position: relative; min-height: 48px; display: flex; align-items: center; padding: 10px 36px 10px 0; color: var(--navy); font-size: 14px; font-weight: 750; cursor: pointer; list-style: none; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--teal); font-size: 23px; font-weight: 500; }
.faq-list details[open] summary::after { content: "−"; }
.faq-list details p { margin: 0; padding: 0 38px 13px 0; font-size: 14px; }
.footer { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 17px 3px 0; color: var(--muted); font-size: 12px; }
.footer p { margin: 0; }
.footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px 14px; }
.footer a, .privacy-settings { min-height: 28px; display: inline-flex; align-items: center; border: 0; background: transparent; padding: 0; color: var(--navy); font-size: 12px; font-weight: 650; text-decoration: none; }
.privacy-settings:hover, .footer a:hover { color: var(--teal); text-decoration: underline; }

@media (max-width: 980px) {
  .tool-intro { grid-template-columns: 1fr; }
  .tool-intro > div { padding: 23px; }
  .tool-intro picture { max-height: 250px; }
  .tool-intro picture img { min-height: 220px; }
  h1 { font-size: 30px; }
  .calculator-grid { grid-template-columns: 1fr; }
  .trip-row { grid-template-columns: repeat(2, minmax(130px, 1fr)) minmax(130px, .8fr) 1fr 40px; }
  .worked-example, .content-split { grid-template-columns: 1fr; }
  .worked-example .table-wrap { margin-top: 0; }
}

@media (max-width: 720px) {
  .page { width: min(100% - 18px, 1180px); padding-top: 8px; }
  .brand-sub { display: none; }
  .nav-link { max-width: 142px; white-space: normal; text-align: center; line-height: 1.15; }
  .tool-intro > div { padding: 19px 16px; }
  .tool-intro picture, .tool-intro picture img { min-height: 170px; height: 170px; }
  h1 { font-size: 26px; }
  .lead { font-size: 14px; }
  .workspace { padding: 13px; }
  .workspace-heading { grid-template-columns: 1fr; gap: 8px; }
  .mode-switch { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trip-panel, .results-panel { padding: 11px; }
  .control-row { grid-template-columns: 1fr; }
  .trip-row { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .ongoing-control, .trip-duration { min-height: 32px; }
  .remove-trip { grid-column: 2; justify-self: end; }
  .action-row > button, .file-button { flex: 1 1 130px; }
  .file-button span { width: 100%; }
  .timeline-heading { align-items: start; flex-direction: column; }
  .legend { justify-content: flex-start; }
  .timeline { grid-template-columns: repeat(15, minmax(7px, 1fr)); gap: 3px; }
  .timeline-day { height: 11px; }
  .numbered-steps ol, .sources-section ul { grid-template-columns: 1fr; }
  .content-section { margin-top: 17px; }
  .content-section > section { padding: 20px 2px; }
  .content-section h2 { font-size: 21px; }
  .content-section p, .content-section li { font-size: 14px; }
  .rule-section, .privacy-section, .limitations-section { padding-left: 12px !important; padding-right: 8px !important; }
  .footer { align-items: flex-start; flex-direction: column; }
  .footer nav { justify-content: flex-start; }
}

@media (max-width: 430px) {
  .brand-name { font-size: 13px; }
  .brand img { width: 38px; height: 38px; flex-basis: 38px; }
  .top-actions { gap: 5px; }
  .nav-link { max-width: 105px; padding: 0 7px; font-size: 11px; }
  .language-menu-list { right: -2px; }
  h1 { font-size: 23px; }
  .trust { display: grid; }
  .trip-heading { align-items: stretch; flex-direction: column; }
  .trip-heading .primary { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid > div { min-height: 72px; }
  .timeline { grid-template-columns: repeat(10, minmax(7px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
