/* Drone Locker — equipment accountability UI.
   Sober, high-contrast, square-cornered. Dark by default; light follows the device or the user's choice. */

:root {
  --bg: #0d1014;
  --panel: #151a20;
  --panel-2: #1b2129;
  --line: #2b333d;
  --line-strong: #3a4450;
  --text: #e4e7eb;
  --muted: #8a94a3;
  --accent: #4a86c8;
  --accent-text: #ffffff;
  --in: #3d9be0;
  --out: #e0a526;
  --gtg: #2fb36b;
  --fmc: #2fb36b;
  --nmc: #e5484d;
  --overdue: #f07a2a;
  --res: #6d7fd6;
  --purple: #8b6fd6;
  --on-fill: #0d1014;
  --header-bg: rgba(13, 16, 20, .96);
  --err-text: #ffb4b6;
  --warn-text: #f3d48a;
  --ok-text: #a9e6c4;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eceff2; --panel: #ffffff; --panel-2: #f5f7f9; --line: #d3d9e0; --line-strong: #b9c2cc;
    --text: #12171d; --muted: #56606c; --accent: #1f5fa8; --accent-text: #ffffff;
    --in: #1769aa; --out: #9a5b00; --gtg: #1e7d46; --fmc: #1e7d46; --nmc: #c62828; --overdue: #b9470b;
    --res: #4553b8; --purple: #6b46c1; --on-fill: #ffffff; --header-bg: rgba(255, 255, 255, .96);
    --err-text: #8e1c1c; --warn-text: #6b4100; --ok-text: #14532d; --shadow: 0 6px 24px rgba(18, 23, 29, .14);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eceff2; --panel: #ffffff; --panel-2: #f5f7f9; --line: #d3d9e0; --line-strong: #b9c2cc;
  --text: #12171d; --muted: #56606c; --accent: #1f5fa8; --accent-text: #ffffff;
  --in: #1769aa; --out: #9a5b00; --gtg: #1e7d46; --fmc: #1e7d46; --nmc: #c62828; --overdue: #b9470b;
  --res: #4553b8; --purple: #6b46c1; --on-fill: #ffffff; --header-bg: rgba(255, 255, 255, .96);
  --err-text: #8e1c1c; --warn-text: #6b4100; --ok-text: #14532d; --shadow: 0 6px 24px rgba(18, 23, 29, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.35rem; letter-spacing: .01em; }
h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .08em; }
h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono, code { font-family: var(--mono); font-size: .92em; letter-spacing: .01em; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.i { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; }

/* ---------- header / layout ---------- */
header.top {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem;
  background: var(--header-bg); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
header.top .brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
header.top .who { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .85rem; text-decoration: none; }
header.top .who:hover { color: var(--text); }
.role { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; border: 1px solid var(--line-strong); padding: 0 .3rem; border-radius: 3px; }
main { max-width: 1240px; margin: 0 auto; padding: 1rem; }

nav.tabs { display: flex; gap: 0; overflow-x: auto; margin: -.25rem 0 1rem; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
nav.tabs a {
  flex: none; padding: .6rem .85rem; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .07em; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.tabs a:hover { color: var(--text); }
nav.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs .sep { flex: none; width: 1px; background: var(--line); margin: .5rem .35rem; }

/* ---------- status tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.tile {
  display: flex; flex-direction: column; gap: .15rem; padding: .7rem .9rem; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c, var(--accent));
  text-decoration: none; color: var(--text);
}
.tile:hover { border-color: var(--line-strong); border-top-color: var(--c, var(--accent)); }
.tile.active { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.tile .label { font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.tile .num { font-size: 1.7rem; font-weight: 800; color: var(--c, var(--text)); line-height: 1.1; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.toolbar h2, .toolbar h3 { margin: 0; }
.toolbar input[type=search] { flex: 1 1 220px; }

/* ---------- controls ---------- */
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 4px; padding: .55rem .7rem; min-height: 42px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.toolbar select, .toolbar input { width: auto; }
label.field, div.field { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
label.field > input, label.field > select, label.field > textarea, div.field > .seg { margin-top: .3rem; text-transform: none; letter-spacing: normal; font-size: .95rem; font-weight: 400; color: var(--text); }
label.field > .small, div.field > .seg { display: block; width: max-content; }
label.field > .small { width: auto; margin-top: .25rem; font-weight: 400; text-transform: none; letter-spacing: normal; }
label.field .req, div.field .req { color: var(--nmc); }
label.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text); cursor: pointer; min-height: 32px; }
label.check input { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.grid .wide { grid-column: 1 / -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px;
  padding: .45rem .95rem; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--panel-2);
  font-weight: 700; font-size: .85rem; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; letter-spacing: .02em;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.out { background: var(--out); border-color: var(--out); color: var(--on-fill); }
.btn.in { background: var(--in); border-color: var(--in); color: var(--on-fill); }
.btn.danger { background: transparent; border-color: var(--nmc); color: var(--nmc); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn.big { min-height: 56px; font-size: 1rem; flex: 1; text-transform: uppercase; letter-spacing: .08em; }
.btn.sm { min-height: 32px; padding: .25rem .6rem; font-size: .78rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.seg label { display: flex; align-items: center; padding: .5rem 1.1rem; cursor: pointer; font-weight: 800; letter-spacing: .06em; }
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--c); color: var(--on-fill); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- status badges ---------- */
.badge {
  display: inline-block; padding: .05rem .4rem; border-radius: 3px; font-size: .68rem; font-weight: 800;
  letter-spacing: .08em; border: 1px solid; line-height: 1.5; text-transform: uppercase;
}
.badge.IN { color: var(--in); border-color: var(--in); }
.badge.OUT { color: var(--out); border-color: var(--out); }
.badge.FMC { color: var(--fmc); border-color: var(--fmc); }
.badge.NMC { color: var(--nmc); border-color: var(--nmc); background: color-mix(in srgb, var(--nmc) 12%, transparent); }
.badge.GTG { color: var(--on-fill); background: var(--gtg); border-color: var(--gtg); }
.badge.OVERDUE { color: #fff; background: var(--overdue); border-color: var(--overdue); }
.badge.RETIRED { color: var(--muted); border-color: var(--muted); }
.badge.parts-needed { color: var(--overdue); border-color: var(--overdue); }
.badge.parts-ordered { color: var(--out); border-color: var(--out); }
.badge.parts-received { color: var(--gtg); border-color: var(--gtg); }

/* ---------- equipment rows ---------- */
.list { display: flex; flex-direction: column; gap: .4rem; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .65rem .9rem; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--line-strong); text-decoration: none; color: var(--text);
}
.row:hover { border-color: var(--line-strong); border-left-color: var(--accent); }
.row.overdue { border-left-color: var(--overdue); }
.row .title { font-weight: 700; }
.row .meta { color: var(--text); font-size: .82rem; display: flex; flex-wrap: wrap; gap: .15rem 1rem; }
.row .meta > span { white-space: nowrap; }
.row .meta b { font-size: .64rem; letter-spacing: .08em; color: var(--muted); margin-right: .2rem; }
.row .badges { display: flex; gap: .3rem; align-items: start; justify-content: end; flex-wrap: wrap; }
.row-wrap { display: flex; align-items: stretch; gap: .4rem; }
.row-wrap > .row { flex: 1; min-width: 0; }
.row-wrap > .btn { align-self: center; }
label.pick { display: flex; align-items: center; justify-content: center; width: 44px; flex: none; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
label.pick input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; background: var(--panel-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.warn-row td { background: color-mix(in srgb, var(--nmc) 8%, transparent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table tr:last-child td { border-bottom: 0; }

/* ---------- detail ---------- */
.detail-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: start; justify-content: space-between; }
.detail-head h2 { text-transform: none; letter-spacing: .01em; font-size: 1.2rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: .75rem 0 0; }
.kv dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding-top: .15rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.qr { background: #fff; padding: 8px; border-radius: 4px; width: 150px; border: 1px solid var(--line); }
.qr img { display: block; width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: .2rem .9rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .78rem; white-space: nowrap; font-family: var(--mono); padding-top: .1rem; }
.ev { font-size: .64rem; font-weight: 800; padding: .05rem .35rem; border-radius: 3px; background: var(--line); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.ev.SIGN_OUT { background: var(--out); color: var(--on-fill); }
.ev.SIGN_IN { background: var(--in); color: var(--on-fill); }
.ev.STATUS, .ev.MAINT_OPEN, .ev.MAINT_UPDATE, .ev.MAINT_CLOSE { background: var(--purple); color: #fff; }
.ev.RETIRED, .ev.DELETED { background: var(--nmc); color: #fff; }
.ev.ADDED, .ev.RESTORED { background: var(--gtg); color: var(--on-fill); }

/* ---------- maintenance tickets ---------- */
.ticket { padding: .7rem .9rem; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--line-strong); display: flex; flex-direction: column; gap: .3rem; }
.ticket.open { border-left-color: var(--nmc); }
.ticket.closed { opacity: .8; }
.ticket .toolbar { margin: 0; }
.ticket .actions { margin: .2rem 0 0; }
.t-form:not(:empty) { margin-top: .5rem; }
.nmc-picks { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: .35rem; text-transform: none; letter-spacing: normal; font-weight: 400; }

/* ---------- alerts / toast ---------- */
.alert { padding: .65rem .9rem; border-radius: 4px; margin-bottom: .75rem; border: 1px solid; border-left-width: 4px; }
.alert.error { border-color: var(--nmc); background: color-mix(in srgb, var(--nmc) 9%, transparent); color: var(--err-text); }
.alert.warn { border-color: var(--out); background: color-mix(in srgb, var(--out) 10%, transparent); color: var(--warn-text); }
.alert.ok { border-color: var(--gtg); background: color-mix(in srgb, var(--gtg) 9%, transparent); color: var(--ok-text); }
#toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 2000;
  padding: .7rem 1rem; border-radius: 4px; background: var(--panel); color: var(--text); font-weight: 700;
  border: 1px solid var(--line-strong); border-left: 4px solid var(--gtg); box-shadow: var(--shadow); max-width: 90vw;
}
#toast.error { border-left-color: var(--nmc); }
.update-bar {
  position: fixed; left: 50%; transform: translateX(-50%); top: 4.25rem; z-index: 3000; display: flex; gap: .75rem; align-items: center;
  background: var(--panel); border: 1px solid var(--accent); color: var(--text); padding: .5rem .5rem .5rem 1rem; border-radius: 4px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* ---------- login ---------- */
.login { max-width: 400px; margin: 8vh auto; padding: 1.5rem; }
.login .brand-big { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-bottom: 1.25rem; text-align: center; }
.login .brand-big h1 { margin: .25rem 0 0; }
.login .brand-big p { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; }
.notice { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-left: 3px solid var(--out); padding: .6rem .75rem; border-radius: 4px; margin: 1rem 0 .5rem; }

/* ---------- home ---------- */
.quick { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.cards .card { margin: 0; }
.cards .card.alarm { border-color: var(--overdue); border-top: 3px solid var(--overdue); }
.cards .wide-card { grid-column: 1 / -1; }

/* ---------- kit ---------- */
.kit-chip { background: var(--out); border-color: var(--out); color: var(--on-fill); }
.kit-chip .count { font-family: var(--mono); }

/* ---------- more menu ---------- */
.more-who { margin-bottom: .75rem; }
.more-list { display: flex; flex-direction: column; gap: .35rem; }
.more-item { display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.more-item .i { width: 1.35rem; height: 1.35rem; color: var(--muted); }

/* ---------- map ---------- */
#map, .mini-map { height: 65vh; min-height: 360px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); }
.mini-map { height: 260px; min-height: 0; margin-top: .4rem; }
.drone-icon svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.drone-label { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); font-weight: 700; box-shadow: none; border-radius: 3px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border-radius: 4px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.cal-head h2 { margin: 0; flex: 1; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal .dow { text-align: center; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; padding: .25rem 0; }
.cal .day { min-height: 92px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 4px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal .day.other { opacity: .4; }
.cal .day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .day .d { font-size: .72rem; font-weight: 800; color: var(--muted); font-family: var(--mono); }
.chip { font-size: .68rem; padding: 1px 4px; border-radius: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border: 0; text-align: left; font-weight: 600; }
.chip.res { background: var(--res); color: #fff; }
.chip.co { background: var(--out); color: var(--on-fill); }
.chip.co.late { background: var(--overdue); color: #fff; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin-top: .5rem; text-transform: uppercase; letter-spacing: .06em; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; background: var(--c); }

/* ---------- scanner ---------- */
.scanner video { width: 100%; max-height: 60vh; border-radius: var(--radius); background: #000; object-fit: cover; }

/* ---------- admin ---------- */
#users input:not([type=checkbox]), #users select { min-height: 34px; padding: .3rem .5rem; min-width: 120px; }
.actions-cell { display: flex; flex-wrap: wrap; gap: .3rem; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); }

/* ---------- QR labels (print) ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.2in, 1fr)); gap: .15in; }
.label-card { background: #fff; color: #000; border: 1px dashed #999; border-radius: 3px; padding: .12in; display: flex; gap: .1in; align-items: center; break-inside: avoid; }
.label-card img { width: 1.1in; height: 1.1in; }
.label-card .t { font-weight: 800; font-size: 10pt; text-transform: uppercase; }
.label-card .s { font-size: 8.5pt; font-family: var(--mono); }

/* ---------- signature ---------- */
.ack { margin: .35rem 0; font-size: .82rem; font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text); }
.sig { margin-top: .3rem; text-transform: none; letter-spacing: normal; font-weight: 400; }
.sig-canvas { display: block; width: 100%; height: 160px; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; touch-action: none; cursor: crosshair; }
.sig-bar { display: flex; align-items: center; justify-content: space-between; margin-top: .3rem; }

/* ---------- accessories ---------- */
.acc { display: flex; flex-direction: column; gap: .5rem; margin-top: .35rem; text-transform: none; letter-spacing: normal; font-weight: 400; color: var(--text); }
.acc-block { display: flex; flex-direction: column; gap: .3rem; }
.acc-head { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: .35rem; }
.acc-line { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2); font-size: .9rem; }
.acc-line .acc-name { flex: 1; font-weight: 600; text-transform: none; letter-spacing: normal; }
.acc-line .acc-name-in { flex: 1; min-height: 34px; padding: .3rem .5rem; }
.acc-line .acc-qty { width: 72px; min-height: 34px; padding: .3rem .5rem; text-align: center; font-family: var(--mono); }
.acc-line .muted { white-space: nowrap; text-transform: none; letter-spacing: normal; }
.acc-line.short { border-color: var(--nmc); background: color-mix(in srgb, var(--nmc) 10%, transparent); }
.acc-line.short .acc-qty { border-color: var(--nmc); color: var(--nmc); font-weight: 800; }

/* ---------- reservations / issue ---------- */
.row.static { cursor: default; }
.row.static:hover { border-left-color: var(--line-strong); border-color: var(--line); }
.issue-card { border-top: 3px solid var(--out); }
.issue-card .row-wrap > .btn { align-self: center; }

/* ---------- hand receipt (screen + print) ---------- */
.receipt { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 4px; padding: 1.5rem; max-width: 1000px; margin: 0 auto; }
.receipt .muted, .receipt .small { color: #444; }
.r-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #111; padding-bottom: .6rem; margin-bottom: .8rem; }
.r-title { font-size: 1.4rem; font-weight: 900; letter-spacing: .14em; }
.r-unit { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: #444; }
.r-no { text-align: right; }
.r-no .mono { font-size: 1.05rem; font-weight: 800; }
.r-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; color: #555; font-weight: 700; }
.r-status { display: inline-block; margin-top: .25rem; font-size: .66rem; font-weight: 800; letter-spacing: .1em; padding: .05rem .4rem; border: 1px solid; border-radius: 3px; }
.r-status.open { color: #9a5b00; } .r-status.closed { color: #1e7d46; }
.r-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.r-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.r-table th, .r-table td { border: 1px solid #999; padding: .35rem .45rem; vertical-align: top; color: #111; background: #fff; }
.r-table th { background: #e9ecef; color: #111; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
.r-short { color: #b00020; font-weight: 800; }
.r-sign { margin-top: 1.2rem; font-size: .85rem; }
.r-sig-row { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; margin-top: .75rem; align-items: end; }
.r-sig img { display: block; max-width: 100%; height: 90px; object-fit: contain; object-position: left bottom; }
.r-nosig { height: 90px; display: flex; align-items: flex-end; color: #777; font-style: italic; }
.r-date { height: 90px; display: flex; align-items: flex-end; font-family: var(--mono); }
.r-line { border-top: 1px solid #111; padding-top: .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #333; }
.r-foot { margin-top: 1.2rem; font-size: .68rem; color: #666; border-top: 1px solid #ccc; padding-top: .4rem; }
@media (max-width: 720px) {
  .receipt { padding: .9rem; }
  .r-grid { grid-template-columns: 1fr 1fr; }
  .r-table { font-size: .72rem; }
  .r-sig-row { grid-template-columns: 1fr; gap: 1rem; }
}
@media print {
  .receipt { border: 0; padding: 0; max-width: none; }
  .r-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- fast sign-out form ---------- */
#form-area, form.panel, .done-box { scroll-margin-top: 84px; }
div.field > input { margin-top: .3rem; text-transform: none; letter-spacing: normal; font-size: .95rem; font-weight: 400; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; text-transform: none; letter-spacing: normal; }
.chip-btn {
  min-height: 34px; padding: .25rem .7rem; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--panel-2);
  color: var(--text); font-weight: 700; font-size: .8rem; cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.due-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .3rem; }
.due-row input { width: auto; flex: 0 1 200px; margin: 0; text-transform: none; letter-spacing: normal; font-weight: 400; font-size: .95rem; color: var(--text); }
.due-row .chips { margin: 0; }
details.acc-wrap, details.more-wrap { border: 1px solid var(--line); border-radius: 4px; padding: 0; background: var(--panel-2); }
details.acc-wrap > summary, details.more-wrap > summary {
  list-style: none; cursor: pointer; padding: .65rem .8rem; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline;
}
details > summary::-webkit-details-marker { display: none; }
details.acc-wrap > summary::before, details.more-wrap > summary::before { content: "▸"; color: var(--muted); }
details[open].acc-wrap > summary::before, details[open].more-wrap > summary::before { content: "▾"; }
.acc-sum { text-transform: none; letter-spacing: normal; font-weight: 400; color: var(--text); font-size: .88rem; }
summary .link { margin-left: auto; color: var(--accent); text-transform: none; letter-spacing: normal; font-size: .82rem; }
details[open] summary .link { display: none; }
details.acc-wrap > .acc, details.more-wrap > .grid { padding: 0 .8rem .8rem; }

/* ---------- item page actions ---------- */
.sec-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: -.4rem; }
.done-box { background: var(--panel); border: 1px solid var(--gtg); border-left: 4px solid var(--gtg); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; }
.done-msg { font-weight: 800; color: var(--ok-text); display: flex; align-items: center; gap: .4rem; }
.done-box .actions { margin: .6rem 0 0; }

/* ---------- header find ---------- */
header.top .find input { width: 220px; min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.mode-seg label { padding: .4rem .8rem; font-size: .8rem; }

/* colour helpers (CSP blocks inline style attributes, so colours come from classes) */
.c-ALL { --c: var(--accent); } .c-IN { --c: var(--in); } .c-OUT { --c: var(--out); } .c-GTG { --c: var(--gtg); }
.c-FMC { --c: var(--fmc); } .c-NMC { --c: var(--nmc); } .c-OVERDUE { --c: var(--overdue); } .c-RES { --c: var(--res); }

/* ---------- bottom nav (phones) ---------- */
.bottom-nav { display: none; }
@media (max-width: 720px) {
  .desk { display: none !important; }
  nav.tabs .sec { display: none; }
  nav.tabs.not-inv { display: none; }
  main { padding: .75rem .75rem calc(84px + env(safe-area-inset-bottom)); }
  header.top { padding-top: calc(.55rem + env(safe-area-inset-top)); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile .num { font-size: 1.35rem; }
  .row { grid-template-columns: 1fr; }
  .row .badges { justify-content: start; }
  .cal .day { min-height: 64px; }
  .cal .chip { font-size: .58rem; }
  .cards { grid-template-columns: 1fr; }
  .actions-cell .btn { flex: 1; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: var(--header-bg); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .3rem 0; min-height: 52px; justify-content: center;
    color: var(--muted); text-decoration: none; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em;
  }
  .bottom-nav a .i { width: 1.4rem; height: 1.4rem; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a.scan-fab { color: var(--accent); }
  .bottom-nav .fab {
    display: grid; place-items: center; width: 56px; height: 56px; margin-top: -24px; border-radius: 12px;
    background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow); border: 3px solid var(--bg);
  }
  .bottom-nav .fab .i { width: 1.6rem; height: 1.6rem; }
  #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media print {
  header.top, nav.tabs, .no-print, #toast, .bottom-nav, .update-bar, .kit-chip { display: none !important; }
  html, body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .label-card { border-color: #ccc; }
}

/* ---------- training-area map layers ---------- */
.ta-label { background: transparent; border: 0; box-shadow: none; color: #0d2a4d; font-weight: 800; font-size: 11px; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; padding: 0; }
.ta-label::before { display: none; }
.hide-ta-labels .ta-label { display: none; }
.drone-icon.approx { opacity: .65; }
.pin-warn { color: var(--nmc) !important; font-weight: 800; }
.leaflet-control-layers { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong) !important; border-radius: 4px; }
.leaflet-control-layers label { font-size: .8rem; }
.field .leaflet-container, .leaflet-container { text-transform: none; letter-spacing: normal; font-weight: 400; }

/* ---------- camera scanner ---------- */
.cam-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; max-height: 62vh; }
.cam-wrap video { display: block; width: 100%; max-height: 62vh; object-fit: cover; }
.cam-frame { position: absolute; left: 50%; top: 50%; width: min(62vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); pointer-events: none; }
.cam-status { position: absolute; left: 0; right: 0; bottom: 0; padding: .5rem; text-align: center; color: #fff; font-weight: 700;
  font-size: .85rem; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }

/* ---------- calendar markers ---------- */
.chip.ci { background: var(--in); color: var(--on-fill); }
.chip.due { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--out); }
.chip.due.late { box-shadow: inset 0 0 0 1px var(--overdue); color: var(--overdue); }
.c-DUE { --c: transparent; } .c-DUE::before { box-shadow: inset 0 0 0 1px var(--out); }

.cal .day { cursor: pointer; }
.cal .day.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.chip b { font-weight: 800; }
.day-list { margin-top: .75rem; }
.day-list .timeline li { align-items: center; }
.day-list .chip { display: inline-block; min-width: 3.4rem; text-align: center; }
@media (max-width: 720px) {
  .cal .chip-t { display: none; }
  .cal .chip { text-align: center; padding: 1px 0; }
}

#tm input { min-height: 34px; padding: .3rem .5rem; min-width: 110px; }
#tm .t-notes { min-width: 160px; }

/* ---------- admin layout ---------- */
.admin-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .75rem; }
.admin-head h2 { margin: 0; }
.subtabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: thin; }
.subtabs a { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); text-decoration: none; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.subtabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.subtabs .count:not(:empty) { font-family: var(--mono); font-size: .72rem; padding: 0 .35rem; border-radius: 3px; background: color-mix(in srgb, currentColor 15%, transparent); }
.sub-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: .9rem; margin-bottom: .9rem; }
.sub-panel h3 { margin-top: 0; }
.toolbar.filters input[type=search] { flex: 1 1 240px; }
.table-note { margin: 0 0 .4rem; }
.empty-state { text-align: center; padding: 1.5rem 1rem; color: var(--muted); }
.empty-state .actions { justify-content: center; }
.save-bar { position: sticky; bottom: 0; padding: .6rem 0; background: linear-gradient(transparent, var(--bg) 35%); display: flex; justify-content: flex-end; }
.sel-cell { width: 36px; }

/* saving indicator: thin bar + no double submits */
body.busy::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 4000;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat;
  animation: busybar 1s linear infinite; }
@keyframes busybar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
body.busy button[type=submit], body.busy .btn[data-t-save], body.busy .btn[data-u-save] { opacity: .6; pointer-events: none; }

/* tables become stacked cards on phones */
@media (max-width: 720px) {
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { border-bottom: 1px solid var(--line); padding: .6rem .7rem; position: relative; }
  table.rtable td { border: 0; padding: .2rem 0; }
  table.rtable td[data-label]::before { content: attr(data-label); display: block; font-size: .64rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted); margin-bottom: .1rem; }
  table.rtable td.sel-cell { position: absolute; right: .7rem; top: .6rem; width: auto; }
  table.rtable td input:not([type=checkbox]), table.rtable td select { width: 100%; min-width: 0; }
  table.rtable .actions-cell { padding-top: .4rem; }
  .admin-head { flex-direction: column; align-items: stretch; }
}
.subtabs a { flex: none; }
@media (max-width: 720px) {
  .subtabs { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .subtabs a { justify-content: center; padding: .55rem .4rem; }
}
@media (max-width: 720px) {
  table.rtable.compact td[data-label] { display: flex; gap: .5rem; align-items: baseline; padding: .1rem 0; }
  table.rtable.compact td[data-label]::before { display: inline; flex: 0 0 5.5rem; margin: 0; }
  table.rtable.compact .actions-cell { display: flex; gap: .4rem; }
}
.table-note { padding: .5rem .6rem 0; }

/* thumb-friendly secondary buttons on phones */
@media (max-width: 720px) {
  .btn.sm, .chip-btn, .subtabs a { min-height: 40px; }
  .cal-head .btn.sm { min-width: 44px; }
}
