[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --harbour: #0f2e44;      /* header, primary text on buttons */
  --sea: #1d5f7a;          /* primary action */
  --paper: #eef2f1;        /* page */
  --card: #ffffff;
  --ink: #14212b;
  --muted: #586874;
  --line: #d6dfe2;
  --overdue: #b8321f;  --overdue-bg: #fbe7e3;
  --due: #a86200;      --due-bg: #fdf0dc;
  --soon: #2f6690;     --soon-bg: #e3edf6;
  --ok: #2b7451;       --ok-bg: #e2f1e8;
  --none: #8a979f;     --none-bg: #eef1f3;
  --radius: 12px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.signed-in { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
a { color: var(--sea); }
:focus-visible { outline: 3px solid #7fb3d5; outline-offset: 2px; }

/* ---------- header and navigation ---------- */
header.top {
  background: var(--harbour); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
header.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.tenant { color: #b9cad6; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.nav-wide { display: none; }
.nav-wide a, .nav-wide button.link { color: #dbe6ee; font-size: 15px; }
.nav-wide a[aria-current="page"] { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 6px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar > a, .tabbar summary {
  display: flex; align-items: center; justify-content: center; height: var(--tabbar-h);
  color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; cursor: pointer; list-style: none;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar [aria-current="page"] { color: var(--harbour); font-weight: 700; box-shadow: inset 0 3px 0 var(--sea); }
.more { position: relative; }
.more-menu {
  position: absolute; right: 8px; bottom: calc(var(--tabbar-h) + 6px); min-width: 200px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(15, 46, 68, .18); padding: 6px 0;
}
.more-menu a, .more-menu button.link {
  display: block; width: 100%; text-align: left; padding: 12px 16px; color: var(--ink);
  text-decoration: none; font-size: 16px; background: none; border: 0;
}
.more-menu form { margin: 0; border-top: 1px solid var(--line); }

@media (min-width: 860px) {
  .nav-wide { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin-left: auto; }
  .tenant { flex: 0 1 auto; }
  .tabbar { display: none; }
  body.signed-in { padding-bottom: 32px; }
}

/* ---------- page layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.page-head { margin: 4px 0 16px; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }
.lede { margin: 2px 0 8px; color: var(--muted); }
.back { display: inline-block; margin-bottom: 6px; font-size: 15px; text-decoration: none; }
.back::before { content: "‹ "; }
.facts { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.facts li { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 14px; color: var(--muted); }
.tally { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

.panel, .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.panel > h2 { margin-bottom: 8px; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 14px; }
.actions .button { text-align: center; }
.actions .button:first-child { grid-column: 1 / -1; }
@media (min-width: 600px) { .actions .button:first-child { grid-column: auto; } }

/* section jump links on the vessel page: scroll sideways, stick under the header */
.jump {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; overflow-x: auto;
  margin: 0 -16px 12px; padding: 8px 16px; background: var(--paper);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: none; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 14px; white-space: nowrap;
}
section[id] { scroll-margin-top: 56px; }

/* ---------- the row: what it is on the left, its status on the right ---------- */
.items { margin: 0 -16px; border-top: 1px solid var(--line); }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
  padding: 12px 16px 12px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent;
  color: var(--ink); text-decoration: none;
}
.panel > .items:last-child { margin-bottom: -16px; }
.panel > .items:last-child .item:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
a.item:active { background: #f4f7f8; }
a.item { grid-template-columns: minmax(0, 1fr) auto 10px; }
a.item::after { content: "›"; color: var(--none); font-size: 20px; line-height: 1; align-self: center; }
.item-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; max-width: 46vw; }
.item-when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.chip, .chip-inline {
  display: inline-block; font-size: 13px; font-weight: 650; line-height: 1.2; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--none-bg); color: var(--muted);
}
.s-overdue { border-left-color: var(--overdue); }
.s-due     { border-left-color: var(--due); }
.s-soon    { border-left-color: var(--soon); }
.s-ok      { border-left-color: var(--ok); }
.s-overdue .chip, .chip-inline.s-overdue { background: var(--overdue-bg); color: var(--overdue); }
.s-due .chip,     .chip-inline.s-due     { background: var(--due-bg); color: var(--due); }
.s-soon .chip,    .chip-inline.s-soon    { background: var(--soon-bg); color: var(--soon); }
.s-ok .chip,      .chip-inline.s-ok      { background: var(--ok-bg); color: var(--ok); }
.s-overdue .item-when { color: var(--overdue); }
.empty { color: var(--muted); padding: 12px 16px; margin: 0; }

/* ---------- text bits ---------- */
.muted { color: var(--muted); } .small, .hint { font-size: 14px; }
.hint { color: var(--muted); margin: 10px 0 0; }
.flash { background: #fff6dd; border: 1px solid #f0d58a; padding: 10px 12px; border-radius: 8px; }
.note { background: #eaf2f7; border-left: 4px solid var(--sea); padding: 8px 12px; border-radius: 4px; }
.banner { display: block; background: var(--due-bg); color: var(--due); font-weight: 600; padding: 12px 14px; border-radius: var(--radius); margin: 0 0 14px; text-decoration: none; }
.banner::after { content: " ›"; }
code { overflow-wrap: anywhere; }
dl.conditions { margin: 12px 0 0; }
dl.conditions dt { font-size: 13px; color: var(--muted); margin-top: 8px; }
dl.conditions dd { margin: 2px 0 0; }

/* ---------- forms ---------- */
label { display: block; margin: 0 0 12px; font-size: 14px; color: var(--muted); }
label.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 16px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input[type=checkbox] { width: 22px; height: 22px; margin: 0; flex: none; }
textarea { min-height: 80px; }
.row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 600px) { .row { grid-template-columns: 1fr 1fr; align-items: end; } }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 0 0 10px; }
.inline-form label { flex: 1 1 180px; margin: 0; }
.inline-form span { flex: 1 1 160px; align-self: center; }
button, .button {
  display: inline-block; background: var(--sea); color: #fff; border: 0; border-radius: 10px; padding: 11px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 46px;
}
button.secondary, .button.secondary { background: #dfe9ee; color: var(--harbour); }
button.danger { background: var(--overdue); }
button.small, .button.small { padding: 6px 10px; min-height: 36px; font-size: 14px; }
button.link { background: none; color: inherit; padding: 0; min-height: 0; font-weight: 400; text-decoration: underline; }
form.inline { display: inline; }
details.add { margin-top: 12px; }
details.add > summary {
  list-style: none; cursor: pointer; padding: 10px 12px; border: 1px dashed #b7c6cd; border-radius: 10px;
  color: var(--sea); font-weight: 600;
}
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary::before { content: "+ "; }
details.add[open] > summary { margin-bottom: 12px; border-style: solid; }
details.add[open] > summary::before { content: "− "; }
.danger-zone { margin: 20px 0; }
.dropzone {
  display: block; border: 2px dashed #b7c6cd; border-radius: var(--radius); padding: 18px 14px; text-align: center; color: var(--ink); cursor: pointer;
}
.dropzone-title { display: block; font-weight: 600; font-size: 17px; }
.dropzone input { margin-top: 12px; border: 0; padding: 0; background: none; }
.upload button { width: 100%; margin-top: 10px; }
details summary { cursor: pointer; color: var(--sea); }
pre.extract { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: #f6f8fa; padding: 8px; border-radius: 6px; max-height: 320px; overflow: auto; }
.split { display: grid; gap: 14px; } @media (min-width: 860px) { .split { grid-template-columns: 1fr 1fr; } }
ul.errors { color: var(--overdue); }

/* audit trail */
ol.trail { list-style: none; margin: 0 -16px -16px; padding: 0; border-top: 1px solid var(--line); }
ol.trail li { padding: 10px 16px; border-bottom: 1px solid var(--line); }
ol.trail li:last-child { border-bottom: 0; }
.trail-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.trail-head .item-when { margin-left: auto; }

/* legacy table, kept for wide admin views only */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px 4px; vertical-align: top; }

/* ---------- checklists (offline page) ---------- */
.sync-bar { position: sticky; top: 0; z-index: 2; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; background: var(--none-bg); }
.sync-bar.ok { background: var(--ok-bg); color: var(--ok); } .sync-bar.offline { background: var(--overdue-bg); color: var(--overdue); } .sync-bar.pending { background: var(--due-bg); color: var(--due); }
ol.checklist { padding-left: 0; list-style: none; counter-reset: i; }
ol.checklist li { counter-increment: i; border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; padding: 12px; margin: 0 0 10px; background: #fff; }
ol.checklist li .item-text::before { content: counter(i) ". "; font-weight: 700; }
ol.checklist li.ok { border-color: var(--ok); background: #f3faf6; }
ol.checklist li.bad { border-color: var(--overdue); background: #fdf3f2; }
ol.checklist li.missing { box-shadow: 0 0 0 3px #f0d58a; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.choices .ok-btn { background: var(--ok); } .choices .bad-btn { background: var(--overdue); }
ol.checklist input.note { margin-top: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; }
ol.checklist-view li.bad { color: var(--overdue); }
#run button#submit { width: 100%; }
