/* Flight Ops Logbook — "whiteboard and ink": white board, cobalt rules, tabular figures. */

:root {
    --ground: #EDF0F4;
    --surface: #FFFFFF;
    --tint: #F4F7FC;
    --tint-strong: #E8EEF9;
    --ink: #0F1B2D;
    --ink-2: #46546A;
    --ink-3: #5B6880;
    --mute: #8794A8;
    --rule: #D5DBE5;
    --rule-strong: #B5C3DF;
    --accent: #1B3F8B;
    --accent-dark: #0F2A66;
    --navy: #0F1B2D;
    --ok: #0B5D44;
    --ok-bg: #DDF3EA;
    --warn: #8A4B00;
    --warn-bg: #FDECCF;
    --warn-fill: #B45309;
    --bad: #A11D12;
    --bad-bg: #FBE0DC;
    --none-bg: #E6EAF0;
    --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --cond: 'IBM Plex Sans Condensed', 'Arial Narrow', 'IBM Plex Sans', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 400 15px/1.4 var(--sans);
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, p { margin: 0; }
b { font-weight: 600; }

.mono { font-family: var(--mono); }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }
.strong { font-weight: 600; }
.dim { color: var(--mute); }
.sub { font-size: 13px; color: var(--ink-2); }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.note { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.note.warn, .warn { color: var(--warn); }
.note.over, .over { color: var(--bad); }
.print-only { display: none; }
/* Parts of a form that do not apply (ground run, ferry registration), whatever their own display is. */
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #8FB4FF; outline-offset: 2px; }

/* ---------- app bar ---------- */

.appbar { background: var(--navy); color: #FFFFFF; }
.appbar-inner {
    max-width: 1440px; margin: 0 auto; padding: 0 32px; min-height: 64px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 32px;
}
.brand {
    display: flex; align-items: center; gap: 12px; color: #FFFFFF; text-decoration: none;
    font: 700 20px var(--cond); letter-spacing: 0.06em; text-transform: uppercase;
}
.brand:hover { color: #FFFFFF; }
.mainnav { display: flex; flex-wrap: wrap; gap: 4px; flex-grow: 1; }
.mainnav a {
    display: inline-flex; align-items: center; gap: 8px; min-height: 61px; padding: 0 14px;
    color: #C5CEDC; text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent;
}
.mainnav a:hover { color: #FFFFFF; }
.mainnav a[aria-current="page"] { color: #FFFFFF; border-bottom-color: #8FB4FF; }
.mainnav .nav-icon { display: none; }
.appbar-right { display: flex; align-items: center; gap: 16px; padding: 8px 0; margin-left: auto; }
.clock { font: 400 14px var(--mono); color: #C5CEDC; white-space: nowrap; }
.appbar-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; padding: 0 12px; background: transparent; color: #FFFFFF;
    border: 1.5px solid #5B6880; border-radius: 6px; font: 600 14px var(--sans); cursor: pointer;
}
.appbar-btn svg { display: none; }
.appbar-btn:hover { border-color: #C5CEDC; }

/* ---------- page frame ---------- */

.page {
    max-width: 1440px; margin: 0 auto; padding: 28px 32px 48px;
    display: flex; flex-direction: column; gap: 24px;
}
/* Wrappers of parts that reload live keep the spacing of the page. */
.page > div[data-live] { display: contents; }
/* A logbook line that another user just saved. */
.is-new, .is-new > td { animation: live-new 6s ease-out; }
@keyframes live-new { from { background-color: var(--warn-bg); } }
@media (prefers-reduced-motion: reduce) {
    .is-new, .is-new > td { animation: none; background-color: var(--tint-strong); }
}
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.pagehead h1 {
    font: 700 40px/1.05 var(--cond); letter-spacing: 0.02em; text-transform: uppercase;
}
.lead { margin-top: 6px; color: var(--ink-2); }
.crumbs { font-size: 14px; color: var(--ink-2); margin-bottom: -8px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.unlocked { font-size: 14px; font-weight: 600; color: var(--ok); }
.flash {
    padding: 12px 16px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); font-weight: 600;
}

/* ---------- buttons, inputs ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; background: var(--surface); color: var(--ink);
    border: 1.5px solid var(--mute); border-radius: 6px; font: 600 15px var(--sans);
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { color: var(--ink); border-color: var(--ink-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFFFF; }
.btn-danger { color: var(--bad); border-color: #D9A29C; }
.btn-danger:hover { color: var(--bad); border-color: var(--bad); }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn-sm { padding: 0 14px; font-size: 14px; color: var(--accent); border-color: var(--rule-strong); }
.btn-icon { width: 44px; padding: 0; }
.btn.is-disabled { background: var(--tint); border-color: #C5CEDC; color: var(--mute); cursor: default; }

label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select {
    width: 100%; height: 44px; padding: 0 12px; background: var(--surface); color: var(--ink);
    border: 1.5px solid var(--mute); border-radius: 6px; font: 500 16px var(--sans);
}
.select { width: auto; font-weight: 600; font-size: 15px; }
.input.mono { font-family: var(--mono); }
.input.strong { font-weight: 600; }
.textarea { height: auto; padding: 10px 12px; font-weight: 400; line-height: 1.4; resize: vertical; }
.input.input-validation-error { border-color: var(--bad); }
.readout {
    height: 44px; display: flex; align-items: center; padding: 0 12px; border-radius: 6px;
    background: var(--tint); font-weight: 600; font-size: 16px;
}
.field-error { display: block; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--bad); }
.field-validation-valid, .validation-summary-valid { display: none; }
.errors {
    padding: 12px 16px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); font-weight: 600;
}
.errors ul { margin: 0; padding-left: 18px; }
.hint { font-size: 13px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 64px;
    margin: 0; padding: 0 16px; background: var(--surface); color: var(--ink);
    border: 1.5px solid var(--mute); border-radius: 6px; font-size: 15px; cursor: pointer;
}
/* A chip with a code and its spelled-out name underneath. */
.chip-named { flex-direction: column; align-items: flex-start; gap: 1px; min-height: 52px; padding: 6px 14px; line-height: 1.2; }
.chip-named span { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.chips input:checked + .chip { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.chips input:checked + .chip-named span { color: #DCE6FA; }
.chips input:focus-visible + .chip { outline: 3px solid #8FB4FF; outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; cursor: pointer; font-size: 15px; font-weight: 400; color: var(--ink); }
.check input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); }

/* ---------- panels, cards ---------- */

.panel {
    background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
    padding: 20px 24px; display: flex; flex-direction: column; gap: 16px;
}
.panel h2 { font-size: 17px; font-weight: 600; }
.panel.empty { color: var(--ink-2); }
.fields { display: flex; flex-wrap: wrap; gap: 16px; }
.fields-end { align-items: flex-end; gap: 16px 24px; }
.field { flex: 1 1 150px; min-width: 0; }
.field-2 { flex: 2 1 260px; }
.field-3 { flex: 3 1 320px; }
.field-narrow { flex: 0 1 130px; }
.field-fixed { flex: 0 1 200px; }
.field-grow { flex: 3 1 360px; }
.field-chips { flex: 0 0 auto; }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.card-accent { border: 2px solid var(--accent); }
.card-head {
    padding: 14px 20px; background: var(--tint);
    font: 700 15px var(--cond); letter-spacing: 0.06em; text-transform: uppercase;
}
.rows { margin: 0; }
.rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 20px; border-top: 1px solid var(--rule); }
.rows dt { font-size: 13px; color: var(--ink-2); }
.rows dd { margin: 0; text-align: right; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.rows-change dt { font-size: 15px; font-weight: 600; color: var(--ink); }
.rows-change dd { font-weight: 400; }
.rows-change .was { color: var(--ink-2); }
.rows-change .lg { font-size: 20px; }

.split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.split-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.split-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.calc { display: flex; flex-wrap: wrap; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.calc > div { flex: 1 1 220px; background: var(--tint); padding: 14px 16px; }
.calc .label { margin-bottom: 0; }
.calc-value { display: block; margin-top: 6px; font: 600 28px var(--mono); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.form-note { flex: 1 1 280px; font-size: 13px; color: var(--ink-2); }

/* ---------- status badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px;
    font-size: 13px; font-weight: 600; white-space: nowrap;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-hold { background: var(--warn-bg); color: var(--warn); }
.badge-aog { background: var(--bad-bg); color: var(--bad); }
/* Maintenance due: amber within the tolerance, red once the tolerance is used up. */
.badge-due { background: var(--warn-bg); color: var(--warn); }
.badge-overdue { background: var(--bad-bg); color: var(--bad); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.board .badges { flex-direction: column; align-items: flex-start; }
.badge-none { background: var(--none-bg); color: var(--ink-2); }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; font-size: 13px; color: var(--ink-2); }
.legend-note { flex: 1 1 360px; }

/* ---------- due next ---------- */

.due { display: flex; flex-wrap: wrap; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.due-label {
    flex: 0 1 132px; background: var(--tint); padding: 16px 20px; display: flex; align-items: center;
    font: 700 14px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2);
}
.due-item { flex: 1 1 300px; background: var(--surface); padding: 14px 20px; display: flex; align-items: center; gap: 16px; }
.due-value { font: 600 26px var(--mono); white-space: nowrap; }
.due-title { font-weight: 600; text-wrap: balance; }
.due-sub { font-size: 13px; color: var(--ink-2); }

/* ---------- status board ---------- */

.board-wrap { background: var(--surface); border: 2px solid var(--accent); border-radius: 10px; overflow-x: auto; }
.board { width: 100%; min-width: 1340px; border-collapse: collapse; }
.board thead th {
    padding: 14px 12px; background: var(--tint); text-align: left; white-space: nowrap;
    font: 700 15px var(--cond); letter-spacing: 0.06em; text-transform: uppercase;
}
.board .unit { font: 500 11px var(--mono); letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.board tbody th, .board tbody td {
    height: 96px; padding: 12px; border-top: 2px solid var(--accent); text-align: left; vertical-align: middle; font-weight: 400;
}
.board th + th, .board th + td, .board td + td { border-left: 1px solid var(--accent); }
.board .reg {
    display: inline-flex; align-items: center; min-height: 44px;
    font: 700 30px/1 var(--cond); letter-spacing: 0.02em; color: var(--ink);
}
.board a.reg { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-color: #8FA6D6; }
.board a.reg:hover { text-decoration-color: var(--accent); }
.board .loc { font: 600 20px var(--mono); }
.board .date { font: 500 16px var(--mono); margin-bottom: 2px; }
.board .big { font: 600 30px/1 var(--mono); }
.board .min { font-size: 16px; font-weight: 500; color: var(--ink-3); }
.board .maint { font-family: var(--mono); white-space: nowrap; }
.board .maint-at { font-size: 17px; font-weight: 600; }
.board .maint-date { font-size: 14px; color: var(--ink-2); }
.board .bar { height: 6px; margin: 6px 0; border-radius: 3px; background: #E1E6EE; overflow: hidden; }
.board .bar-fill { height: 100%; background: var(--accent); }
.board .bar-fill.warn { background: var(--warn-fill); }
.board .bar-fill.over { background: var(--bad); }
.board .kicker { font-size: 11px; }
.board .hold { font-weight: 600; }
.board .c-aircraft { white-space: nowrap; }
.board tr.is-empty .loc, .board tr.is-empty .date, .board tr.is-empty .big { color: var(--mute); }

/* ---------- logbook ---------- */

.ac-title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.pagehead .reg-title { font: 700 56px/1 var(--cond); letter-spacing: 0.02em; text-transform: none; }
.ac-type { font-weight: 600; font-size: 17px; }

.stats { display: flex; flex-wrap: wrap; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.stat { flex: 1 1 130px; background: var(--surface); padding: 16px 20px; }
.stat-wide { flex: 1 1 220px; }
.stat-wider { flex: 2 1 220px; }
.stat-big { font: 600 28px var(--mono); margin-top: 4px; }
.stat-mid { font: 600 20px var(--mono); margin: 8px 0 4px; white-space: nowrap; }
.stat-light { font-weight: 400; font-size: 15px; color: var(--ink-2); }
.stat-text { font-weight: 600; font-size: 17px; margin: 8px 0 4px; }

.book { background: var(--surface); border: 2px solid var(--accent); border-radius: 10px; overflow: hidden; }
.book-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 14px 20px; }
.book-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; color: var(--ink-2); }
.book-title h2 { font: 700 24px var(--cond); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); }
.pager { display: flex; align-items: center; gap: 8px; }
.pager-label { padding: 0 8px; font: 400 14px var(--mono); }
.book-scroll { overflow-x: auto; border-top: 2px solid var(--accent); }
.book-note { padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }
.book-filter { padding: 0 20px 14px; font-weight: 600; }
.log .none { height: 72px; text-align: center; color: var(--ink-2); }

/* filter of the logbook: closed until it is needed */
.filter { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.filter summary {
    display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px;
    font-weight: 600; cursor: pointer; list-style: none;
}
.filter summary::-webkit-details-marker { display: none; }
.filter-count { padding: 2px 8px; border-radius: 4px; background: var(--tint-strong); color: var(--accent); font-size: 13px; }
.filter-chevron { margin-left: auto; color: var(--ink-2); }
.filter[open] .filter-chevron { transform: rotate(180deg); }
.filter[open] summary { border-bottom: 1px solid var(--rule); }
.filter-form { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 20px; }
.filter-form select.input { font-weight: 500; }

.log { width: 100%; min-width: 1300px; border-collapse: collapse; font-size: 14px; }
.log th, .log td { padding: 8px; text-align: left; vertical-align: middle; }
.log th + th, .log td + td { border-left: 1px solid var(--rule); }
.log thead th {
    background: var(--tint); font-size: 12px; font-weight: 600; line-height: 1.3; vertical-align: bottom;
    border-left-color: var(--rule-strong);
}
.log thead .t-group { text-align: center; border-bottom: 1px solid var(--rule-strong); }
.log tbody td, .log tfoot td { height: 52px; border-top: 1px solid var(--rule); }
.log .t-right, .log .num { text-align: right; }
.log .num { font-family: var(--mono); white-space: nowrap; }
.log .num.strong { font-weight: 600; }
.log td.mono { font-size: 14px; white-space: nowrap; }
.log .duty { font-size: 12px; color: var(--ink-2); }
.log .serial { white-space: nowrap; }
.log .serial .mono { font-size: 14px; }
.log .remark { font-size: 13px; min-width: 240px; }
.log .carry td { height: auto; padding: 10px 8px; background: #FBFCFE; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.log .carry .num { font-size: 14px; color: var(--ink); }
.log tbody .carry td, .log tfoot tr:first-child td { border-top: 2px solid var(--accent); }
.log .next td + td { padding: 0; background: #F6F9FE; }
.log .next a { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 12px; font-weight: 600; text-decoration: none; }
.tag { display: inline-block; margin-right: 6px; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.tag-defect { background: var(--warn-bg); color: var(--warn); }
.tag-maint { background: var(--tint-strong); color: var(--accent); }
.tag-camo { margin-left: 6px; background: var(--ok-bg); color: var(--ok); }
.tag-failed { margin-left: 6px; background: var(--bad-bg); color: var(--bad); }
.edit-link { margin-left: 8px; font-weight: 600; }
.log-cards { display: none; }

/* ---------- aircraft setup, login ---------- */

.split-reverse .fleet-list { flex: 1 1 320px; min-width: 0; }
.fleet-new, .fleet-row {
    display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 12px 8px 20px;
    border-top: 1px solid var(--rule);
}
.fleet-new { font-weight: 600; text-decoration: none; }
.fleet-row { justify-content: space-between; }
.fleet-new.is-current, .fleet-row.is-current { background: var(--tint-strong); }
.fleet-reg { font: 700 20px/1.1 var(--cond); letter-spacing: 0.02em; }

.login { max-width: 480px; }
.login-center { width: 100%; margin: 6vh auto 0; }
.login-title { font: 700 32px/1.1 var(--cond); letter-spacing: 0.02em; text-transform: uppercase; }
.login form { display: flex; flex-direction: column; gap: 16px; }
.login .field { flex: none; }

/* ---------- office display (/display): sizes follow the screen width ---------- */

html.display { font-size: max(8px, calc(100vw / 120)); }
html.display body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; font-size: 1rem; }
.display-head {
    background: var(--navy); color: #FFFFFF; padding: 0 2rem; min-height: 4.75rem;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 2rem;
}
.display-title { display: flex; align-items: baseline; gap: 1.25rem; }
.display-title h1 { font: 700 2.5rem/1 var(--cond); letter-spacing: 0.06em; text-transform: uppercase; }
.display-title span { font-size: 1.125rem; color: #C5CEDC; }
.display-clock { display: flex; align-items: baseline; gap: 1.75rem; font-family: var(--mono); color: #C5CEDC; }
.display-clock b { font-size: 2.25rem; font-weight: 600; color: #FFFFFF; }
.display-date { font-size: 1.125rem; }
.display-main { flex: 1; min-height: 0; padding: 1.25rem 2rem; display: flex; flex-direction: column; }
.display-main > div { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1rem; }

.display .due { border-radius: 0.625rem; }
.display .due-label { flex-basis: 9.5rem; padding: 0.875rem 1.25rem; font-size: 1.0625rem; }
.display .due-item { flex-basis: 24rem; padding: 0.75rem 1.5rem; gap: 1.25rem; }
.display .due-value { font-size: 1.875rem; }
.display .due-title { font-size: 1.125rem; }
.display .due-sub { font-size: 0.9375rem; }

.display .board-wrap { flex: 1; min-height: 0; border-radius: 0.625rem; overflow: hidden; }
.display .board { min-width: 0; height: 100%; table-layout: fixed; }
.display .board thead th { padding: 1rem 0.875rem; font-size: 1.0625rem; }
.display .board .unit { font-size: 0.75rem; }
.display .board tbody th, .display .board tbody td { height: auto; padding: 0.5rem 0.875rem; }
.display .board .reg { min-height: 0; font-size: 2.375rem; }
.display .board .sub, .display .board .note { font-size: 0.9375rem; }
.display .board .badge { padding: 0.4375rem 0.75rem; font-size: 1rem; }
.display .board .badge .dot { width: 0.5625rem; height: 0.5625rem; }
.display .board .loc { font-size: 1.625rem; }
.display .board .date { font-size: 1.25rem; }
.display .board .big { font-size: 2.375rem; }
.display .board .min { font-size: 1.25rem; }
.display .board .maint-at { font-size: 1.375rem; }
.display .board .maint-date { font-size: 1.0625rem; }
.display .board .bar { height: 0.5rem; margin: 0.375rem 0; }
.display .board .kicker { font-size: 0.75rem; }
.display .board .hold { font-size: 1.125rem; }
.display .board th:nth-child(1) { width: 12.4%; }
.display .board th:nth-child(2) { width: 10.4%; }
.display .board th:nth-child(3) { width: 6.5%; }
.display .board th:nth-child(4) { width: 9.2%; }
.display .board th:nth-child(5) { width: 8.1%; }
.display .board th:nth-child(6) { width: 7%; }
.display .board th:nth-child(7) { width: 13%; }
.display .board th:nth-child(8) { width: 9.7%; }
.display .board th:nth-child(9) { width: 8.7%; }
.display .legend { font-size: 0.9375rem; }
.display .legend .badge { padding: 0.375rem 0.75rem; font-size: 0.9375rem; }
.display .legend-note { text-align: right; }

/* ---------- phones: tab bar, cards instead of wide tables, one column ---------- */

@media screen and (max-width: 720px) {
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

    /* app bar: brand and UTC time on top, navigation as a tab bar at the bottom */
    .appbar-inner { padding: 0 16px; min-height: 52px; flex-wrap: nowrap; justify-content: space-between; gap: 12px; }
    .brand { gap: 10px; font-size: 16px; }
    .brand svg { width: 22px; height: 22px; }
    .appbar-right { gap: 10px; padding: 0; }
    .clock { font-size: 13px; }
    .clock-date { display: none; }
    .appbar-btn { width: 36px; padding: 0; }
    .appbar-btn svg { display: block; }
    .appbar-btn span { display: none; }
    /* Two buttons (lock + sign out) leave no room for the time. */
    .appbar-right.has-two .clock { display: none; }

    .mainnav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--navy); border-top: 1px solid #22324D;
    }
    .mainnav a {
        flex-direction: column; justify-content: center; gap: 3px; min-height: 60px; padding: 6px 4px 4px;
        font-size: 12px; line-height: 1.1; text-align: center;
        border-bottom: 0; border-top: 3px solid transparent;
    }
    .mainnav a[aria-current="page"] { border-top-color: #8FB4FF; }
    .mainnav .nav-icon, .mainnav .nav-lock { display: block; width: 22px; height: 22px; }
    .mainnav .nav-more { display: none; }

    /* page frame */
    .page { padding: 16px 16px 32px; gap: 16px; }
    .pagehead { gap: 12px; }
    .pagehead h1 { font-size: 28px; }
    .pagehead .reg-title { font-size: 40px; }
    .pagehead > .btn, .pagehead > div { width: 100%; }
    .actions { gap: 8px; }
    .actions .select { flex: 1 1 100%; }
    .actions .btn { flex: 1 1 0; }
    .crumbs { margin-bottom: -4px; }
    .select { font-size: 16px; }

    .panel { padding: 16px; gap: 14px; }
    .calc > div { flex-basis: 140px; padding: 12px 14px; }
    .calc-value { font-size: 24px; }
    .form-actions { gap: 10px; }
    .form-actions .btn { flex: 1 1 0; }
    .form-actions .btn-primary { flex-basis: 100%; }
    .form-note { flex-basis: 100%; }
    .rows > div { padding: 10px 16px; }
    .card-head { padding: 12px 16px; }

    /* one column; on the entry form the preview moves right above the save button */
    .split { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 16px; }
    .split > *, .split-reverse .fleet-list { flex: none; width: 100%; }
    form.split > .split-main { display: contents; }
    form.split > .split-side { order: 1; }
    form.split .form-actions { order: 2; }
    .fleet-new, .fleet-row { min-height: 56px; padding-left: 16px; }

    /* due next */
    .page .due-label { flex: 1 1 100%; padding: 10px 16px; }
    .page .due-item { flex: 1 1 100%; padding: 12px 16px; gap: 14px; }
    .page .due-value { font-size: 22px; min-width: 88px; }

    /* status board: one card per aircraft */
    .page .board-wrap { background: none; border: 0; border-radius: 0; overflow: visible; }
    .page .board, .page .board tbody { display: block; min-width: 0; }
    .page .board thead { display: none; }
    .page .board tr {
        display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px;
        background: var(--surface); border: 2px solid var(--accent); border-radius: 10px; overflow: hidden;
    }
    .page .board tbody th, .page .board tbody td { height: auto; padding: 10px 16px; border: 0; }
    .page .board .c-aircraft { grid-column: 1 / 3; order: 1; padding-top: 12px; }
    .page .board .reg { min-height: 40px; font-size: 28px; }
    .page .board td:nth-child(2) { order: 2; display: flex; justify-content: flex-end; align-items: flex-start; padding-top: 16px; }
    .page .board td:nth-child(3) { order: 3; }
    .page .board td:nth-child(5) { order: 4; }
    .page .board td:nth-child(6) { order: 5; }
    .page .board td:nth-child(4) { order: 6; }
    .page .board td:nth-child(n+7) { order: 7; }
    .page .board td[data-label]:not(:nth-child(2))::before {
        content: attr(data-label); display: block;
        font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2);
    }
    /* location, TSN, LDG side by side */
    .page .board td:nth-child(3), .page .board td:nth-child(5), .page .board td:nth-child(6) {
        padding: 10px 12px 12px 16px; background: var(--tint); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
    }
    .page .board td:nth-child(5), .page .board td:nth-child(6) { border-left: 1px solid var(--rule); }
    .page .board td:nth-child(3)::before, .page .board td:nth-child(5)::before, .page .board td:nth-child(6)::before { margin-bottom: 4px; }
    .page .board .loc { font-size: 20px; }
    .page .board .big { font-size: 22px; }
    .page .board .min { font-size: 14px; }
    /* the rest as label | value lines */
    .page .board td:nth-child(4), .page .board td:nth-child(n+7) {
        grid-column: 1 / -1; display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 12px; align-items: baseline;
    }
    .page .board td:nth-child(4)::before, .page .board td:nth-child(n+7)::before { grid-column: 1; grid-row: 1 / span 4; }
    .page .board td:nth-child(4) > *, .page .board td:nth-child(n+7) > * { grid-column: 2; }
    .page .board td:nth-child(n+7) { border-top: 1px solid var(--rule); }
    .page .board td.is-blank { display: none; }
    .page .board .date { margin-bottom: 0; }
    .page .board .maint-at { font-size: 16px; }
    .page .board .bar { max-width: 220px; }
    .legend-note { flex-basis: 100%; }

    /* logbook */
    .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat { padding: 12px 14px; }
    .stat-wider { grid-column: 1 / -1; }
    .stat-big { font-size: 24px; }
    .stat-mid { font-size: 17px; white-space: normal; }
    .stat-mid .stat-light { display: block; font-size: 14px; }
    .book-head { padding: 12px 16px; }
    .book-title h2 { font-size: 20px; }
    .book-scroll { display: none; }
    .book-note { padding: 12px 16px; }

    .log-cards { display: flex; flex-direction: column; border-top: 2px solid var(--accent); }
    .log-none { padding: 20px 16px; text-align: center; color: var(--ink-2); }
    .book-filter { padding: 0 16px 12px; }
    .filter summary { padding: 0 16px; }
    .filter-form { padding: 14px 16px 16px; }
    .log-carry {
        display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 10px 16px;
        background: #FBFCFE; font-size: 13px; font-weight: 600; color: var(--ink-2);
    }
    .log-carry .mono { font-size: 14px; color: var(--ink); }
    .log-carry + .log-carry { border-top: 1px solid var(--rule); }
    .log-list { margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--accent); }
    .log-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px 14px; border-bottom: 1px solid var(--rule); }
    .lc-head { display: flex; align-items: baseline; gap: 10px; }
    .lc-no { min-width: 28px; font: 600 15px var(--mono); }
    .lc-date { font: 400 14px var(--mono); color: var(--ink-2); }
    .lc-nature { flex: 1; min-width: 0; font-weight: 600; }
    .lc-ft { font: 600 20px var(--mono); }
    .lc-route { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-left: 38px; font: 400 15px var(--mono); }
    .lc-route b { font-weight: 600; }
    .lc-route svg { color: var(--ink-3); }
    .lc-crew { display: flex; flex-wrap: wrap; gap: 2px 14px; padding-left: 38px; font-size: 14px; }
    .lc-crew .duty { font-size: 12px; color: var(--ink-2); }
    .lc-serial { padding-left: 38px; font-size: 14px; }
    .lc-serial b { font: 600 14px var(--mono); }
    .lc-serial .duty { font-size: 12px; color: var(--ink-2); }
    .lc-figs { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding-left: 38px; }
    .lc-figs div { display: flex; align-items: baseline; gap: 6px; }
    .lc-figs dt { font-size: 12px; color: var(--ink-2); }
    .lc-figs dd { margin: 0; font: 500 14px var(--mono); }
    .lc-remark { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-left: 38px; font-size: 13px; }
    .lc-new { margin: 12px 16px; background: #F6F9FE; color: var(--accent); border-color: var(--rule-strong); border-style: dashed; }
    .lc-new + .log-carry { border-top: 2px solid var(--accent); }
    .log-list + .log-carry { border-top: 0; }

    .login { max-width: none; }
}

/* ---------- print: one logbook page ---------- */

@media print {
    /* Landscape on whatever paper the printer has (A4, Letter). A fixed paper size would cut the
       page off on a printer that is set to another one. */
    @page { size: landscape; margin: 10mm; }
    body { background: #FFFFFF; font-size: 11px; }
    .appbar, .no-print { display: none !important; }
    .print-only { display: revert; }
    .page { padding: 0; max-width: none; }
    /* A filtered list can run over several sheets: nothing may clip it. */
    .book { border-width: 1px; border-radius: 0; overflow: visible; }
    .book-scroll { overflow: visible; }
    .book-head { padding: 6px 10px; }
    .book-title h2 { font-size: 18px; }
    .book-filter { padding: 0 10px 6px; }

    /* One page of the logbook (12 lines, two crew members each) and the signature block fit on one sheet. */
    .log { min-width: 0; font-size: 10px; line-height: 1.25; }
    .log th, .log td { padding: 3px 5px; }
    .log thead th { font-size: 10px; }
    .log td.mono, .log .num, .log .remark, .log .carry td, .log .carry .num { font-size: 10px; }
    .log .duty, .tag { font-size: 9px; }
    .log .serial .mono { font-size: 10px; }
    .log tbody td, .log tfoot td { height: 20px; }
    .log .carry td { padding: 4px 5px; }
    .log .remark { min-width: 0; }
    /* Name and duty stay on one line, so a line of the logbook is at most two lines high. */
    .log td > div { white-space: nowrap; }
    .log tr { break-inside: avoid; }

    /* signature block under the printed list */
    .print-sign { display: flex; gap: 12mm; padding: 5mm 6mm 3mm; break-inside: avoid; }
    .print-sign > div { flex: 1; display: flex; flex-direction: column; }
    .print-sign .ps-wide { flex: 2; }
    .ps-line { display: flex; align-items: flex-end; min-height: 7mm; padding-bottom: 1mm; border-bottom: 1px solid #000000; font: 500 12px var(--mono); }
    .ps-label { margin-top: 1.5mm; font-size: 10px; color: var(--ink-2); }
}
