/* Hangar. One stylesheet, no build step. Colours are tokens so dark mode only swaps these. */

:root {
	--bg: #f4f6f9;
	--surface: #ffffff;
	--text: #14202e;
	--muted: #5b6776;
	--line: #dde3ea;
	--brand: #0f2742;
	--brand-text: #ffffff;
	--accent: #f2b632;
	--link: #1b5fa8;
	--ok: #17794a;
	--ok-bg: #e3f4ea;
	--soon: #8a5a00;
	--soon-bg: #fdf1d6;
	--bad: #b42318;
	--bad-bg: #fde7e5;
	--muted-bg: #eceff3;
	--dual: #2f6fb8;
	--solo: #17794a;
	--hire: #7a4bb5;
	--maintenance: #8a5a00;
	--radius: 10px;
	--shadow: 0 1px 2px rgb(15 39 66 / 6%), 0 2px 8px rgb(15 39 66 / 5%);
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0c1622;
		--surface: #13202f;
		--text: #e6ecf2;
		--muted: #93a1b1;
		--line: #253447;
		--brand: #0a1a2c;
		--link: #7db4f0;
		--ok: #5fd39a;
		--ok-bg: #123524;
		--soon: #f2c35b;
		--soon-bg: #3a2c0c;
		--bad: #ff8a80;
		--bad-bg: #3d1614;
		--muted-bg: #1d2b3b;
		--shadow: none;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-text-size-adjust: 100%;
}

a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
p { margin: 0 0 .75em; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; padding-top: 8vh; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.1rem; }
.reg { font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

/* Top bar */
.topbar { background: var(--brand); color: var(--brand-text); }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: rgb(255 255 255 / 80%); text-decoration: none; padding: 16px 10px; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }
.signout .link { color: rgb(255 255 255 / 75%); }

@media (max-width: 700px) {
	.topbar-inner { gap: 0 12px; }
	.nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 6px; }
	.nav a { padding: 10px; }
	.signout { margin-left: auto; }
}

main { padding-top: 24px; padding-bottom: 32px; }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

/* Layout pieces */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-bottom: .1em; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.highlight { border-color: var(--accent); }
.narrow-card { max-width: 460px; margin: 0 auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 16px; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.aircraft-card { display: block; color: inherit; text-decoration: none; margin: 0; }
a.aircraft-card:hover { border-color: var(--link); }
.aircraft-card p { margin: .25em 0; }
.live.flying, .lead.flying { color: var(--ok); font-weight: 600; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 4px 0; }

/* Badges and messages */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-soon { background: var(--soon-bg); color: var(--soon); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.flash { padding: 10px 14px; border-radius: var(--radius); background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--soon-bg); color: var(--soon); }
.flash ul { margin: .4em 0 0; padding-left: 1.2em; }

.verdicts { display: grid; gap: 8px; margin: 12px 0; }
.verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.verdict-kind { min-width: 110px; font-weight: 600; }
.verdict-inline { margin-right: 14px; white-space: nowrap; }
.raw { background: var(--muted-bg); padding: 10px 12px; border-radius: 8px; font-size: .85rem; white-space: pre-wrap; word-break: break-word; }

/* Forms */
label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
	font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
	border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--link); outline-offset: 1px; }
input[readonly] { background: var(--muted-bg); }
.check { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 42px; }
.check input { width: auto; min-height: 0; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; }
.span-2 { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 200px; }
.inline-form.compact select { min-height: 34px; padding: 4px 8px; width: auto; }
.copy { font-family: ui-monospace, monospace; font-size: .85rem; }

.button {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
	padding: 8px 16px; border: 0; border-radius: 8px; background: var(--brand); color: #fff;
	font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .button { background: #2b5d94; } }
.button:hover { filter: brightness(1.15); }
.button.secondary { background: var(--muted-bg); color: var(--text); }
.button-danger { background: var(--bad); }
.button.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; }
.head-actions input[type="date"] { width: auto; }

details > summary { cursor: pointer; color: var(--link); margin-top: 12px; }
details[open] > summary { margin-bottom: 12px; }
details.danger > summary { color: var(--bad); }
details.popover { display: inline-block; }
details.popover > summary { list-style: none; margin: 0; color: #fff; }
details.popover > summary::-webkit-details-marker { display: none; }
details.popover[open] form { position: absolute; right: 16px; z-index: 5; width: min(300px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.card .table-wrap { border: 0; margin: 0 -18px 8px; border-radius: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; position: relative; }
td.actions form { display: inline-block; margin-left: 8px; }
tr.inactive td { opacity: .55; }
.limits input { min-width: 80px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }

/* Bookings */
.booking-list { display: grid; gap: 6px; }
.booking-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; background: var(--muted-bg); color: inherit; text-decoration: none; border-left: 4px solid var(--dual); }
.booking-row:hover { filter: brightness(.97); }
.booking-row .when { font-variant-numeric: tabular-nums; color: var(--muted); }
.kind-solo { border-left-color: var(--solo); }
.kind-hire { border-left-color: var(--hire); }
.kind-maintenance { border-left-color: var(--maintenance); }

/* The day sheet: one row per aircraft, hours across. Scrolls sideways on phones. */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 16px; }
.sheet-row { display: grid; grid-template-columns: 110px minmax(700px, 1fr); border-bottom: 1px solid var(--line); }
.sheet-row:last-child { border-bottom: 0; }
.sheet-label { padding: 10px 12px; display: grid; gap: 4px; align-content: center; position: sticky; left: 0; background: var(--surface); z-index: 2; border-right: 1px solid var(--line); }
.sheet-track { position: relative; display: grid; grid-template-columns: repeat(var(--hours), 1fr); min-height: 56px; }
.sheet-hours .sheet-track { min-height: 0; }
.sheet-hours span { font-size: .75rem; color: var(--muted); padding: 6px 4px; border-left: 1px solid var(--line); }
.slot { border-left: 1px solid var(--line); }
.slot:hover { background: var(--muted-bg); }
.block {
	position: absolute; top: 6px; bottom: 6px; z-index: 1; overflow: hidden; border-radius: 6px;
	background: var(--dual); color: #fff; font-size: .78rem; padding: 4px 6px; text-decoration: none; line-height: 1.25;
}
.block span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.block.kind-solo { background: var(--solo); }
.block.kind-hire { background: var(--hire); }
.block.kind-maintenance { background: repeating-linear-gradient(45deg, var(--maintenance), var(--maintenance) 8px, #a36c00 8px, #a36c00 16px); }

/* Sign-in and public pages */
.bare main { padding-top: 0; }
.auth .logo { text-align: center; margin-bottom: 4px; }
.auth h1 { text-align: center; }
.public-head { padding: 24px 0 8px; }
body.bare .wrap.narrow:has(.public-head) { max-width: 1100px; padding-top: 0; }
.flying { color: var(--ok); font-weight: 600; }

/* Maps (Leaflet). The tiles are darkened in dark mode; routes and labels keep their colours. */
.map { height: 340px; border-radius: 8px; margin: 4px 0 12px; z-index: 0; background: var(--muted-bg); }
.map-tall { height: 440px; }
@media (max-width: 600px) { .map, .map-tall { height: 280px; } }
@media (prefers-color-scheme: dark) { .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }
.map-plane span {
	display: inline-block; transform: translate(-50%, -50%); padding: 2px 7px; border-radius: 999px; white-space: nowrap;
	background: var(--c); color: #fff; font: 700 12px/1.4 system-ui, sans-serif; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); border: 2px solid #fff;
}
.map-plane.is-flying span { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgb(23 121 74 / 25%); } }
@media (prefers-reduced-motion: reduce) { .map-plane.is-flying span { animation: none; } }
.has-route { cursor: pointer; border-radius: 6px; padding-left: 6px !important; margin-left: -6px; }
.has-route:hover, .has-route:focus-visible { background: var(--muted-bg); }
.has-route.is-selected { background: var(--muted-bg); box-shadow: inset 3px 0 0 var(--link); }
