:root {
  color-scheme: light;
  --bg: #f6f3eb;
  --ink: #192d3c;
  --muted: #53616b;
  --line: #dcded5;
  --blue: #244557;
  --tint: #ede7d8;
  --red: #a32c32;
  --amber: #805b14;
  --green: #246045;
  --card: #fffefa;
  --red-bg: #fbeeed;
  --amber-bg: #f7edda;
  --green-bg: #eaf3ed;
  --brass: #806021;
  --header: #19232f;
  --on-header: #f6f3eb;
  --header-muted: #d0d7db;
  --header-brass: #d5bb80;
  --button: #244557;
  --on-button: #fffefa;
  --button-hover: #192d3c;
  --field-line: #82877f;
  --focus: #806021;
  --shadow: 0 4px 18px rgb(25 45 60 / 5%);
  --nav-shadow: 0 -6px 24px rgb(25 45 60 / 6%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101c27;
    --ink: #f4f0e6;
    --muted: #bdc8cf;
    --line: #354653;
    --blue: #d5bb80;
    --tint: #293847;
    --red: #ffb4af;
    --amber: #e5c68a;
    --green: #a2d6b4;
    --card: #192936;
    --red-bg: #402b32;
    --amber-bg: #393326;
    --green-bg: #203a32;
    --brass: #d5bb80;
    --button: #d5bb80;
    --on-button: #172633;
    --button-hover: #e5c68a;
    --field-line: #85959f;
    --focus: #e5c68a;
    --shadow: 0 4px 18px rgb(0 0 0 / 12%);
    --nav-shadow: 0 -6px 24px rgb(0 0 0 / 16%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-block: 100px; }
body {
  margin: 0;
  font: 16px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
a {
  display: inline-block;
  min-width: 44px;
  min-height: 44px;
  padding-block: 8px;
  color: var(--blue);
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
}
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { scroll-margin-block: 100px; }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: calc(10px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: var(--header);
  color: var(--on-header);
  border-bottom: 2px solid var(--header-brass);
}
.brand {
  flex-shrink: 0;
  color: var(--on-header);
  font: 500 24px/1.25 var(--serif);
  text-decoration: none;
  letter-spacing: -.025em;
}
#aircraft-name {
  min-width: 0;
  font-size: 14px;
  color: var(--header-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
main {
  max-width: 740px;
  margin: 0 auto;
  padding: 28px max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left));
  overflow-wrap: break-word;
}
main > * { min-width: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; }
h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.15; margin: 4px 0 22px; letter-spacing: -.025em; text-wrap: balance; }
h2 { display: flex; align-items: center; gap: 12px; font-size: 24px; line-height: 1.3; margin: 30px 0 14px; letter-spacing: -.015em; }
h2::before { content: ""; width: 22px; height: 2px; flex: none; background: var(--brass); }
p { margin: 0 0 16px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: var(--nav-shadow);
  padding: 0 max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
}
.tabs a {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  max-width: 184px;
  min-height: 64px;
  padding: 16px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  border-top: 3px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--brass); border-top-color: var(--brass); background: var(--tint); }
.tabs a:focus-visible { outline-offset: -5px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
a.card { display: block; color: inherit; text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 21px; line-height: 1.3; }
.card h3 a { padding-block: 6px; }
.card p:last-child { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; }
.row > * { min-width: 0; max-width: 100%; }
.row > :last-child { text-align: right; white-space: normal; }
.pill {
  display: inline-block;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
  background: var(--tint);
  color: var(--blue);
}
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.green { background: var(--green-bg); color: var(--green); }
.big { font-size: clamp(28px, 4vw, 36px); font-weight: 600; line-height: 1.25; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 48px;
  max-width: 100%;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid var(--button);
  background: var(--button);
  color: var(--on-button);
  font: inherit;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  overflow-wrap: break-word;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.btn.ghost { background: var(--card); border-color: var(--field-line); color: var(--blue); }
.btn.danger { background: var(--card); color: var(--red); border-color: var(--red); }
.btn.small { min-height: 44px; padding: 10px 14px; font-size: 14px; }
.btn:disabled { cursor: default; border-style: dashed; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.card .actions:last-child { margin-bottom: 0; }
label { display: block; font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--field-line);
  border-radius: 9px;
  font: inherit;
  background: var(--card);
  color: var(--ink);
  accent-color: var(--blue);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { min-height: 120px; resize: vertical; }
input[type="file"] { font-size: 14px; }
input::file-selector-button { min-height: 44px; margin: -4px 12px -4px -5px; padding: 8px 12px; border: 1px solid var(--field-line); border-radius: 6px; background: var(--tint); color: var(--blue); font: inherit; cursor: pointer; }
.inline { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 10px; align-items: end; margin-top: 14px; }
.inline.wide { grid-template-columns: 1fr; }
.inline:has(select) { grid-template-columns: minmax(0, 1fr) 110px; }
.inline select { grid-column: 1; }
.inline[data-form="hours"] { grid-template-columns: minmax(0, 1fr) auto; }
.inline[data-form="hours"] span { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--card); }
th.num, td.num { text-align: right; white-space: nowrap; }
td .muted { font-size: 13px; }
tfoot td { font-weight: 700; border-bottom: 0; padding-top: 16px; }
.over { color: var(--red); font-weight: 700; }
.under { color: var(--green); font-weight: 700; }
.alert, .ok { border-left: 3px solid; padding: 16px 18px; border-radius: 8px; margin: 16px 0; }
.alert { color: var(--ink); border-left-color: var(--red); background: var(--red-bg); }
.ok { color: var(--ink); border-left-color: var(--green); background: var(--green-bg); }
.empty { text-align: center; color: var(--muted); padding: 30px 20px; border: 1px dashed var(--field-line); border-radius: 14px; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; margin-top: 8px; }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; white-space: normal; }
.bar { height: 6px; border-radius: 99px; background: var(--tint); overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--brass); }
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%}.w95{width:95%}.w100{width:100%}
.scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.shared { padding-bottom: 24px; }
.drop-on { outline: 2px dashed var(--brass); outline-offset: 4px; }
.file-input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; }
label.btn { position: relative; margin: 0; font-size: inherit; }
label.btn:focus-within, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, main:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.top a:focus-visible { outline-color: var(--header-brass); }
.check { display: flex; align-items: center; gap: 14px; min-height: 56px; margin: 0 0 12px; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 500; font-size: 16px; box-shadow: var(--shadow); cursor: pointer; }
.check input { width: 24px; height: 24px; min-height: 0; flex: none; }
.check:has(input:checked) { border-color: var(--green); background: var(--green-bg); }

@media (hover: hover) {
  a.card:hover { border-color: var(--brass); }
  a:hover { text-decoration-thickness: 2px; }
  .btn:hover { background: var(--button-hover); border-color: var(--button-hover); }
  .btn.ghost:hover { background: var(--tint); border-color: var(--blue); }
  .btn.danger:hover { background: var(--red-bg); border-color: var(--red); }
  .tabs a:hover { background: var(--tint); }
}

@media (max-width: 420px) {
  .inline, .inline:has(select) { grid-template-columns: minmax(0, 1fr) 96px; }
  .inline .btn, .inline select { grid-column: 1 / -1; }
  .inline[data-form="hours"] .btn { grid-column: auto; }
  .card { padding: 18px; }
}

@media (max-width: 359px) {
  main { padding: 22px max(12px, env(safe-area-inset-right)) 24px max(12px, env(safe-area-inset-left)); }
  .top { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  h1 { font-size: 30px; }
  .big { font-size: 28px; }
  .tabs a { font-size: 12px; padding: 14px 2px; }
  .card { padding: 16px; }
  .inline, .inline:has(select), .inline[data-form="hours"] { grid-template-columns: minmax(0, 1fr); }
  .inline .btn { grid-column: auto; }
  .btn { padding: 10px 12px; }
  th, td { padding: 10px 6px; font-size: 13px; }
  #aircraft-name { display: none; }
}

@media (min-width: 600px) {
  main { max-width: 980px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; align-items: start; padding: 36px max(28px, env(safe-area-inset-right)) 40px max(28px, env(safe-area-inset-left)); }
  main > * { grid-column: 1 / -1; }
  main > .card, main > .check { grid-column: auto; }
  main > :not(.card) + .card:not(:has(+ .card)), main > .card:first-child:not(:has(+ .card)) { grid-column: 1 / -1; }
  .top { padding-left: max(28px, calc((100% - 924px) / 2), env(safe-area-inset-left)); padding-right: max(28px, calc((100% - 924px) / 2), env(safe-area-inset-right)); }
  .tabs a { font-size: 14px; }
  form#main-form { width: 100%; max-width: 600px; }
}

@media (horizontal-viewport-segments: 2) {
  main { max-width: none; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); column-gap: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px) + 32px); }
  .tabs a:nth-child(3) { margin-right: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px)); }
}

@media (max-height: 420px) and (orientation: landscape) {
  .top { position: static; }
  .tabs a { min-height: 48px; padding: 8px 2px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  :root { color-scheme: light; --bg: #fff; --card: #fff; --ink: #19232f; --muted: #43505c; --line: #c4c9cd; --blue: #244557; --brass: #806021; --red: #a32c32; --green: #246045; --red-bg: #fbeeed; --green-bg: #eaf3ed; }
  .top, .tabs, .no-print { display: none !important; }
  body { padding: 0; font-size: 11pt; background: var(--bg); }
  main { display: block; max-width: none; padding: 0; }
  h1 { font-size: 24pt; }
  h2 { font-size: 16pt; break-after: avoid; }
  h2::before { display: none; }
  .scroll { overflow: visible; }
  .card, .check { box-shadow: none; break-inside: avoid; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
  a { min-width: 0; min-height: 0; padding: 0; }
}

.statement-editor { min-width: 1050px; }
.statement-editor input, .statement-editor select { min-width: 130px; }
.statement-editor td:nth-child(4) input { min-width: 220px; }
