:root {
  /* White and red, after the classic Beechcraft livery. */
  --red: #c8102e; --red-dark: #9e0b23; --red-tint: #fdecee;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f7f7f8; --text: #1a1a1d; --muted: #61636b; --border: #e3e3e7;
  --accent: var(--red); --accent-text: #ffffff;
  --ok-bg: #e4f3e8; --ok: #1b6b36; --soon-bg: #fff3d6; --soon: #8a5800;
  --over-bg: #c8102e; --over: #ffffff; --none-bg: #eeeff2; --none: #4c5059;
  --notice-bg: #f7f7f8;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
main > h1:first-child, .page-head h1, .hero h1 { border-left: 4px solid var(--red); padding-left: .6rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--red); font-weight: 600; }

.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center;
  padding: .8rem 16px; background: var(--red); color: #fff;
  box-shadow: inset 0 -4px 0 var(--red-dark); }
.brand { font-weight: 800; color: #fff; text-decoration: none; letter-spacing: .02em; text-transform: uppercase; font-size: .95rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.topbar nav a { text-decoration: none; color: rgba(255,255,255,.85); }
.topbar nav a:hover { color: #fff; text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.brand-logo { display: inline-flex; align-items: center; background: #fff; border-radius: 6px; padding: 3px 8px; }
.brand-logo img { height: 26px; width: auto; max-width: 160px; display: block; }
.brand-logo.preview { border: 1px solid var(--border); padding: 8px 12px; }
.brand-logo.preview img { height: 40px; max-width: 280px; }
.topbar .signout { display: inline; margin: 0; }
.topbar .signout button { color: rgba(255,255,255,.85); font-size: inherit; }
.topbar .signout button:hover { color: #fff; }
.login-card { max-width: 360px; margin: 3rem auto; display: flex; flex-direction: column; gap: 1rem; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
.topbar .pill.alert { background: #fff; color: var(--red); }
.topbar nav { align-items: center; }
.topbar nav a.current { color: #fff; font-weight: 600; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; color: rgba(255,255,255,.85); display: inline-flex; align-items: center; gap: .3rem; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: .4em; height: .4em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-.15em) rotate(45deg); margin-left: .15rem; }
.menu[open] summary::after { transform: translateY(.1em) rotate(-135deg); }
.menu summary:hover, .menu[open] summary, .menu.active summary { color: #fff; }
.menu.active summary { font-weight: 600; }
.menu-panel { position: absolute; top: calc(100% + .55rem); left: -.75rem; z-index: 20; min-width: 14rem;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--red); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: .35rem 0; display: flex; flex-direction: column; }
.topbar .menu-panel a, .topbar .menu-panel .signout button { color: var(--text); padding: .45rem 1rem; text-decoration: none;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; text-align: left; width: 100%; font-weight: 400; }
.topbar .menu-panel a:hover, .topbar .menu-panel .signout button:hover { background: var(--red-tint); color: var(--red-dark); text-decoration: none; }
.topbar .menu-panel a.current { color: var(--red); font-weight: 600; }
.topbar .menu-panel .signout { display: block; border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .3rem; }
.topbar .menu-panel .pill.alert { background: var(--red); color: #fff; }
@media (max-width: 600px) {
  .menu-panel { position: fixed; left: 16px; right: 16px; top: auto; margin-top: .55rem; min-width: 0; }
}
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 3rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.hero-plane { flex: 1 1 260px; max-width: 380px; width: 100%; height: auto; align-self: center; mix-blend-mode: multiply; }
@media print { .hero-plane { display: none; } }
.tach-card { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--red); border-radius: 10px; padding: 1rem; min-width: 240px; }
.tach-card .big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
form.inline { display: flex; gap: .5rem; margin-top: .6rem; }
form.inline input { width: 9rem; }

.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-top: 1.25rem; }
.count { display: flex; flex-direction: column; padding: .75rem 1rem; border-radius: 10px; text-decoration: none; }
.count .n { font-size: 1.6rem; font-weight: 700; }
.count.overdue { background: var(--over-bg); color: var(--over); }
.count.due_soon { background: var(--soon-bg); color: var(--soon); }
.count.no_record { background: var(--none-bg); color: var(--none); }
.count.ok { background: var(--ok-bg); color: var(--ok); }
.count.overdue { background: var(--red); color: #fff; }
.count.zero { background: var(--surface-2); color: var(--muted); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.due_soon { background: var(--soon-bg); color: var(--soon); }
.badge.overdue { background: var(--over-bg); color: var(--over); }
.badge.complied { background: var(--ok-bg); color: var(--ok); }
.badge.no_record, .badge.no_interval { background: var(--none-bg); color: var(--none); }
.flag { font-size: .7rem; border: 1px solid var(--border); color: var(--muted); border-radius: 4px; padding: 0 .3rem; margin-left: .3rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--surface-2); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tr.inactive td { opacity: .6; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.stats .val { font-size: 1.1rem; font-weight: 600; margin-top: .2rem; }
.notes { white-space: pre-wrap; }
.notice { background: var(--notice-bg); border-radius: 8px; padding: .6rem .9rem; }
.error { background: var(--red-tint); color: var(--red-dark); border-radius: 8px; padding: .6rem .9rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .45rem .6rem; width: 100%; }
label.check input { width: auto; }
.actions { display: flex; gap: .75rem; align-items: center; }
button, .button { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-text); border: none;
  border-radius: 6px; padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-block; }
.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; }
button.link.danger, .danger { color: var(--red); }
button:hover, .button:hover { background: var(--red-dark); }
.button.secondary:hover, button.link:hover { background: transparent; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; }

.pill { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; font-size: .75rem; font-weight: 700;
  text-align: center; background: var(--none-bg); color: var(--none); }
.ad-alert { display: block; margin-top: 1rem; padding: .75rem 1rem; border-radius: 10px; background: var(--red-tint);
  color: var(--red-dark); text-decoration: none; border: 1px solid #f5c2ca; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--border); margin: 1rem 0; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.ad { margin-bottom: .75rem; }
.serial-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 1rem; }
.bulk { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.25rem 0 1rem; }
.chip { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .85rem; }
.chip.active { border-color: var(--red); color: var(--red); font-weight: 600; background: var(--red-tint); }
.serial-check { padding: .45rem .7rem; border-radius: 6px; border-left: 4px solid; }
.serial-check.applies, .serial-check.equipment { background: var(--red-tint); border-color: var(--red); }
.serial-check.engine { background: var(--soon-bg); border-color: #d9a400; }
.serial-check.no_match { background: var(--ok-bg); border-color: var(--ok); }
.serial-check.excluded { background: var(--ok-bg); border-color: var(--ok); }
.serial-check.review { background: var(--surface-2); border-color: var(--border); }
.ad header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.ad h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.ad p { margin: .6rem 0; }
.applicability { white-space: pre-wrap; background: var(--surface-2); padding: .6rem .8rem; border-radius: 6px; }
.ad-actions { flex-wrap: wrap; margin-top: .5rem; }
.inline-note { display: flex; gap: .5rem; flex: 1; min-width: 260px; }
.inline-note input { flex: 1; }
.secondary-btn { background: transparent; color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.secondary-btn:hover { background: var(--surface-2); }
.danger-zone { margin-top: 2rem; }

.ad-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 .5rem; }
.ad-summary a { padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .9rem; }
.ad-summary a.attn { border-color: var(--red); color: var(--red); background: var(--red-tint); }
.ad-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; white-space: nowrap; }
.ad-table td { vertical-align: top; }
.signoff { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.5rem; margin: 2.5rem 0 1rem; }
.signoff div { border-top: 1px solid var(--text); padding-top: .3rem; font-size: .8rem; color: var(--muted); }
@media (max-width: 600px) { .signoff { grid-template-columns: 1fr; } }

@page { margin: 14mm 12mm; }

@media print {
  .topbar, .no-print { display: none; }
  .ad-summary a { border-color: #999; }
  .ad-section h2 { break-after: avoid; }
  .ad-table { font-size: 9.5pt; }
  .ad-table thead { display: table-header-group; }
  .ad-table tr, .signoff { break-inside: avoid; }
  .ad-table a { color: inherit; text-decoration: none; }
  .badge.overdue { border: 1px solid #000; }
  body { background: #fff; color: #000; }
  .table-wrap { border: none; }
  main { padding: 0; }
}

.equip-card { margin-bottom: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.equip-head { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.equip-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.equip-actions { display: flex; gap: .6rem; align-items: center; border-top: 1px solid var(--border); padding-top: .6rem; }
.equip-actions .spacer { flex: 1; }
.equip-actions label.check { font-size: .85rem; }
.danger-btn { color: var(--red); border-color: #f0b8c0; }
.danger-btn:hover { background: var(--red-tint); }
.backup-card > p:first-child { margin-top: 0; }
@media (max-width: 760px) { .equip-row { grid-template-columns: 1fr 1fr; } }
.record { background: var(--surface-2); border-left: 4px solid var(--border); padding: .45rem .7rem; border-radius: 6px; }
.serial-check.not_on_record { background: var(--ok-bg); border-color: var(--ok); }
.log-entry { margin-bottom: .6rem; }
.log-entry header, .suggest header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.log-entry p { margin: .4rem 0; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.chip.linked { border-color: var(--ok); color: var(--ok); }
.chip.linked { display: inline-flex; align-items: center; gap: .35rem; }
.chip.linked a { color: inherit; text-decoration: none; }
.chip.linked form.inline { margin: 0; }
.chip.linked button.link { color: inherit; font-size: 1rem; line-height: 1; }
.link-item { margin-top: .4rem; }
.link-item summary { cursor: pointer; color: var(--accent); width: fit-content; }
.link-item form.inline { flex-wrap: wrap; }
.link-item select { flex: 1; min-width: 200px; max-width: 28rem; }
.link-item p { margin: .3rem 0 0; }
.uncertain { background: var(--soon-bg); color: var(--soon); border-radius: 6px; padding: .3rem .6rem; margin: .4rem 0 0; }
.suggest { margin-bottom: 1rem; }
.suggest h3 { margin: 0; font-size: 1.05rem; }
.suggest table td { vertical-align: top; }
.inbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.inbox-item { display: flex; flex-direction: column; gap: .35rem; padding: .6rem; }
.inbox-item img { width: 100%; height: 180px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.inbox-item.processed img, .inbox-item.discarded img { opacity: .6; }

/* Annual inspection scope */
.annual-when { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; align-items: flex-end; border-top: 4px solid var(--red); }
.annual-when .big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.annual-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-left: auto; }
.annual-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }
.annual-form input { width: 10rem; }
.annual-line { margin: 1.25rem 0 0; }
.squawk-form { margin-top: .75rem; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin-right: .6rem; }
tr.resolved td { opacity: .6; }
.print-only { display: none; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; }
.section-head h2 { margin-bottom: .5rem; }
.section-head label.check { display: flex; gap: .4rem; font-size: .85rem; }
@media print {
  .print-skip { display: none; }
  .print-only { display: table-cell; }
  .scope-table { font-size: 9.5pt; }
  .scope-table thead { display: table-header-group; }
  .scope-table tr, .annual-when { break-inside: avoid; }
  .scope-table a { color: inherit; text-decoration: none; }
  .scope-table th.print-only { width: 18%; }
  .scope-table td div { white-space: nowrap; }
  .scope-table td > .muted.small { white-space: normal; }
  h2 { break-after: avoid; }
  .counts { display: none; }
  .annual-when { border: 1px solid #999; border-top: 3px solid #000; padding: .5rem .8rem; }
}

/* Borescope */
.cyl-links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 0; }
.cyl-links .label { margin-right: .25rem; }
.cyl-links .button { padding: .3rem .7rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; }
.photo { margin: 0; padding: .5rem; display: flex; flex-direction: column; gap: .45rem; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; background: var(--surface-2); }
.photo figcaption { display: flex; flex-direction: column; gap: .3rem; }
.photo-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.photo-edit summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.photo-edit form { margin-top: .5rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.stack label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.badge.cond-good { background: var(--ok-bg); color: var(--ok); }
.badge.cond-monitor { background: var(--soon-bg); color: var(--soon); }
.badge.cond-action { background: var(--over-bg); color: var(--over); }

/* Oil analysis */
.oil-table td.num, .oil-table th.num { text-align: right; }
.oil-table .group-row td { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: .35rem; padding-bottom: .35rem; }
.oil-table th .small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.oil-table td.up { color: var(--red); font-weight: 600; }
.spark { color: var(--red); display: block; }
fieldset.elements { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem 1rem; margin: 0; }
fieldset.elements legend { font-weight: 600; padding: 0 .3rem; }
fieldset.elements p { margin: 0 0 .75rem; }
.element-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem .9rem; }
@media print {
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .photo { break-inside: avoid; }
  .oil-table { font-size: 9pt; }
}
.read-report { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: .5rem; border-top: 3px solid var(--red); }
.read-report > div { flex: 1 1 260px; }
.read-report p { margin: .2rem 0 0; }
.or-manual { margin: .75rem 0 .5rem; }
fieldset.history label.check { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin: .3rem 0; }

/* Mechanic View */
.mode-pill { background: #fff; color: var(--red); font-size: .75rem; font-weight: 700; border-radius: 999px; padding: .1rem .6rem; }
body.mechanic form[method="post"]:not(.signout) { display: none; }  /* backup to the server's own refusal */
.mech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.mech-card { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: var(--text); }
.mech-card:hover { border-color: var(--red); }
.mech-card strong { color: var(--red); }
.issue-list { padding-left: 1.2rem; margin: .25rem 0; }
.issue-list li { margin-bottom: .4rem; }
table .group-row td { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
