:root {
  --navy: #0f1b2d; --navy2: #1b2c45; --sky: #2f80ed; --sky-d: #1f63c4;
  --bg: #f3f5f8; --card: #fff; --line: #e2e7ee; --ink: #16202e; --muted: #667487;
  --ok: #1f8a4c; --ok-bg: #e5f5ec; --due: #9a6200; --due-bg: #fff3d6; --bad: #c0362c; --bad-bg: #fde8e6; --na-bg: #eef1f5;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--sky-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.2rem 0 .4rem; }
code { background: var(--na-bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { display: inline-block; transform: rotate(-20deg); color: #7fb2ff; }
.top nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav a, .me a { color: #c9d6ea; padding: .4rem .65rem; border-radius: 7px; white-space: nowrap; }
.top nav a.on, .top nav a:hover, .me a.on, .me a:hover { background: var(--navy2); color: #fff; text-decoration: none; }
.me { display: flex; align-items: center; gap: .3rem; }
.me form { margin: 0; }
button.link { background: none; border: 0; color: #8fa3bf; cursor: pointer; font: inherit; padding: .4rem; }
@media (max-width: 760px) {
  .top { padding: .5rem .6rem; gap: .4rem; }
  .top nav { order: 3; flex-basis: 100%; }
  .me { margin-left: auto; }
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 1.5rem 1rem 2rem; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(16, 27, 45, .04); }
.card.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.card.inactive { opacity: .6; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols > * { min-width: 0; }
.pilot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.top-actions { margin-bottom: 1rem; }

/* aircraft card */
.ac-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.ac-card.grounded { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-bg); }
.meters, .stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.meters > div, .stats > div { background: var(--bg); border-radius: 8px; padding: .4rem .75rem; min-width: 86px; }
.stats { margin-bottom: 1rem; }
.stats > div { background: var(--card); border: 1px solid var(--line); }
.meters small, .stats small { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.meters b, .stats b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.ground-banner { background: var(--bad); color: #fff; font-weight: 700; padding: .35rem .7rem; border-radius: 7px; display: inline-block; margin-top: .3rem; }
.ground-banner.big { display: block; padding: .7rem 1rem; margin-bottom: 1rem; }
.bar { height: 8px; background: var(--na-bg); border-radius: 99px; overflow: hidden; margin: .6rem 0 .3rem; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), #56ccf2); border-radius: 99px; }
.goal { display: flex; justify-content: space-between; gap: .5rem; margin-top: .6rem; font-size: .92rem; }
.alerts { list-style: none; padding: 0; margin: .6rem 0; }
.alerts li { padding: .25rem 0; }

/* badges */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; white-space: nowrap; vertical-align: 1px; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-due { background: var(--due-bg); color: var(--due); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-na { background: var(--na-bg); color: var(--muted); }

/* lists & tables */
.list { list-style: none; padding: 0; margin: 0 0 .5rem; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; font-weight: 600; font-size: .88rem; padding: .4rem .6rem .4rem 0; vertical-align: top; width: 38%; }
.kv td { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.kv tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--line); padding: .45rem .5rem; white-space: nowrap; }
.tbl td { padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.fwd td { background: #f4f8ff; }
.tbl tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl tbody tr:hover td { background: #fafbfd; }

/* forms */
.form label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: .7rem; }
.form input:not([type=checkbox]), .form select, .form textarea, .filters input, .filters select, input.copy {
  display: block; width: 100%; margin-top: .25rem; font: inherit; font-weight: normal; color: var(--ink);
  padding: .55rem .65rem; border: 1px solid #cbd3de; border-radius: 8px; background: #fff; min-height: 42px;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--sky); }
.form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form fieldset[disabled] { opacity: .75; }
label.check { display: flex !important; align-items: center; gap: .5rem; font-weight: normal !important; }
label.check input { width: 20px; height: 20px; }
.checks { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.grid2, .grid3, .grid4 { display: grid; gap: 0 .9rem; align-items: end; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
@media (max-width: 760px) {
  .grid3, .grid4 { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters select, .filters input { width: auto; margin: 0; }
.filters label { font-size: .8rem; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; background: var(--sky); color: #fff; border: 1px solid var(--sky); border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; min-height: 42px; white-space: nowrap; }
.btn:hover { background: var(--sky-d); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--sky-d); border-color: #cbd3de; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--bad); border-color: #f0c4c0; }
.btn.danger:hover { background: var(--bad-bg); }
.small-btn { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.inline-del { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
details.squawk-box { background: #fff8f2; border: 1px solid #f3dcc8; border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0 1rem; }
details.squawk-box summary { cursor: pointer; font-weight: 600; }
details.squawk-box[open] summary { margin-bottom: .6rem; }

/* flash */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem; font-size: .92rem; }
.f-ok { background: var(--ok-bg); color: #145c33; }
.f-warn { background: var(--due-bg); color: #6d4500; }
.f-err { background: var(--bad-bg); color: #8f241c; }
pre.err { white-space: pre-wrap; background: var(--bad-bg); padding: .6rem; border-radius: 6px; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
.cal-head h1 { margin: 0 .4rem; min-width: 170px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 1rem; }
.cal .dow { background: var(--navy); color: #c9d6ea; text-align: center; font-size: .74rem; padding: .35rem 0; text-transform: uppercase; letter-spacing: .05em; }
.cal .day { background: #fff; min-height: 96px; padding: .25rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal .day.other { background: #f8f9fb; }
.cal .day.other .dnum { color: #a8b2bf; }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--sky); }
.cal .dnum { font-size: .8rem; font-weight: 700; color: var(--ink); align-self: flex-start; padding: 0 .25rem; border-radius: 5px; }
.cal .ev { font-size: .74rem; background: #e8f0fd; color: #18427f; border-left: 3px solid var(--sky); border-radius: 4px; padding: 1px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal .ev.mine { background: #dff3e8; color: #145c33; border-left-color: var(--ok); }
.cal .ev.mx { background: #fde8e6; color: #8f241c; border-left-color: var(--bad); }
@media (max-width: 640px) {
  .cal .day { min-height: 62px; padding: 2px; }
  .cal .ev { font-size: .64rem; padding: 0 2px; border-left-width: 2px; }
}

/* login */
.login { max-width: 400px; margin-top: 8vh; text-align: center; }
.login .form { text-align: left; }
.login .btn { width: 100%; }
.login-logo { font-size: 2.4rem; color: var(--sky); transform: rotate(-20deg); display: inline-block; }

@media print {
  .top, .actions, .filters, .foot, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

/* v2 additions */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tile { display: block; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--sky); }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--sky); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.notice { background: #eef5ff; border: 1px solid #cfe0fb; border-left: 4px solid var(--sky); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .8rem; }
.notice.n-warn { background: var(--due-bg); border-color: #f1dca4; border-left-color: #e0a100; }
.card.attention { border-color: #f1dca4; background: #fffcf2; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.ok:hover { background: #17703d; }
button.link.danger-link, .danger-link { color: var(--bad); padding: 0 .3rem; font-size: .85rem; }
form.inline { display: inline; }
.top-gap { margin-top: 1rem; }
.indent { padding-left: 1.8rem; }
.code-input { font-size: 1.4rem !important; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.mfa-setup { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; margin: 1rem 0; }
.mfa-setup ol { flex: 1; min-width: 220px; padding-left: 1.2rem; margin: 0; }
.mfa-setup li { margin-bottom: .6rem; }
.qr { width: 200px; height: 200px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.qr svg { width: 100%; height: 100%; }
.secret code { display: inline-block; margin-top: .3rem; font-size: 1rem; letter-spacing: .08em; padding: .3rem .5rem; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; margin: 1rem 0; }
.codes code { font-size: 1.05rem; padding: .45rem; text-align: center; letter-spacing: .06em; }
.matrix td.c, .matrix th.c { text-align: center; }
.matrix tr.grp td { background: var(--bg); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.yes { color: var(--ok); font-weight: 700; }
.owes { color: var(--bad); }
.credit { color: var(--ok); }
.tbl tr.sel td { background: #f4f8ff; }
.sign-box { background: var(--ok-bg); border: 1px solid #bfe6cf; border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; }
.sign-box p { margin: 0 0 .5rem; }
.endorsement .sig { font-family: Georgia, serif; font-style: italic; border-top: 1px solid var(--line); padding-top: .5rem; }
.override-box { background: var(--bad-bg); border: 1px solid #f0c4c0; border-radius: 8px; padding: .7rem .9rem; margin: 1rem 0; }
.frat-score { font-size: .85rem; padding: .15rem .6rem; border-radius: 99px; vertical-align: 2px; }
.att { font-size: .82rem; white-space: nowrap; }
.tbl.wb input { width: 90px; text-align: right; padding: .35rem .45rem; border: 1px solid #cbd3de; border-radius: 6px; font: inherit; }
.tbl input:not([type=checkbox]) { width: 100%; padding: .35rem .45rem; border: 1px solid #cbd3de; border-radius: 6px; font: inherit; }
svg.env { width: 100%; max-width: 480px; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; margin-top: .8rem; }
.env-poly { fill: #e5f5ec; stroke: var(--ok); stroke-width: 2; }
.env-line { stroke: var(--muted); stroke-dasharray: 4 3; }
.pt-ok { fill: var(--sky); } .pt-bad { fill: var(--bad); }
.ax, .lbl { font-size: 11px; fill: var(--muted); } .lbl { font-weight: 700; fill: var(--ink); }
.flash ul { margin: .3rem 0 0; padding-left: 1.2rem; }
@media print { .tabs, .sign-box { display: none !important; } }

@media (max-width: 1360px) and (min-width: 761px) {
  .top nav { order: 3; flex-basis: 100%; }
  .me { margin-left: auto; }
}
