/* Fee Calculator — public page. Plain CSS, no framework.
   Calm public-sector look: one accent colour, system fonts, AA contrast,
   visible focus, works from 320 px to desktop and on paper. */

:root {
  --ink: #14212b;
  --muted: #4d5b66;
  --line: #d5dde3;
  --bg: #f4f7f9;
  --card: #ffffff;
  --accent: #0b3a5b;
  --accent-2: #155f8f;
  --accent-soft: #e6f0f6;
  --warn-bg: #fff6e0;
  --warn-ink: #6b4a00;
  --error: #a4161a;
  --ok: #1d6b3a;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent-2); }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Header */
.top { background: var(--accent); color: #fff; padding: 20px 0 22px; }
.top-row { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.top h1 { margin: 2px 0 4px; font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.01em; }
.tagline { margin: 0; max-width: 46rem; color: #d7e6f0; }
.badge {
  display: inline-block; margin: 0; padding: 2px 8px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 0.8125rem; font-weight: 600;
}
.lang { display: flex; gap: 4px; }
.lang a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.lang a[aria-current="page"] { background: rgba(255, 255, 255, 0.18); }
.lang a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Layout */
.layout { display: grid; gap: 20px; padding-top: 20px; padding-bottom: 24px; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 440px; align-items: start; }
  .col-result { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.card h3 { margin: 18px 0 8px; font-size: 1rem; }
.assistant { border-color: #b9d3e4; background: linear-gradient(180deg, #f7fbfe, #fff); }

/* Form */
.grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
label, legend { font-weight: 600; font-size: 0.9375rem; }
input[type="text"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 9px 10px; min-height: 42px;
  border: 1px solid #93a3af; border-radius: 6px; background: #fff;
}
textarea { resize: vertical; min-height: 64px; }
input:disabled, textarea:disabled { background: #eef2f4; }
.hint { margin: 2px 0 0; font-size: 0.8125rem; color: var(--muted); }
.has-error input { border-color: var(--error); }
.error { color: var(--error); font-weight: 600; }

.checks { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.check, .radio { display: flex; gap: 8px; align-items: flex-start; }
.check input, .radio input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check label, .radio label { font-weight: 400; }
.radios { border: 0; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.radios legend { margin-bottom: 6px; padding: 0; }
.radios.inline { flex-direction: row; flex-wrap: wrap; gap: 6px 18px; }

.hours { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
.hour { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px;
        border-bottom: 1px solid #edf1f4; padding-bottom: 8px; }
.hour label { font-weight: 400; }
.hour label .small { display: block; }
.unit { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); }
.unit input { width: 92px; }

details.group { border-top: 1px solid #edf1f4; padding: 8px 0; }
details.group summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.cat-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.cat-item label { font-weight: 400; }
.cat-item label .small { display: block; }
.cat-item input { width: 76px; flex: none; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row p { flex: 1 1 260px; margin: 0; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: 9px 16px; min-height: 42px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }

.notice { margin: 12px 0 0; padding: 10px 12px; border-radius: 6px; background: var(--accent-soft); }
.notice.error { background: #fdecec; color: var(--error); }
.notice a { word-break: break-all; }

/* Vessel search */
.search input { margin-top: 4px; }
.results { list-style: none; margin: 10px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results button {
  width: 100%; text-align: left; font: inherit; background: #fff; border: 0; padding: 10px 12px; cursor: pointer;
  display: flex; flex-direction: column;
}
.results button:hover { background: var(--accent-soft); }
.vessel-card { margin-top: 14px; display: grid; gap: 12px; }
@media (min-width: 700px) { .vessel-card { grid-template-columns: 1fr 1fr; } }
.links a { margin-right: 10px; }

.tile-map { position: relative; height: 220px; margin: 0; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: #aad3df; }
.tile-map .tiles { position: absolute; width: 768px; height: 768px; }
.tile-map .tile { position: absolute; width: 256px; height: 256px; }
.tile-map .tile img { position: absolute; inset: 0; width: 256px; height: 256px; }
.tile-map .marker {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: #d62828; border: 3px solid #fff; box-shadow: 0 0 0 2px #d62828;
}
.tile-map figcaption {
  position: absolute; right: 0; bottom: 0; font-size: 0.6875rem; background: rgba(255, 255, 255, 0.85); padding: 1px 6px;
}

/* Result */
.totals { margin: 0 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.totals div { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.totals dt { font-size: 0.8125rem; color: var(--muted); }
.totals dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals .grand { grid-column: 1 / -1; background: var(--accent); color: #fff; }
.totals .grand dt { color: #d7e6f0; }
.totals .grand dd { font-size: 1.6rem; }

.warnings { margin: 12px 0; padding: 10px 12px 10px 28px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; }

.lines h3 { margin: 18px 0 4px; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.lines table { width: 100%; border-collapse: collapse; }
.lines th, .lines td { text-align: left; vertical-align: top; padding: 9px 0; border-bottom: 1px solid #edf1f4; }
.lines th { font-weight: 600; padding-right: 10px; }
.lines td { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.basis, .ref, .note, .per-year { display: block; font-size: 0.8125rem; font-weight: 400; }
.basis { color: var(--muted); font-variant-numeric: tabular-nums; }
.ref { margin-top: 2px; }
.note { color: var(--muted); font-style: italic; }
.per-year { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.answer { margin-top: 12px; padding: 12px; background: var(--accent-soft); border-radius: 8px; }
.answer p { margin: 0 0 8px; }
.answer.error { background: #fdecec; color: var(--error); }

.foot { padding-bottom: 32px; color: var(--muted); }
sup { font-size: 0.7em; line-height: 0; }

/* Mobile: the total stays in sight while the form is long */
.mobile-total {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 16px; background: var(--accent); color: #fff; text-decoration: none;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}
.mobile-total:hover { color: #fff; }
.mobile-total strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
@media (min-width: 980px) { .mobile-total { display: none; } }
.foot .src { display: inline-block; margin-right: 12px; }

/* Saved estimate page */
.estimate-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.meta { margin: 0 0 12px; }

@media print {
  body { background: #fff; font-size: 11pt; }
  .top { background: #fff; color: var(--ink); padding: 0 0 8px; border-bottom: 2px solid var(--ink); }
  .tagline, .badge { color: var(--ink); background: none; padding: 0; }
  .lang, .col-form, .no-print, .skip, .foot a { display: none !important; }
  .layout { display: block; padding: 0; }
  .col-result { position: static; max-height: none; overflow: visible; }
  .card { border: 0; padding: 0; }
  .totals .grand { background: none; color: var(--ink); border: 2px solid var(--ink); }
  .totals .grand dt { color: var(--ink); }
  a { color: var(--ink); text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
