/* Brand palette from the logo guide: ink blue #1C2B4A, stamp red #D9482B (stamp and crosses only, never text), paper #F3EDE2.
   Every text pair below meets WCAG AA (4.5:1) in both themes; checked by hand when this palette was set. */
:root {
  --bg: #f3ede2;
  --surface: #fffcf6;
  --ink: #1c2b4a;
  --muted: #5a6274;
  --line: #ddd3c1;
  --brand: #1c2b4a;
  --brand-ink: #f3ede2;
  --brand-soft: #e4e7ee;
  --stamp: #d9482b;
  --ok: #1d7a46;
  --ok-soft: #e5f4ea;
  --warn: #8f5b00;
  --warn-soft: #fbf0d9;
  --soon: #b5480d;
  --soon-soft: #fde9dd;
  --over: #b42318;
  --over-soft: #fde8e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 43, 74, .06), 0 4px 16px rgba(28, 43, 74, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a2c;
    --surface: #18233a;
    --ink: #f3ede2;
    --muted: #a9b1c2;
    --line: #2b3752;
    --brand: #afc2ea;
    --brand-ink: #1c2b4a;
    --brand-soft: #23314f;
    --stamp: #e8674c;
    --ok: #5cc98a;
    --ok-soft: #12291c;
    --warn: #f0b64a;
    --warn-soft: #2d2412;
    --soon: #f38a4f;
    --soon-soft: #301d12;
    --over: #f47066;
    --over-soft: #331714;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin-top: 1.4em; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 .7em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.error { color: var(--over); min-height: 1.2em; margin: .4em 0 0; }
.caution { color: var(--warn); }

/* ---------- header ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px clamp(12px, 3vw, 28px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.2rem;
  font-family: Georgia, "Times New Roman", serif; letter-spacing: .01em; }
.brand img { border-radius: 7px; }

/* The full stamp: 48 px is the smallest size the logo guide allows. */
.footer-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.footer-brand img { width: 56px; height: 56px; flex: none; }
.footer-brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; }

.tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1 1 auto; }
.tabs a {
  padding: 7px 11px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .95rem; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); background: var(--brand-soft); }
.tabs a[aria-current="page"] { color: var(--brand-ink); background: var(--brand); }
.tabs .tab-pro { font-weight: 600; }

.top-controls { display: flex; gap: 6px; }

select, input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }

/* ---------- layout ---------- */

main { max-width: 1080px; margin: 0 auto; padding: clamp(16px, 3vw, 32px); }

/* Each tab's title looks like a page heading; only the landing hero is an h1 for search engines. */
.view-title { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.01em; margin-top: .2em; }

.hero { padding: clamp(12px, 4vw, 40px) 0 8px; max-width: 760px; }
.lead { font-size: 1.1rem; color: var(--muted); }
.badge {
  display: inline-block; margin-top: 12px; padding: 6px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: .9rem;
}

.panel, .card, .rule, .pro-box, .locked, .report {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 16px 18px; margin: 16px 0; }
.panel > h2:first-child { margin-top: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid label, label.inline { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.check { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: .92rem; }
label.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.actions.wrap { flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--over); }
.btn.small { padding: 5px 10px; font-size: .85rem; font-weight: 500; }
.btn.big { padding: 14px 24px; font-size: 1.1rem; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.notice {
  background: var(--warn-soft); color: var(--ink); border-left: 4px solid var(--warn);
  padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}

.banner {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center;
  padding: 10px 16px; background: var(--brand-soft); border-bottom: 1px solid var(--line);
}

.now { font-size: 1.15rem; font-weight: 600; margin: 8px 0 0; }

/* ---------- rule cards ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { padding: 16px; display: flex; flex-direction: column; gap: 2px; border-top: 5px solid var(--ok); }
.card header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.card .big { font-size: 1.6rem; font-weight: 700; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.chip { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

.bar { display: block; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }

.status-ok { border-top-color: var(--ok); }
.status-ok .chip { background: var(--ok-soft); color: var(--ok); }
.status-warn { border-top-color: var(--warn); }
.status-warn .chip { background: var(--warn-soft); color: var(--warn); }
.status-warn .bar > span { background: var(--warn); }
.status-soon { border-top-color: var(--soon); }
.status-soon .chip { background: var(--soon-soft); color: var(--soon); }
.status-soon .bar > span { background: var(--soon); }
.status-over { border-top-color: var(--over); }
.status-over .chip { background: var(--over-soft); color: var(--over); }
.status-over .bar > span { background: var(--over); }
.card-locked { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.card-locked header { width: 100%; }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 44px; gap: 10px; align-items: center; }
.bar-row .bar { margin: 0; }
.bar-row .bar > span { background: var(--brand); }
.bar-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Year timeline: 12 rows of 31 day cells, coloured by country. */
.timeline { display: grid; gap: 3px; max-width: 760px; }
.tl-row { display: grid; grid-template-columns: 3.4em repeat(31, minmax(0, 1fr)); gap: 2px; align-items: center; }
.tl-month { font-size: .78rem; color: var(--muted); text-transform: capitalize; }
.tl-cell { display: block; aspect-ratio: 1; min-height: 6px; border-radius: 2px; background: var(--line); }
.tl-cell.tl-none { visibility: hidden; }
.tl-cell.tl-today { outline: 2px solid var(--ink); outline-offset: 0; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 4px; font-size: .85rem; }
.tl-key { display: inline-flex; align-items: center; gap: 6px; }
.tl-key .tl-cell { width: 12px; height: 12px; min-height: 0; }
.c0 { background: #2f5aa8; } .c1 { background: #e0782f; } .c2 { background: #0f766e; } .c3 { background: #c2417a; }
.c4 { background: #8a9a1f; } .c5 { background: #7a52c7; } .c6 { background: #b5850b; } .c7 { background: #7d8a88; }
.timeline .tl-cell[class*=" c"], .tl-key .tl-cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

.card .remind { align-self: flex-start; margin: 6px 0 4px; }
.report.sample { position: relative; }
.report.sample .report-head { opacity: .85; }

.partners { margin-top: 28px; padding: 14px 18px; border: 1px dashed var(--line); border-radius: var(--radius); }
.partners ul { margin: 0 0 8px; padding-left: 18px; }

/* ---------- trips ---------- */

.trip-list { display: grid; gap: 8px; margin: 16px 0; }
.trip {
  display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(190px, 1.6fr) 80px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.trip-country { font-weight: 600; }
.trip-days { color: var(--muted); font-variant-numeric: tabular-nums; }
.trip-note { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.trip-actions { display: flex; gap: 6px; }

.steps { margin: 6px 0 14px; padding-left: 20px; }
.steps li { margin: 3px 0; }
.preview-table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 8px 0; }
.preview-table th, .preview-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.preview-table th.num, .preview-table td.num { text-align: right; }
.preview-table input { width: 18px; height: 18px; }

/* ---------- planner ---------- */

.result-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.result-list li { padding: 8px 12px; border-radius: 10px; border-left: 4px solid var(--ok); background: var(--ok-soft); }
.result-list li.status-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.result-list li.status-over { border-left-color: var(--over); background: var(--over-soft); }
.result-list li.status-soon { border-left-color: var(--soon); background: var(--soon-soft); }
.overview .result-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.overview .result-list li.current { box-shadow: inset 0 0 0 2px var(--brand); }
.overview button.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--brand); text-decoration: underline; cursor: pointer; }
.result-list li.status-locked { border-left-color: var(--brand); background: var(--brand-soft); }
.big-line { font-size: 1.15rem; font-weight: 700; }

/* ---------- rules ---------- */

.search input { width: 100%; max-width: 420px; margin: 8px 0 14px; }
.rule-list { display: grid; gap: 8px; }
.rule { padding: 0; }
.rule summary {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; cursor: pointer; padding: 12px 16px; font-weight: 600;
}
.rule-body { padding: 0 16px 14px; }
.facts { margin: 0 0 10px; padding-left: 18px; }
.pro-tag { font-size: .75rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }

/* ---------- report ---------- */

.locked { padding: 18px; }
.report { padding: 22px; margin-top: 14px; }
.report:empty { display: none; }
.report table { width: 100%; border-collapse: collapse; margin: 6px 0 18px; font-size: .92rem; }
.report th, .report td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.report th.num, .report td.num { text-align: right; }
.report h3 { margin-top: 14px; }
.report code { word-break: break-all; }
.report-head { border-bottom: 2px solid var(--stamp); margin-bottom: 10px; }

/* ---------- data & pro ---------- */

.profile-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.profile-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }

.pro-box { padding: clamp(18px, 4vw, 36px); max-width: 640px; }
.features { padding-left: 20px; margin: 10px 0 20px; }
.features li { margin: 4px 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.plan .btn { margin-top: auto; white-space: normal; text-align: center; }
.license { margin-top: 20px; display: grid; gap: 6px; }
.license .row { display: flex; gap: 8px; }
.license input { flex: 1; font-family: ui-monospace, Consolas, monospace; }

.code { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* ---------- generated explanation pages ---------- */

.page { max-width: 820px; }
.page h2 { margin-top: 1.6em; }
.page h3 { margin: 1em 0 .3em; }
.page .notice { display: block; }
.crumbs { color: var(--muted); margin-bottom: 10px; }
.facts-table { width: 100%; border-collapse: collapse; margin: 14px 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts-table th, .facts-table td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.facts-table th { width: 30%; color: var(--muted); font-weight: 600; }
.facts-table thead th { width: auto; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; padding-left: 18px; }
.table-scroll { overflow-x: auto; }

/* ---------- footer & toast ---------- */

.footer { max-width: 1080px; margin: 24px auto 0; padding: 20px clamp(16px, 3vw, 32px) 40px; border-top: 1px solid var(--line); font-size: .9rem; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.powered { font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); max-width: 90vw;
}

/* ---------- embed mode ---------- */

body.embed .topbar .top-controls #profileSelect,
body.embed .tabs a[data-view="report"],
body.embed .tabs a[data-view="data"],
body.embed .tabs a[data-view="pro"],
body.embed .footer > p:not(.powered),
body.embed .footer-links,
body.embed .footer-brand { display: none; }
body.embed .footer { margin-top: 8px; padding-bottom: 16px; }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .topbar { gap: 8px; position: static; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .top-controls { margin-left: auto; }
  .trip { grid-template-columns: 1fr auto; }
  .trip-dates, .trip-note { grid-column: 1 / -1; }
  .trip-actions { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: minmax(90px, 40%) 1fr 36px; }
}

/* ---------- print: only the report ---------- */

@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; color-scheme: light; }
  body { font-size: 11pt; }
  .topbar, .footer, .banner, .toast, .no-print, #view-report > .view-title, #view-report > p, .skip { display: none !important; }
  main { padding: 0; max-width: none; }
  .view { display: none !important; }
  #view-report { display: block !important; }
  .report { border: 0; box-shadow: none; padding: 0; }
}
