/* ============================================================================
   MML CREW OPS - styling for the whole app
   ----------------------------------------------------------------------------
   One stylesheet for every screen. Colours live in the variables just below,
   so changing a colour here changes it everywhere.
   Look: "maritime operations centre" - navy header and menu, light working
   area, teal = clickable, traffic-light status pills.
   ========================================================================== */

/* ---------- Fonts (bundled in lib/fonts so the app works offline) -------- */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('lib/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('lib/fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('lib/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url('lib/fonts/barlow-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('lib/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('lib/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  --navy-900: #0b1b2b;     /* header */
  --navy-800: #0f2236;     /* side menu */
  --navy-700: #1b3550;     /* menu hover */
  --navy-text: #c4d2df;    /* menu text */
  --navy-muted: #8ea3b8;   /* menu group labels */

  --teal: #0f7c86;         /* primary action / links */
  --teal-dark: #0a5a61;
  --teal-soft: #e6f4f5;

  --bg: #eef2f5;           /* working area */
  --surface: #ffffff;      /* cards */
  --surface-2: #f3f6f8;    /* subtle panels */
  --line: #d5dde4;
  --line-soft: #e6ebef;
  --field-line: #c9d3dc;

  --text: #132230;
  --text-2: #3d4f60;
  --muted: #56687a;

  /* Status colours (traffic light) */
  --ok-bg: #e6f4ec;   --ok: #17663a;
  --amb-bg: #fff0d9;  --amb: #8f4a05;  --amb-line: #f0cf9c;
  --red-bg: #fdecea;  --red: #a01c12;
  --gry-bg: #eef1f4;  --gry: #55626f;

  --radius: 8px;
  --font: 'Barlow', 'Segoe UI', Arial, sans-serif;
  --font-head: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color-scheme: light; }
body { font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg); }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2, h3 { font-family: var(--font-head); margin: 0; }
.hide { display: none !important; }
.muted { color: var(--muted); }
/* Text only screen readers hear (keeps forms accessible without clutter). */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #5fb7bf; outline-offset: 2px; }

/* ---------- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.pri { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.pri:hover { background: var(--teal-dark); }
.btn.warn { color: var(--amb); border-color: #e6c08f; }
.btn.danger { background: #b45309; border-color: #b45309; color: #fff; }
.btn.danger:hover { background: #92400e; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
}
.iconbtn:hover { color: var(--red); border-color: #e3b3ad; }
.iconbtn svg { width: 16px; height: 16px; }

/* ---------- Pills (small coloured labels) --------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill.ok  { background: var(--ok-bg);  color: var(--ok); }
.pill.amb { background: var(--amb-bg); color: var(--amb); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.gry { background: var(--gry-bg); color: var(--gry); }
.pill.t-OIL { background: #e3ecf6; color: #1d4a7a; }
.pill.t-LPG { background: #e9f4ee; color: #1d6440; }
.pill.t-LNG { background: #efe9f7; color: #4b2d7f; }
.pill.t-other { background: var(--gry-bg); color: var(--gry); }

/* ---------- Form fields --------------------------------------------------- */
.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.f input, .f select, .f textarea, .inp {
  min-height: 40px; width: 100%; border-radius: 6px; border: 1px solid var(--field-line);
  padding: 0 10px; font: inherit; font-size: 14.5px; font-weight: 500; color: var(--text); background: #fff;
}
.f textarea { padding: 10px; resize: vertical; min-height: 80px; }
.f input.bad { border-color: #c46a07; background: #fff8ec; }
.f input:disabled, .f select:disabled, .f textarea:disabled { background: var(--surface-2); color: var(--text-2); }
.req { color: var(--red); }
.hint { font-size: 12px; font-weight: 500; color: var(--muted); }
.fwarn { font-size: 12.5px; font-weight: 600; color: var(--amb); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; }
.span-all { grid-column: 1 / -1; }

/* ---------- Messages ------------------------------------------------------ */
.msg { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.4; }
.msg.err  { background: var(--red-bg); border: 1px solid #f1bdb7; color: #7d160e; }
.msg.amb  { background: #fff4e3; border: 1px solid var(--amb-line); }
.msg.info { background: var(--teal-soft); border: 1px solid #b7dde0; }
.msg strong { margin-right: 4px; }

/* Toast: the small "Saved" note that pops up bottom-right. */
#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 360px;
  background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; font-size: 14px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.err { background: #7d160e; }

/* =========================================================================
   SIGN-IN AND CONNECTION SCREENS
   ========================================================================= */
.authwrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #183553 0%, var(--navy-900) 60%);
}
.authcard {
  width: 100%; max-width: 420px; background: #fff; border-radius: 12px; padding: 28px 28px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 14px;
}
.authbrand { display: flex; align-items: center; gap: 12px; }
.authbrand img { height: 54px; }
.authbrand .t1 { font-family: var(--font-head); font-weight: 700; font-size: 26px; letter-spacing: .04em; line-height: 1; }
.authbrand .t2 { font-size: 13px; color: var(--muted); margin-top: 3px; }
.authcard h2 { font-size: 22px; }
.authcard .btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.authcard .btnrow .btn { flex: 1; }
.tinylink { align-self: flex-end; font-size: 12px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; }

/* =========================================================================
   APP SHELL: header, side menu, main area
   ========================================================================= */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  background: var(--navy-900); color: #fff; display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 22px; padding: 10px 20px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.topbar .brand img { height: 34px; }
.topbar .brand span { font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: .04em; }
.topbar .right { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 13.5px; color: var(--navy-text); }
.topbar .who { color: #fff; font-weight: 600; }
.topbar .who small { color: var(--navy-text); font-weight: 500; }
.topbar .btn { min-height: 34px; padding: 0 12px; font-size: 13px; background: transparent; color: #fff; border-color: #2a4560; }
.topbar .btn:hover { background: var(--navy-700); }
.menutoggle { display: none; }
.navclose { display: none !important; margin: 6px 0 4px auto; color: #fff; border-color: #2a4560; background: transparent; }

.shell { display: flex; flex: 1; min-height: 0; }
.sidenav { width: 232px; flex: none; background: var(--navy-800); padding: 8px 12px 20px; }
.navgrp { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-muted); padding: 14px 14px 4px; }
.navlist { display: flex; flex-direction: column; gap: 2px; }
.navlist a, .navlist span.soon {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--navy-text);
  text-decoration: none; font-size: 14px; font-weight: 500; padding: 10px 14px; border-radius: 6px;
}
.navlist a:hover { background: var(--navy-700); color: #fff; }
.navlist a.on { background: var(--teal); color: #fff; font-weight: 600; }
.navlist span.soon { color: #6f859a; cursor: default; }
.navlist span.soon em { font-style: normal; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; border: 1px solid #34506b; border-radius: 4px; padding: 1px 5px; }

main#view > * { min-width: 0; max-width: 100%; }
main#view { flex: 1; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.pagehead h1 { font-size: 32px; line-height: 1; }
.pagehead .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { font-size: 13.5px; font-weight: 600; text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.h2 { font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Tables -------------------------------------------------------- */
.tablewrap { overflow-x: auto; position: relative; }   /* relative: keeps hidden labels inside the scroll box */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
}
.tbl th button.sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.tbl th button.sort:focus-visible { outline: 3px solid #5fb7bf; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #f7fafb; }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
.tbl .vn { font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: .02em; color: var(--text); text-decoration: none; }
.tbl .vn:hover { color: var(--teal); text-decoration: underline; }
.tbl .acts { display: inline-flex; gap: 6px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Toolbar (filters above a table) ------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { min-height: 40px; padding: 0 16px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--navy-900); color: #fff; }
.toolbar .inp { width: 260px; max-width: 100%; }
.toolbar label.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.toolbar select.inp { width: auto; }

/* ---------- Vessel edit: checkboxes, name/value rows ---------------------- */
.chks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--field-line); border-radius: 6px; font-size: 14px; font-weight: 600; background: #fff; cursor: pointer;
}
.chk:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.chk input { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.row3 { display: grid; grid-template-columns: minmax(0, 1.6fr) 110px 150px auto; gap: 8px; align-items: center; }
.rows .rowhead:only-child { display: none; }
.rowhead { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.row2 .inp, .row3 .inp { min-height: 38px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.panel { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 6px; background: var(--surface-2); font-size: 14px; }
.stickybar { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Crew register ---------------------------------------------- */
.pill.st-onb { background: #e0eefa; color: #154a7a; }    /* on board */
.pill.st-ash { background: #f1eee6; color: #5b4a22; }    /* ashore, not available */
.pill.st-rec { background: #efe9f7; color: #4b2d7f; }    /* recruitment */
.pill.vsl { background: var(--navy-900); color: #fff; letter-spacing: .03em; }
.tbl .cn { font-weight: 600; color: var(--text); text-decoration: none; }
.tbl .cn:hover { color: var(--teal); text-decoration: underline; }
.crewhead { display: flex; gap: 16px; align-items: center; }
.avatar {
  flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--navy-800); color: #fff;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 26px; letter-spacing: .03em;
}
.crewhead h1 { font-size: 30px; line-height: 1.05; }
.crewhead .pref { font-family: var(--font); font-size: 16px; font-weight: 500; color: var(--muted); }
.crewhead .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.crewhead .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--text); border-bottom-color: var(--teal); }
.tab.soon { color: #9aa8b5; cursor: default; }
.ecrow { border: 1px solid var(--line-soft); border-radius: 8px; padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.ecfoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ecfoot .btn.ghost { color: var(--muted); }
.ecfoot .btn.ghost:hover { color: var(--red); }
.chk:has(input[type=radio]:checked) { border-color: var(--teal); background: var(--teal-soft); }
.chk input[type=radio] { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }
.duprow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.seg { flex-wrap: wrap; }

/* ---------- Documents & certificates (Phase 2) -------------------------- */
.pill.org  { background: #fde3d3; color: #93370d; }            /* expires within 30 days */
.pill.yel  { background: #fff3c4; color: #6b5300; }            /* expires within 90 days */
.pill.miss { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px #d9a39d; }   /* missing */
button.tab { background: none; border: 0; border-bottom: 3px solid transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); padding: 10px 14px; cursor: pointer; white-space: nowrap; }
button.tab:hover { color: var(--text); }
button.tab.on { color: var(--text); border-bottom-color: var(--teal); }
.tabpane { display: flex; flex-direction: column; gap: 18px; }
.tabpane.hide { display: none; }
.avatar { overflow: hidden; position: relative; padding: 0; border: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avbtn { cursor: pointer; }
.avbtn .avcam { position: absolute; inset: auto 0 0 0; background: rgba(11,27,43,.7); font-size: 13px; line-height: 20px; opacity: 0; transition: opacity .15s; }
.avbtn:hover .avcam, .avbtn:focus-visible .avcam { opacity: 1; }
.doctop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.reqcard .reqhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.reqsum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.reqlist { display: flex; flex-direction: column; }
.reqrow { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.reqrow .reqtx { font-size: 14px; }
.cathead { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 4px; }
.doctbl td { vertical-align: top; }
.doctbl tr.hist td { color: var(--muted); }
.fpills { display: flex; flex-direction: column; gap: 4px; }
.fmini { display: inline-flex; align-items: center; gap: 6px; max-width: 200px; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 2px 10px 2px 3px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text); }
.fmini span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmini:hover { border-color: var(--teal); color: var(--teal); }
.ficon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 18px; border-radius: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; color: #fff; }
.ficon.pdf { background: #c0392b; }
.ficon.img { background: #2e7d4f; }
.modal.wide { max-width: 860px; }
.meddet { border: 1px dashed #d9b3ad; border-radius: 8px; padding: 12px 14px; background: #fffafa; display: flex; flex-direction: column; gap: 10px; }
/* Upload box (Troy's standard): drop zone on the left, file pills on the right */
.upbox { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.dropzone { flex: none; width: 190px; min-height: 110px; border: 2px dashed var(--field-line); border-radius: 8px; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; text-align: center; font-size: 13px; color: var(--text-2); }
.dropzone.over { border-color: var(--teal); background: var(--teal-soft); }
.dzbtns { display: flex; gap: 6px; }
.fchips { flex: 1 1 320px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; min-width: 0; }
.fchip { display: inline-flex; align-items: center; gap: 6px; width: 320px; max-width: 100%; height: 28px; padding: 0 4px 0 4px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; }
.fchip .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbtn { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.fbtn svg { width: 14px; height: 14px; }
.fbtn:hover { background: var(--surface-2); color: var(--teal); }
.fbtn.del:hover { color: var(--red); }
.frename { flex: 1; height: 24px; border: 1px solid var(--teal); border-radius: 999px; padding: 0 10px; font: inherit; font-size: 13px; min-width: 0; }

/* ---------- Administration ------------------------------------------- */
a.tab { text-decoration: none; display: inline-block; }
a.tab:hover { color: var(--text); }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; background: var(--teal-soft); border: 1px solid #b7dde0; font-weight: 600; font-size: 14px; }
.ruletbl td { vertical-align: top; }
.whobox { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.rankgrid { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.rankgrp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rankgrp .hint { width: 100%; }
.chk.sm { min-height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.chk.sm input { width: 16px; height: 16px; }

/* ---------- Modal dialog -------------------------------------------------- */
.modal-back { position: fixed; inset: 0; z-index: 40; background: rgba(11,27,43,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); padding: 24px 26px; display: flex; flex-direction: column; gap: 16px;
}
.modal h2 { font-size: 26px; line-height: 1.1; }
.modal .li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; }
.modal .li svg { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--ok); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Phone and tablet --------------------------------------------- */
@media (max-width: 860px) {
  .menutoggle { display: inline-flex; }
  .sidenav { position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; transform: translateX(-110%); transition: transform .2s; overflow-y: auto; visibility: hidden; }
  body.menu-open .sidenav { transform: none; visibility: visible; box-shadow: 8px 0 30px rgba(0,0,0,.35); }
  body.menu-open::after { content: ''; position: fixed; inset: 0; z-index: 25; background: rgba(11,27,43,.45); }
  .navclose { display: flex !important; }
  main#view { padding: 16px; }
  .topbar { padding: 8px 16px; }
  .topbar .date { display: none; }
  .row3 { grid-template-columns: minmax(0, 1fr) 80px auto; }
  .row3 .mand { display: none; }
}
@media (max-width: 520px) {
  .topbar .who small { display: none; }
  .pagehead h1 { font-size: 28px; }
  .crewhead h1 { font-size: 24px; }
  .avatar { width: 48px; height: 48px; font-size: 20px; }
  .seg button { padding: 0 10px; font-size: 13px; }
  .reqrow { grid-template-columns: minmax(0, 1fr) auto; }
  .reqrow .reqst { grid-column: 1 / -1; }
  .dropzone { width: 100%; min-height: 0; flex-direction: row; flex-wrap: wrap; }
  .row2 { grid-template-columns: minmax(0, 1fr) auto; }
  .row2 .val { grid-column: 1 / -1; grid-row: 2; }
  .row2.rowhead { display: none; }
  .partrow { padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
  .toolbar .inp { width: 100%; }
}

/* ---- Administration: change log (v0.4.1) ---- */
.logtbl td { vertical-align: top; }
.logtbl .chg { margin: 1px 0; }
.logtbl .chg + .chg { margin-top: 4px; }
.logtbl .arrow { color: var(--muted); padding: 0 2px; }
/* Requirements matrix: up to three action buttons wrap into two rows (v0.4.2) */
.ruletbl td:last-child .acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; width: 190px; }

/* ---- Assignments tab (v0.5.0, Phase 3a) ---- */
.asgcur, .asgnext { display: flex; flex-direction: column; gap: 4px; }
.asgcur.on { border-left: 4px solid var(--teal); }
.asghead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; font-size: 15px; }
.asglabel { display: inline-block; font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin-right: 10px; }
.asgline { font-size: 15px; }
.asgfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; margin-top: 10px; font-size: 14px; }
.t-red { color: var(--red); font-weight: 600; }
.t-amb { color: var(--amb); font-weight: 600; }
.rdbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fbfcfd; }
.rdhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.rdlist { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.rdlist li { padding-left: 18px; position: relative; line-height: 1.35; }
.rdlist li::before { content: ''; position: absolute; left: 2px; top: 6px; width: 8px; height: 8px; border-radius: 50%; }
.rdlist li.rd-b::before { background: var(--red); }
.rdlist li.rd-w::before { background: var(--amb); }
.rdlist li.rd-i::before { background: #9aa8b5; }
.rdlock { color: var(--red); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; }
.sorrow { display: flex; gap: 8px; align-items: center; }
.sorrow .inp { flex: 1; min-width: 0; }


/* ---- Vessel Crew onboard tab (v0.5.1, Phase 3b) ---- */
.mnsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.mnbox { gap: 4px; padding: 14px 16px; }
.mnval { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mnval .muted { font-size: 14px; font-weight: 500; }
.mntbl tr.grp td { background: #f4f6f8; font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; color: var(--muted); padding-top: 6px; padding-bottom: 6px; }
.mntbl tr.vac td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.mnp { padding: 2px 0; line-height: 1.4; }
.mnp + .mnp { border-top: 1px dashed var(--line); margin-top: 3px; padding-top: 5px; }
.mnoff a { text-decoration: line-through; color: var(--muted); }
@media (max-width: 640px) {
  .mnsum { grid-template-columns: 1fr 1fr; }
  .mnval { font-size: 18px; }
}

/* ===========================================================================
   HELP: User guide + About (help.js, guide.js) - added in 0.6.0
   ========================================================================= */
.topbar .hdrhelp { text-decoration: none; }
.hlp { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.hlptoc { padding: 14px; position: sticky; top: 12px; max-height: calc(100vh - 110px); overflow-y: auto; }
.hlptoc .inp { width: 100%; margin-bottom: 10px; }
.hlptoc-ch { font-family: var(--font-head); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; }
.hlptoc-ch:first-child { margin-top: 2px; }
.hlptoc a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-size: 14px; line-height: 1.3; border-left: 3px solid transparent; }
.hlptoc a:hover { background: var(--surface-2); color: var(--text); }
.hlptoc a.on { background: var(--teal-soft); color: var(--text); border-left-color: var(--teal); font-weight: 600; }
.hlpart { padding: 22px 26px; max-width: 860px; }
.hlpcrumb { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hlpart h2 { font-size: 26px; margin: 2px 0 12px; }
.hlptext { font-size: 15px; line-height: 1.55; color: var(--text); }
.hlptext h3 { font-size: 18px; margin: 18px 0 6px; }
.hlptext p, .hlptext ul, .hlptext ol { margin: 0 0 12px; }
.hlptext li { margin: 3px 0; }
.hlptext .msg { margin: 12px 0; }
.hlptext p.who { font-size: 13px; color: var(--muted); font-style: italic; }
.hlptext ol.steps li::marker { font-weight: 700; color: var(--teal); }
.hlptbl { border-collapse: collapse; margin: 6px 0 14px; font-size: 14px; width: 100%; }
.hlptbl th, .hlptbl td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
.hlptbl th { background: var(--surface-2); font-weight: 600; }
.hlptbl td:first-child { white-space: nowrap; width: 1%; }
.hlpfoot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.hlpnav { display: flex; gap: 8px; flex-wrap: wrap; }
.hlpnav .btn { text-decoration: none; }
.hlphits { list-style: none; padding: 0; margin: 0; }
.hlphits li { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.hlphits li a { font-weight: 600; }
.hlphits .muted { font-size: 13px; margin-top: 3px; }
.hlpprint { display: none; }

/* About */
.abt { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.abthead { display: flex; align-items: center; gap: 14px; }
.abtlogo { height: 56px; width: auto; }
.abtname { font-family: var(--font-head); font-size: 26px; font-weight: 700; letter-spacing: .04em; }
.abtdl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 14px; margin: 0; font-size: 14px; }
.abtdl dt { color: var(--muted); }
.abtdl dd { margin: 0; }
.abtnote { font-size: 13px; }
.abtrel { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.abtrel:last-child { border-bottom: 0; }
.abtrel ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.45; }

@media (max-width: 900px) {
  .hlp, .abt { grid-template-columns: minmax(0, 1fr); }
  .hlptoc { position: static; max-height: none; }
  .hlpbody { order: -1; }          /* phone: the text first, contents below it */
  .hlpart { padding: 18px; }
  .hlptbl td:first-child { white-space: normal; }
}

/* Print / Save as PDF: the whole guide, nothing else */
@media print {
  body.printing-guide .topbar, body.printing-guide .sidenav,
  body.printing-guide .pagehead, body.printing-guide .hlp, body.printing-guide #toast { display: none !important; }
  body.printing-guide main#view { padding: 0; }
  body.printing-guide .hlpprint { display: block; font-size: 11pt; line-height: 1.45; color: #000; }
  .hlpprint h1 { font-size: 20pt; margin: 0 0 4pt; }
  .hlpprint h1.hlpprint-ch { page-break-before: always; font-size: 18pt; border-bottom: 2px solid #0f7c86; padding-bottom: 4pt; margin-bottom: 10pt; }
  .hlpprint h2 { font-size: 14pt; margin: 14pt 0 4pt; }
  .hlpprint h3 { font-size: 12pt; margin: 10pt 0 3pt; }
  .hlpprint section { page-break-inside: avoid; }
  .hlpprint .pill { border: 1px solid #999; }
}

/* ===========================================================================
   COLLAPSIBLE SIDE MENU (core.js buildMenu) - added in 0.6.1, style "Glide"
   Group headings open / close their items with a slide; items drift in one
   after another. Overrides the older flat .navgrp label above.
   ========================================================================= */
.navsec { display: flex; flex-direction: column; }
button.navgrp { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 9px; width: 100%; cursor: pointer;
  font-family: var(--font); font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--navy-muted); padding: 9px 12px; margin-top: 6px; border-radius: 6px; transition: color .2s, background .2s; }
button.navgrp:hover { background: var(--navy-700); color: #fff; }
button.navgrp:focus-visible { outline: 2px solid #5fc4cc; outline-offset: -2px; }
.navsec.open > button.navgrp { color: #e7eef5; }
button.navgrp svg { width: 16px; height: 16px; flex: none; }
.navgl { flex: 1; }
.navcnt { font-size: 11px; letter-spacing: 0; min-width: 18px; text-align: center; border-radius: 99px; padding: 1px 6px;
  background: var(--navy-700); color: var(--navy-text); opacity: 0; transform: scale(.6); transition: opacity .2s, transform .25s; }
.navsec:not(.open) .navcnt { opacity: 1; transform: none; }
.navchev { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .3s cubic-bezier(.2, .8, .2, 1); margin-right: 3px; }
.navsec.open .navchev { transform: rotate(45deg) translate(-2px, -2px); }
.navbody { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .38s cubic-bezier(.2, .8, .2, 1); }
.navsec.open .navbody { grid-template-rows: 1fr; }
.navitems { overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.navlist .navitems > a, .navlist .navitems > span.soon { padding-left: 37px; opacity: 0; transform: translateY(-6px);
  transition: opacity .2s, transform .25s, background .15s, color .15s; }
.navlist .navsec.open .navitems > a, .navlist .navsec.open .navitems > span.soon { opacity: 1; transform: none;
  transition-delay: calc(var(--i) * 35ms + 60ms), calc(var(--i) * 35ms + 60ms), 0s, 0s; }
.navitems > :first-child { margin-top: 2px; }
.navitems > :last-child { margin-bottom: 4px; }
.navver { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-muted); padding: 22px 12px 4px; }
.nav-instant, .nav-instant * { transition: none !important; }
@media (prefers-reduced-motion: reduce) { .navlist, .navlist * { transition: none !important; } }

/* ===========================================================================
   STAGE 3c (0.7.0): Rotation planner, Find replacement, Availability
   ========================================================================= */
.rotcard .cathead, .frhead { flex-wrap: wrap; gap: 10px; }
/* timeline */
.rotcard .tlwrap { overflow-x: auto; border-top: 1px solid var(--line-soft); }
.tl { min-width: 820px; padding: 0 16px 8px; }
.tlrow { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: stretch; min-height: calc(var(--lanes, 1) * 26px + 6px); border-bottom: 1px solid var(--line-soft); }
.tllab { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 0; font-size: 13.5px; color: var(--text-2); min-width: 0; }
.tllab > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tltrack { position: relative; }
.tlhead { min-height: 30px; border-bottom: 1px solid var(--line); }
.tlhead .tk { position: absolute; top: 8px; font-size: 11.5px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 4px; height: 22px; }
.tlhead .nowlab { position: absolute; top: 8px; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--teal); background: var(--surface); padding: 0 3px; }
.tlves { min-height: 30px; background: var(--surface-2); }
.tlves .tllab a { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: .03em; color: var(--text); text-decoration: none; }
.tlves .tllab a:hover { color: var(--teal); }
.tltrack .now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--teal); opacity: .55; z-index: 1; }
.tlvac { text-decoration: none; font-size: 11px; padding: 1px 7px; }
.bar { position: absolute; top: calc(var(--lane, 0) * 26px + 4px); height: 22px; border-radius: 5px; display: flex; align-items: center; gap: 4px;
  padding: 0 6px; font-size: 12px; font-weight: 600; text-decoration: none; overflow: hidden; white-space: nowrap; z-index: 2; box-sizing: border-box; }
.bar span { overflow: hidden; text-overflow: ellipsis; }
.bar:hover { filter: brightness(1.08); box-shadow: 0 2px 6px rgba(11, 27, 43, .25); }
.k-ok   { background: #1f4e79; color: #fff; }
.k-amb  { background: #d98c1c; color: #fff; }
.k-red  { background: #c0392b; color: #fff; }
.k-plan { background: #fff; color: #1f4e79; border: 2px dashed #1f4e79; }
.k-done { background: #dfe6ec; color: #56687a; }
.k-max  { outline: 2px solid #c0392b; outline-offset: 1px; }
.bar .od { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.28) 0 4px, transparent 4px 8px); pointer-events: none; }
.kbang { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: #fff; color: #c0392b;
  font-size: 11px; font-weight: 800; flex: none; }
.rotkey { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 16px 14px; font-size: 12.5px; color: var(--muted); }
.rotkey span { display: inline-flex; align-items: center; gap: 6px; }
.rotkey .kb { display: inline-block; width: 22px; height: 11px; border-radius: 3px; box-sizing: border-box; }
.rotkey .kbang { border: 1px solid #c0392b; }
.rdtbl td { vertical-align: top; white-space: normal; }
.rdtbl td:nth-child(1), .rdtbl td:nth-child(5), .rdtbl td:nth-child(9) { white-space: nowrap; }
.rdtbl td:nth-child(8) { min-width: 150px; }
/* find replacement */
.frform { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 16px; align-items: end; }
.frgo { display: flex; align-items: end; padding-bottom: 20px; }
.frrel { margin: 4px 0 0; font-size: 14px; }
.frlist { display: flex; flex-direction: column; }
.frc { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line-soft); align-items: start; }
.frc.frdim { opacity: .62; }
.frrank { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.frmain { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.frtop .cn { font-size: 16px; }
.frpills { display: flex; flex-wrap: wrap; gap: 6px; }
.frwhy { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.frdet summary { cursor: pointer; font-size: 13px; color: var(--teal); }
.frdet .rdlist { margin-top: 6px; }
/* availability on the Assignments tab */
.avcard { gap: 10px; }
.avgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; align-items: center; }
.chiplab { width: 100%; margin-bottom: -2px; }
@media (max-width: 760px) {
  .rotcard { display: none; }          /* phone: the Relief due list is what is needed */
  .frc { grid-template-columns: minmax(0, 1fr); }
  .frrank { display: none; }
  .frgo { padding-bottom: 0; }
}

/* ===========================================================================
   STAGE 3d (0.8.0): Sea service tab and the sea-service letter
   ========================================================================= */
.sstables { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.ssbreak { gap: 8px; }
.ssbreak .tbl td { padding: 6px 4px; }
.sstbl td { vertical-align: top; }
.letterwrap { max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 16px; }
.letter { background: #fff; color: #111; max-width: 760px; margin: 0 auto; padding: 36px 44px; font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 1px 4px rgba(11, 27, 43, .12); }
.letter p { margin: 0 0 10px; }
.lhead { display: flex; gap: 14px; align-items: center; border-bottom: 2px solid #0f7c86; padding-bottom: 12px; margin-bottom: 16px; }
.llogo { height: 54px; width: auto; }
.lco { font-family: var(--font-head); font-size: 22px; font-weight: 700; letter-spacing: .03em; }
.laddr { font-size: 12px; color: #444; }
.ldate { text-align: right; }
.ltitle { font-family: var(--font-head); font-size: 18px; text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 12px; text-align: center; }
.ltbl { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 6px 0 12px; }
.ltbl th, .ltbl td { border: 1px solid #bbb; padding: 4px 5px; text-align: left; vertical-align: top; }
.ltbl th { background: #eef2f5; }
.ltbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.ltbl .ltot td { font-weight: 700; background: #f6f8fa; }
.lsign { margin-top: 44px; width: 260px; }
.lline { border-top: 1px solid #333; margin-bottom: 4px; height: 36px; }
.lblank { display: inline-block; min-width: 160px; border-bottom: 1px dotted #999; color: #999; font-weight: 400; }
#ssPrint { display: none; }
@media print {
  body.printing-letter > *:not(#ssPrint) { display: none !important; }
  body.printing-letter #ssPrint { display: block; }
  body.printing-letter .letter { box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- Over-60 exemption letter (over60.js, 0.9.1) ---------- */
.o60msg { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; margin: 0 14px 12px; }
.o60msg > span:first-child { flex: 1 1 320px; min-width: 0; }
.o60note { margin-top: 3px; color: var(--text-2); }
.o60note .lnkbtn { font-size: 12.5px; }
.o60dlg { display: grid; grid-template-columns: minmax(0, 230px) minmax(0, 1fr); gap: 14px; align-items: start; }
.o60side { display: flex; flex-direction: column; gap: 10px; }
.o60mail { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.o60addr { font-size: 13.5px; word-break: break-all; user-select: all; }
.o60wrap { max-height: 62vh; }
.o60wrap .letter { padding: 28px 40px; }
@media (max-width: 760px) { .o60dlg { grid-template-columns: minmax(0, 1fr); } }
/* The form itself: Troy's "Letter Over 60", Times as on the original */
.o60 { position: relative; font-family: 'Times New Roman', Times, serif; font-size: 15px; line-height: 1.5; color: #000; }
.o60 p { margin: 0 0 18px; text-align: justify; }
.o60head { display: block; width: 78%; max-width: 460px; height: auto; margin: 0 auto 34px; }
.o60date { margin-bottom: 26px !important; }
.o60f { font-weight: 700; background: var(--teal-soft); border-bottom: 1px solid var(--teal); padding: 0 2px; }
.o60blank { display: inline-block; min-width: 150px; border-bottom: 1px solid #000; }
.o60sig { display: flex; flex-direction: column; gap: 4px; margin-top: 30px; }
.o60row { display: flex; gap: 30px; flex-wrap: wrap; }
.o60row.gap { margin-top: 16px; }
.o60line { display: inline-block; width: 170px; border-bottom: 1px solid #000; height: 1em; vertical-align: baseline; }
.o60line.s { width: 110px; } .o60line.xs { width: 60px; } .o60line.l { width: 210px; }
.o60stamp { position: absolute; right: 6%; bottom: -10px; width: 130px; height: auto; opacity: .95; pointer-events: none; }
@media print {
  body.printing-letter .letter.o60print { padding: 0.35in 0.6in; }
  body.printing-letter .o60print .o60 { font-size: 12.5pt; }
  body.printing-letter .o60f { background: none; border: 0; padding: 0; }
  body.printing-letter .o60stamp { bottom: -40px; }
}

/* ---------- Safe Manning Certificate box (vesselcerts.js, 0.8.1) ---------- */
.vcbox { display: flex; flex-direction: column; gap: 10px; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.vcbox:empty { display: none; }
.vchead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.vctitle { font-weight: 600; font-size: 15px; }
.vcmeta { margin: 0; font-size: 14px; line-height: 1.5; }
.vcbox .dropzone { background: #fff; }
.vccond { font-size: 14px; }
.vccond summary { cursor: pointer; color: var(--teal); font-weight: 500; }
.vccond dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 0; }
.vccond dt { color: var(--muted); }
.vccond dd { margin: 0; }
.vcacts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vcacts .hint { margin-left: auto; }
.vcnote { margin-top: 3px; }
.vcnote .pill { font-size: 11px; white-space: nowrap; }
.vcchoice { display: flex; flex-direction: column; gap: 8px; }
.vcchoice .btn { height: auto; min-height: 0; padding: 10px 14px; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; }
.vcchoice .btn span { font-size: 13px; color: var(--muted); font-weight: 400; }
@media (max-width: 640px) { .vcacts .hint { margin-left: 0; width: 100%; } }

/* ---------- Vessel operating state + certificate per state (vesselcerts.js, 0.8.2) ---------- */
:root { --vio-bg: #efeafb; --vio: #53399a; }
.pill.vio  { background: var(--vio-bg); color: var(--vio); }
.pill.teal { background: var(--teal-soft); color: var(--teal-dark); }
.redtxt { color: var(--red); font-weight: 600; }
.oktxt  { color: var(--ok); font-weight: 600; }
.lnkbtn { all: unset; cursor: pointer; color: var(--teal); font-size: 13.5px; font-weight: 500; }
.lnkbtn:hover { text-decoration: underline; }
.lnkbtn:focus-visible { outline: 3px solid #5fb7bf; border-radius: 3px; }
.vsbar { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.vsseg { display: flex; width: 100%; }
.vsseg button { flex: 1 1 0; min-width: 0; min-height: 50px; padding: 6px 10px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; text-align: left; line-height: 1.2; }
.vsseg button + button { border-left: 1px solid var(--line); }
.vsseg button small { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.vsseg button[aria-pressed="true"] small { color: var(--navy-text); }
.vsseg button:disabled { cursor: default; }
.vsseg button:disabled:not([aria-pressed="true"]) { color: var(--muted); }
.vcards { display: flex; flex-direction: column; gap: 10px; }
.vccard { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.vccard.on { border: 2px solid var(--teal); padding: 11px 13px; }
details.vccard { gap: 0; background: var(--surface-2); }
details.vccard[open] { gap: 10px; background: #fff; }
details.vccard > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
details.vccard > summary::-webkit-details-marker { display: none; }
details.vccard > summary::before { content: '\25B8'; color: var(--teal); margin-right: -4px; }
details.vccard[open] > summary::before { content: '\25BE'; }
details.vccard > summary .vchead { flex: 1 1 auto; justify-content: flex-start; }
details.vccard > summary:focus-visible { outline: 3px solid #5fb7bf; border-radius: 4px; }
.vcsum { font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.vccard .vchead { justify-content: flex-start; }
.vccrew { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 14px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); }
.vccrew .lbl { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.vccrew .btn, .vccrew .hint { margin-left: auto; }
.vscmp td, .vscmp th { padding: 6px 10px; }
.vscmp tr.tot td { font-weight: 700; border-top: 1px solid var(--line); }
.vlrows { display: flex; flex-direction: column; gap: 8px; }
.vlrow { display: grid; grid-template-columns: minmax(0, 1fr) 80px auto; gap: 8px; align-items: center; }
.vltot { margin-left: auto; font-size: 14px; color: var(--text-2); }
.mnstate { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.mnstate .hint { margin-left: auto; }
@media (max-width: 640px) {
  .vsseg { flex-direction: column; }
  .vsseg button + button { border-left: 0; border-top: 1px solid var(--line); }
  .vccrew .btn, .vccrew .hint, .mnstate .hint { margin-left: 0; }
}
.modal .btnrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Documents tab as one list (documents.js, 0.8.4) ---------- */
.doclist { overflow: hidden; }
.doclist .dlhead { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.doclist .dltop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.dlchips { display: flex; flex-wrap: wrap; gap: 6px; }
.dlchip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.dlchip b { font-variant-numeric: tabular-nums; }
.dlchip:hover { border-color: var(--teal); }
.dlchip[aria-pressed="true"] { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.dlchip:focus-visible { outline: 3px solid #5fb7bf; }
.dltbl { border-top: 1px solid var(--line); }
.dltbl td { vertical-align: middle; }
.dltbl tr.grp td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 6px 12px; }
.dltbl tr.extra td:first-child { opacity: .85; }
.dltbl .vok { color: var(--ok); font-weight: 600; white-space: nowrap; }
.dltbl td.dlacts { text-align: right; }
.dltbl td.dlacts .acts { display: inline-flex; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }
.doclist .dlfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.dltbl .dlstack { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ---------- Change rank on board (0.8.5) -------------------------------- */
.rkchoice { display: flex; flex-direction: column; gap: 8px; }
.rkchoice .chk { align-items: flex-start; padding: 10px 14px; min-height: 0; }
.rkchoice .chk input { margin-top: 2px; flex: none; }
.rkchoice .chk small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.35; }
.rkhappen { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fbfcfd; font-size: 14px; }
.rkhappen ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.35; }
.rkline { margin: 8px 0 0; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.rkline b { color: var(--text); }
/* (0.9.0) sailing in another position, keeps his rank */
.pill.pos { background: var(--amb-bg); color: var(--amb); }
.rkwarn { margin-top: 8px; font-size: 13.5px; }
.rkfound { margin-top: 6px; }
.rkfound ul { margin: 4px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.rkfound details { margin-top: 4px; }
.rkfound summary { cursor: pointer; font-weight: 600; color: var(--teal); }
.rkmore { margin-top: 4px; color: var(--teal); padding-left: 0; }

/* ---------- Favorites and Recently viewed (0.8.6) ------------------------ */
.favstar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; margin-left: 10px;
  border-radius: 50%; border: 1px solid var(--line); background: #fff; color: #9aa8b5; cursor: pointer; vertical-align: middle; position: relative; top: -3px; }
.favstar svg { width: 18px; height: 18px; }
.favstar:hover { color: #c98a00; border-color: #ecd28a; }
.favstar.on { color: #c98a00; border-color: #ecd28a; background: #fff8e1; }
.favstar:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.hlpart h2 .favstar { width: 30px; height: 30px; top: -2px; }
.navfavicon { display: inline-flex; width: 16px; height: 16px; color: #e0b44a; }
.navfavicon svg { width: 16px; height: 16px; }
.navlist .navfav a { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; padding: 7px 14px; }
.navfav a .fl { display: flex; gap: 7px; align-items: center; width: 100%; min-width: 0; }
.navfav a .fl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navfav a .fl svg { width: 12px; height: 12px; color: #e0b44a; flex: none; }
.navfav a small { font-size: 11.5px; color: #8ea3b8; font-weight: 500; padding-left: 19px; line-height: 1.3; }
.navfav a small.alert { color: #f0b37a; }
.navfav a.on small, .navfav a:hover small { color: #d6e2ec; }
.navfav .navmore { display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; font: inherit; font-size: 12px; color: #7fb5bb; padding: 4px 14px 8px 33px; }
.navfav .navmore:hover { color: #fff; text-decoration: underline; }
.navfav .navempty { margin: 2px 0 4px; padding: 0 14px 0 33px; font-size: 12px; color: #8ea3b8; line-height: 1.35; }
.navlist .navrecent a { padding: 6px 14px; font-size: 13px; color: #a9bccd; }
.navrecent a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navrecent a small { color: #6f859a; font-size: 11px; flex: none; }
.favtbl td { vertical-align: middle; }
.favnote { width: 100%; min-height: 34px; border: 1px solid var(--field-line); border-radius: 6px; padding: 0 10px; font: inherit; font-size: 13.5px; }
.favconfirm { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; width: 100%; }
.favtbl td:nth-child(2) { white-space: normal; min-width: 150px; max-width: 260px; }
.favtbl td:nth-child(3) { min-width: 170px; }

/* ---------- Small crew photos in lists (0.8.8) --------------------------- */
.cav { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: #dfe6ed; color: #4a5d70; font: 700 12px var(--font-head); letter-spacing: .03em; vertical-align: middle; }
.cav img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cav.none { background: #fff8ec; color: #a15c07; border: 1.5px dashed #e0a34a; }
.tbl th.pc, .tbl td.pc { width: 46px; padding-right: 0; }
.tbl td.pc .cav { width: 34px; height: 34px; font-size: 13px; }
.pcname { display: inline-flex; align-items: center; gap: 10px; }
.frtop .cav { margin-right: 4px; }
.rdtbl td:nth-child(2) { min-width: 210px; }

/* ---------- Photo viewer, add from a list (0.8.9) ----------------------- */
.cav[role="button"] { cursor: pointer; }
.cav[role="button"]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.cav img { transition: transform .15s; }
.cav[role="button"]:hover img { transform: scale(1.08); }
.cav.none.can:hover, .cav.none.can:focus-visible { color: transparent; background: #fff no-repeat center / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%230f7c86' stroke-width='1.6'%3E%3Cpath d='M3 6.5h3l1.5-2h5l1.5 2h3v9H3z'/%3E%3Ccircle cx='10' cy='11' r='3'/%3E%3C/svg%3E");
  border-color: var(--teal); }
.pvwrap { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 22px; align-items: start; }
.pvimg { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #dfe6ed; display: flex; align-items: center; justify-content: center; }
.pvimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pvinfo h2 { font-size: 28px; line-height: 1.1; }
.pvinfo .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.pvinfo .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.pvinfo .btns { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 16px; }
.pvconfirm { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }
@media (max-width: 640px) { .pvwrap { grid-template-columns: 1fr; } }

/* ---------- Users & roles (0.9.3) ---------------------------------------- */
.uroles { display: flex; flex-direction: column; gap: 8px; }
.urole { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.urole input { margin-top: 3px; }
.urole .hint { display: block; font-size: 13px; }
#usTable .acts { flex-wrap: nowrap; }
