/* Waldersløff Maritime Stability
   Visual language: waldersloff.no (warm charcoal, ivory, copper accent, Manrope, mono labels, fine rules,
   square corners) combined with the approved prototype's maritime blue/teal for water, data and diagrams. */

@font-face { font-family: Manrope; src: url('../fonts/manrope-latin.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  --paper: #111110; --surface: #1a1917; --raised: #221f1c; --raised2: #2a2622; --line: #393631; --line2: #4a4540;
  --ink: #f1eee8; --muted: #b5afa6; --faint: #8d877e;
  --accent: #d6a284; --accent-hover: #e9bfa5; --accent-contrast: #17120f; --accent-soft: #3a2a20;
  --water: #47b8f5; --water-soft: #12324a; --teal: #4fd8c4; --teal-soft: #11352f;
  --ok: #5fd3b7; --ok-soft: #12352e; --warn: #f0c070; --warn-soft: #3d3020; --bad: #ff8f8f; --bad-soft: #42232a; --grey: #aeb6bf; --grey-soft: #2b2e33;
  --hull: #2b3946; --hull-line: #8fb9d3; --cargo: #c9925f; --cargo-sel: #f1d2b8;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --body: Manrope, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --r: 3px; --gutter: clamp(14px, 3vw, 32px);
}
:root[data-theme='light'] {
  color-scheme: light;
  --paper: #f0ede6; --surface: #e8e3d9; --raised: #f7f4ee; --raised2: #ece6dc; --line: #c7c2b7; --line2: #b3ad9f;
  --ink: #22221f; --muted: #5b5b52; --faint: #77756b;
  --accent: #815032; --accent-hover: #673d24; --accent-contrast: #fffaf3; --accent-soft: #ead8c9;
  --water: #136f9e; --water-soft: #d5e7f0; --teal: #0d7d6d; --teal-soft: #d3ece6;
  --ok: #11705f; --ok-soft: #d4ebe3; --warn: #8a5a00; --warn-soft: #f2e2c0; --bad: #a3262f; --bad-soft: #f3d6d6; --grey: #5e646b; --grey-soft: #dfe1e3;
  --hull: #d9e4ec; --hull-line: #2d5f80; --cargo: #a2652f; --cargo-sel: #5a3216;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
::selection { background: var(--accent); color: var(--accent-contrast); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: .25em; }
h1, h2, h3 { margin: 0; letter-spacing: -.03em; font-weight: 600; line-height: 1.15; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: 12px; top: 8px; z-index: 50; padding: 10px 14px; background: var(--ink); color: var(--paper); transform: translateY(-200%); }
.skip:focus { transform: none; }
.mono, .label { font-family: var(--mono); }
.label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); }

/* ------------------------------------------------------------------ shell */
.shell { max-width: 1520px; margin: 0 auto; padding: 0 var(--gutter) 64px; }
.top { display: flex; align-items: center; gap: 20px; min-height: 76px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); }
.wordmark { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.wordmark svg { width: 30px; height: 30px; flex: none; }
.wordmark .name { display: block; font-size: 19px; font-weight: 650; letter-spacing: -.055em; line-height: 1; }
.wordmark .name em { font-style: normal; color: var(--accent); }
.wordmark .detail { display: block; margin-top: 6px; font: 400 9.5px/1 var(--mono); letter-spacing: .19em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); font: 400 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; background: transparent; }
label.chip { white-space: normal; line-height: 1.35; min-height: 36px; text-align: left; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.chip.off .dot { background: var(--warn); }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: var(--r); }
.iconbtn:hover { border-color: var(--accent); }

.vessels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.vessel { display: flex; gap: 14px; align-items: center; padding: 14px 16px 14px 0; border: 0; background: none; text-align: left; color: inherit; border-bottom: 2px solid transparent; min-width: 0; }
.vessel + .vessel { padding-left: 16px; border-left: 1px solid var(--line); }
.vessel svg { width: 76px; height: 30px; flex: none; color: var(--muted); }
.vessel b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vessel small { display: block; font: 400 10px/1.4 var(--mono); letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.vessel[aria-pressed='true'] { border-bottom-color: var(--accent); }
.vessel[aria-pressed='true'] svg { color: var(--accent); }
.vessel:hover b { color: var(--accent-hover); }
.vessel.add { color: var(--muted); }
.vessel.add b { color: var(--accent); }

.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
.side { position: sticky; top: 96px; align-self: start; }
.side .label { margin: 4px 0 12px; display: block; }
.nav { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 8px 10px; margin: 0 0 2px; border: 0; border-left: 2px solid transparent; background: none; color: var(--muted); text-align: left; font-size: 13.5px; }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav:hover { color: var(--ink); background: var(--surface); }
.nav[aria-current='page'] { color: var(--ink); border-left-color: var(--accent); background: var(--surface); }
.side-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }
.side-note b { color: var(--muted); font-weight: 600; }
main { min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 4px 0 20px; flex-wrap: wrap; }
.page-head .label { display: flex; gap: 12px; margin-bottom: 10px; }
.page-head .label i { font-style: normal; color: var(--accent); }
.page-head h1 { font-size: clamp(24px, 3.2vw, 34px); font-weight: 550; letter-spacing: -.045em; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 72ch; font-size: 13.5px; }
.page-head .pills { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ building blocks */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.stack > * + * { margin-top: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.panel.flush { padding: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; letter-spacing: -.02em; }
.panel-head .label { display: block; margin-bottom: 4px; }
.rule { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 13px; min-width: 0; position: relative; text-align: left; color: inherit; width: 100%; }
button.tile:hover { border-color: var(--line2); }
.tile .label { display: block; }
.tile .val { font-size: clamp(20px, 2.3vw, 26px); font-weight: 600; letter-spacing: -.04em; margin: 8px 0 4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.tile .sub { font-size: 11.5px; color: var(--muted); }
.tile .st { position: absolute; top: 12px; right: 12px; }
.tile.na .val { color: var(--faint); font-size: 18px; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 2px; font: 500 10px/1.3 var(--mono); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; border: 1px solid transparent; }
.tag.doc { background: var(--ok-soft); color: var(--ok); }
.tag.calc { background: var(--water-soft); color: var(--water); }
.tag.interp { background: var(--teal-soft); color: var(--teal); }
.tag.manual { background: var(--accent-soft); color: var(--accent); }
.tag.assumed { background: var(--warn-soft); color: var(--warn); }
.tag.missing, .tag.out_of_range { background: var(--grey-soft); color: var(--grey); }
.tag.invalid, .tag.blocked { background: var(--bad-soft); color: var(--bad); }
.tag.line { border-color: var(--line); color: var(--muted); background: none; }

.status { display: inline-flex; align-items: center; gap: 6px; font: 600 10.5px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.status::before { content: ''; width: 9px; height: 9px; flex: none; }
.status.green { color: var(--ok); } .status.green::before { background: var(--ok); border-radius: 50%; }
.status.yellow { color: var(--warn); } .status.yellow::before { background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.status.red { color: var(--bad); } .status.red::before { background: var(--bad); }
.status.grey { color: var(--grey); } .status.grey::before { border: 1.5px solid var(--grey); border-radius: 50%; }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.kv .tag { margin-left: 8px; }

.note { border-left: 2px solid var(--water); background: var(--water-soft); padding: 10px 13px; font-size: 12.5px; color: var(--ink); border-radius: 0 var(--r) var(--r) 0; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }
.note.grey { border-color: var(--grey); background: var(--grey-soft); }
.note + .note { margin-top: 8px; }
.note ul { margin: 6px 0 0; padding-left: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line2); background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; border-radius: var(--r); white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 12px; min-height: 34px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--accent-contrast); }

label.field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea, input.cell, select.cell {
  width: 100%; min-height: 38px; padding: 7px 9px; background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); color: var(--ink); font-variant-numeric: tabular-nums;
}
.field textarea { min-height: 130px; font: 12px/1.5 var(--mono); }
.field input:focus, .field select:focus, input.cell:focus, select.cell:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field .hint { font-size: 11px; color: var(--faint); }
input[type='range'] { width: 100%; accent-color: var(--accent); }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); max-width: 100%; }
.tablewrap.tall { max-height: 520px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 12.5px; }
th { position: sticky; top: 0; background: var(--raised); color: var(--muted); font: 600 10.5px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; z-index: 1; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--raised) 60%, transparent); }
td.flag-invalid, td.flag-blocked { background: var(--bad-soft) !important; color: var(--bad); }
td.flag-suspect { background: var(--warn-soft) !important; color: var(--warn); }
td.flag-resolved { background: var(--teal-soft) !important; }
td.flag-info { box-shadow: inset 0 -2px 0 var(--water); }
tr.sum td { font-weight: 700; background: var(--raised); }
tr.sel td { background: var(--accent-soft) !important; }
tr.unloaded td { opacity: .5; text-decoration: line-through; }
tr.unloaded td:first-child, tr.unloaded td:last-child { text-decoration: none; }

.formula { margin: 10px 0 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); font: 12px/1.75 var(--mono); white-space: pre-wrap; overflow-x: auto; color: var(--ink); }
.formula .c { color: var(--faint); }

details.more { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
details.more summary { font: 600 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); list-style: none; display: flex; gap: 8px; align-items: center; min-height: 32px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: '+'; display: inline-block; width: 14px; }
details.more[open] summary::before { content: '–'; }

.empty { border: 1px dashed var(--line2); padding: 26px; text-align: center; color: var(--muted); border-radius: var(--r); font-size: 13px; }

/* ------------------------------------------------------------------ diagrams */
.diagram { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
svg.diagram[data-view] { touch-action: none; }
.diagram text { font-family: var(--mono); fill: var(--muted); }
.diagram .hull { fill: var(--hull); stroke: var(--hull-line); stroke-width: 1.4; }
.diagram .hull-line { fill: none; stroke: var(--hull-line); stroke-width: 1; opacity: .55; }
.diagram .deck { stroke: var(--hull-line); stroke-width: .8; stroke-dasharray: 3 4; opacity: .7; }
.diagram .space { fill: color-mix(in srgb, var(--water) 9%, transparent); stroke: var(--line2); stroke-width: .8; }
.diagram .space.drop { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); }
.diagram .tankshape { fill: color-mix(in srgb, var(--teal) 10%, transparent); stroke: color-mix(in srgb, var(--teal) 45%, transparent); stroke-width: .7; }
.diagram .tankfill { fill: color-mix(in srgb, var(--teal) 45%, transparent); }
.diagram .water { fill: color-mix(in srgb, var(--water) 16%, transparent); }
.diagram .wl { stroke: var(--water); stroke-width: 1.6; }
.diagram .axis { stroke: var(--line2); stroke-width: 1; }
.diagram .grid { stroke: var(--line); stroke-width: .7; stroke-dasharray: 2 4; }
.diagram .ref { stroke: var(--faint); stroke-width: .9; stroke-dasharray: 4 4; }
.diagram .mark-g { fill: var(--accent); }
.diagram .mark-b { fill: var(--water); }
.diagram .mark-m { fill: var(--teal); }
.diagram .item { fill: color-mix(in srgb, var(--cargo) 60%, var(--surface)); stroke: var(--cargo); stroke-width: 1.2; cursor: grab; }
.diagram .item.k-container20, .diagram .item.k-container40 { fill: color-mix(in srgb, var(--cargo) 45%, var(--surface)); }
.diagram .item.k-tank { fill: color-mix(in srgb, var(--teal) 40%, var(--surface)); stroke: var(--teal); cursor: default; }
.diagram .item.k-bulk { fill: color-mix(in srgb, var(--cargo) 25%, var(--surface)); stroke-dasharray: 4 3; }
.diagram .item.sel { stroke: var(--cargo-sel); stroke-width: 2.4; fill: color-mix(in srgb, var(--accent) 65%, var(--surface)); }
.diagram .item.dragging { cursor: grabbing; opacity: .85; }
.diagram .item.ghost { fill: none; stroke: var(--faint); stroke-dasharray: 3 3; pointer-events: none; }
.diagram .slot { fill: none; stroke: var(--line2); stroke-width: .5; stroke-dasharray: 2 2; }
.diagram .curve { fill: none; stroke: var(--teal); stroke-width: 2.2; }
.diagram .curve.b { stroke: var(--accent); stroke-dasharray: 6 4; }
.diagram .area1 { fill: color-mix(in srgb, var(--teal) 18%, transparent); }
.diagram .area2 { fill: color-mix(in srgb, var(--water) 22%, transparent); }
.diagram .pt { fill: var(--teal); }
.diagram .lbl-ink { fill: var(--ink); }
.diagram .lbl-acc { fill: var(--accent); }
.diagram .lbl-water { fill: var(--water); }
.chartwrap { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); padding: 8px; }
table.items .msum { display: none; }
.chartwrap.pan { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chartwrap.pan > svg { max-width: none; }
.zoombar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; margin: 0 0 6px; }
.zoombar .label { font-size: 9.5px; }
.zoombar .zb { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.zoombar .zb b { font: 600 11px/1 var(--mono); min-width: 42px; text-align: center; color: var(--muted); }
.zoombar .btn.sm { min-width: 36px; min-height: 34px; justify-content: center; }
.cap { font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--teal); }
.legend i.b { background: var(--accent); }
.legend i.w { background: var(--water); }

/* ------------------------------------------------------------------ cargo page */
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.addbtn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 112px; min-height: 52px; padding: 7px 11px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--paper); color: var(--ink); text-align: left; }
.addbtn b { font-size: 12.5px; font-weight: 600; }
.addbtn small { font: 400 10px/1.2 var(--mono); color: var(--faint); letter-spacing: .04em; }
.addbtn:hover { border-color: var(--accent); }
.itemcell { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.itemcell input.cell { min-width: 120px; }
input.cell { min-height: 32px; padding: 4px 7px; font-size: 12.5px; width: 84px; text-align: right; }
input.cell.name { text-align: left; width: 100%; min-width: 130px; }
select.cell { min-height: 32px; padding: 3px 6px; font-size: 12px; width: auto; max-width: 180px; }
.swatch { width: 10px; height: 10px; flex: none; background: var(--cargo); }
.swatch.k-tank { background: var(--teal); }
.opbox { border: 1px solid var(--accent); border-radius: var(--r); padding: 14px 16px; background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.cmp td.d { font-weight: 600; }
.cmp td.up { color: var(--warn); }
.cmp td.down { color: var(--water); }
.live { font: 12px/1.4 var(--mono); color: var(--accent); min-height: 18px; }

.checklist { display: grid; gap: 8px; }
.checkrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.checkrow:last-child { border: 0; }
.checkrow small { display: block; color: var(--faint); font-size: 11.5px; }
.unc { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.unc summary { cursor: pointer; color: var(--warn, #d9a441); list-style: none; }
.unc summary::before { content: "▸ "; }
.unc[open] summary::before { content: "▾ "; }
.unc ul { margin: 4px 0 0; padding-left: 16px; }
.unc li { margin: 2px 0; }

.crit { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, .8fr)) minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.crit:last-child { border: 0; }
.crit .why { font-size: 11px; color: var(--faint); grid-column: 1 / -1; margin-top: -4px; }
.crit.head { font: 600 10px/1.2 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

.flagrow { display: grid; grid-template-columns: 90px 70px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.issue { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--r); padding: 14px 16px; }
.issue.done { border-color: var(--teal); background: var(--teal-soft); }
.issue h3 { font-size: 14px; margin-bottom: 6px; }
.issue p { margin: 6px 0; font-size: 12.5px; }

.vcard { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; align-items: center; }
.vcard svg { width: 110px; height: 44px; color: var(--accent); }
.cov { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; margin-top: 10px; }
.cov div { font-size: 12px; display: flex; gap: 7px; align-items: center; }

/* paper */
.paper { background: #fff; color: #111; border-radius: 2px; padding: 34px 38px; max-width: 820px; margin: 0 auto; font: 12px/1.6 Arial, Helvetica, sans-serif; }
.paper h2 { font-size: 19px; letter-spacing: -.01em; margin: 0; color: #111; }
.paper .ph { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 16px; }
.paper .ph small { display: block; color: #444; font-size: 11px; }
.paper .brand { text-align: right; font-size: 11px; color: #444; }
.paper .brand b { color: #111; font-size: 13px; }
.paper pre { white-space: pre-wrap; word-break: break-word; font: 11.5px/1.62 'Courier New', Courier, monospace; color: #111; margin: 0; }
.paper .pf { border-top: 1px solid #999; margin-top: 18px; padding-top: 8px; font-size: 10px; color: #444; }

footer.site { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--faint); }
footer.site .label { color: var(--faint); }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); font-size: 13px; z-index: 60; box-shadow: 0 6px 24px #0006; max-width: calc(100vw - 32px); }
.bottomnav { display: none; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .layout { display: block; }
  .side { display: none; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 2px; scrollbar-width: none; }
  .bottomnav button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 66px; min-height: 52px; padding: 6px 6px; border: 0; background: none; color: var(--muted); font-size: 10.5px; border-top: 2px solid transparent; }
  .bottomnav button svg { width: 18px; height: 18px; }
  .bottomnav button[aria-current='page'] { color: var(--ink); border-top-color: var(--accent); }
  .shell { padding-bottom: 96px; }
  .vessels { grid-template-columns: repeat(4, minmax(178px, 1fr)); overflow-x: auto; scrollbar-width: thin; }
  .vessel { gap: 10px; }
  .vessel svg { width: 44px; }
  .vessel small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 640px) {
  body { font-size: 13.5px; }
  .top { min-height: 62px; gap: 10px; }
  .wordmark .name { font-size: 16px; }
  .wordmark .detail { letter-spacing: .12em; font-size: 8.5px; }
  .chip.hide-sm { display: none; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 12px; }
  .panel { padding: 14px; }
  .crit { grid-template-columns: minmax(0, 1fr) auto; }
  .crit > :nth-child(2), .crit > :nth-child(3), .crit > :nth-child(4) { display: none; }
  .crit.head { display: none; }
  .flagrow { grid-template-columns: 70px minmax(0, 1fr); }
  .flagrow > :nth-child(2) { display: none; }
  .flagrow > :last-child { grid-column: 1 / -1; }
  .paper { padding: 18px; }
  .vcard { grid-template-columns: 1fr; }
  .page-head { margin-bottom: 14px; }
  .tag { white-space: normal; max-width: 100%; }
  .kv { flex-wrap: wrap; gap: 4px 14px; }
  .tablewrap.tall:has(table.items) { max-height: none; overflow: visible; border: 0; }
  /* item table becomes compact cards: name on top, 4 numbers per row, labels above values */
  table.items thead { display: none; }
  table.items, table.items tbody { display: block; width: 100%; }
  table.items tr { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 8px 6px; padding: 10px 2px 12px; border-bottom: 1px solid var(--line); }
  table.items td { display: block; min-width: 0; border: 0; padding: 0; text-align: left; }
  table.items td:empty { display: none; }
  table.items td[data-l]::before { content: attr(data-l); display: block; font: 600 9px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  table.items td[data-l=""]::before, table.items td.velg::before, table.items td.wide::before { display: none; }
  table.items td.wide { grid-column: 1 / -1; padding-left: 32px; }
  table.items tr.base td.wide, table.items tr.sum td.wide { padding-left: 0; font-weight: 600; }
  table.items td.velg { position: absolute; left: 2px; top: 18px; }
  table.items td.velg input { width: 22px; height: 22px; margin: 0; }
  table.items td.rom { grid-column: span 2; }
  table.items td.act { align-self: end; justify-self: end; }
  table.items td.r { font-variant-numeric: tabular-nums; }
  table.items input.cell, table.items select.cell { width: 100%; min-height: 38px; font-size: 16px; padding: 6px 7px; }
  table.items input.cell.name { font-weight: 600; }
  table.items .itemcell { display: flex; align-items: center; gap: 8px; }
  table.items td.wide small { display: block; margin-top: 4px; line-height: 1.35; }
  table.items td.wide .actions { flex-wrap: wrap; gap: 6px 10px; }
  table.items tr.sum { background: var(--paper); border-bottom: 0; }
  /* collapsed card: name + one summary line; selecting the item (checkbox or summary) opens it for editing */
  table.items tr:not(.sel):not(.base):not(.sum) > td:not(.wide):not(.velg) { display: none; }
  table.items tr:not(.sel) td.wide > small, table.items tr:not(.sel) td.wide > .actions { display: none; }
  table.items tr:not(.sel):not(.base):not(.sum) { padding-bottom: 8px; }
  table.items .msum { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font: 500 11.5px/1.35 var(--mono); color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums; }
  table.items .msum span { flex: none; color: var(--accent); font-family: var(--sans, inherit); font-weight: 600; }
  table.items tr.sel .msum { color: var(--faint); }
  table.items tr.unloaded { opacity: .55; }
}

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

@page { size: A4; margin: 14mm 12mm 16mm; }
@media print {
  :root { --paper: #fff; --ink: #000; }
  body { background: #fff; color: #000; }
  .top, .vessels, .side, .bottomnav, .page-head, .no-print, footer.site, .toast { display: none !important; }
  .shell { padding: 0; max-width: none; }
  .layout { display: block; }
  .panel { border: 0; background: #fff; padding: 0; }
  .paper { padding: 0; max-width: none; box-shadow: none; }
  .print-only { display: block !important; }
  .paper pre, #paperText { white-space: pre-wrap; word-break: break-word; font-size: 8.6pt; line-height: 1.35; color: #000; }
  .chartwrap svg { max-height: 70mm; width: 100% !important; }
  .zoombar { display: none !important; }
  section.panel { break-inside: avoid; }
}

/* 3D illustration */
.v3d .hull3d { stroke: var(--line-strong, #888); stroke-width: 1; }
.v3d .hull3d.far { fill: var(--panel-2, rgba(127,127,127,.10)); }
.v3d .hull3d.near { fill: var(--accent-soft, rgba(214,162,132,.10)); fill-opacity: .55; }
.v3d .deck3d { fill: rgba(127,127,127,.08); stroke: var(--line); }
.v3d .wl3d { fill: none; stroke: var(--water, #4aa3c7); stroke-width: 2; }
.v3d .box3d polygon { stroke: rgba(0,0,0,.45); stroke-width: .6; fill: var(--accent, #d6a284); }
.v3d .box3d .f-top { fill-opacity: .95; } .v3d .box3d .f-right { fill-opacity: .7; } .v3d .box3d .f-front { fill-opacity: .82; }
.v3d .box3d.k-container20 polygon, .v3d .box3d.k-container40 polygon { fill: #4f8fc0; }
.v3d .box3d.k-bulk polygon { fill: #a58b62; } .v3d .box3d.k-vehicle polygon { fill: #6aa57a; } .v3d .box3d.k-machine polygon { fill: #c07a4f; }
.v3d .box3d.sel polygon { stroke: var(--accent, #d6a284); stroke-width: 2; }
