/* Aeropict Logbook — app styles */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e7ef;
  --text: #16202e;
  --muted: #5d6b7e;
  --brand: #0b2545;
  --brand-2: #13315c;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --ok: #1a7f4b;      --ok-bg: #e5f6ec;
  --warn: #9a6200;    --warn-bg: #fff4d6;
  --bad: #b42318;     --bad-bg: #fde8e7;
  --grace: #8a4b00;   --grace-bg: #ffe9d1;
  --na: #5d6b7e;      --na-bg: #eef1f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d131c; --surface: #141c27; --surface-2: #18212e; --border: #263243; --text: #e6ecf4; --muted: #93a1b5;
    --brand: #0a1a30; --brand-2: #10233f; --accent: #5aa9ff; --accent-soft: #15294a;
    --ok: #4cc38a; --ok-bg: #12301f; --warn: #f0b84a; --warn-bg: #33280e; --bad: #ff7b72; --bad-bg: #3a1614;
    --grace: #ffa657; --grace-bg: #3a2410; --na: #93a1b5; --na-bg: #1d2735;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h3 { font-size: 1.05rem; }
h4 { font-size: .9rem; margin-top: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.inline { display: inline; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--brand); color: #cfe0f5; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-size: 1.05rem; padding: 1.1rem 1.1rem 1rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }
.brand b { font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; padding: .25rem .6rem; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 8px; color: #cfe0f5; font-size: .93rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(90,169,255,.18); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.2rem; font-size: .75rem; color: #7f97b5; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 99px; background: #ff6b5b; color: #fff; font-size: .72rem; text-align: center; line-height: 1.5; margin-left: .3em; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .8rem; padding: .9rem 1.6rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.25rem; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.who { font-size: .9rem; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 1.5rem 1.6rem 4rem; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: .75rem 1rem; }
  .content { padding: 1rem 1rem 4rem; }
  .who { display: none; }
}

/* ---------------------------------------------------------------- components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.callout { border-left: 4px solid var(--accent); }
.card.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; }
.card.empty p { margin: 0; }
.table-card { padding: 0; overflow: hidden; }
.scroll-x { overflow-x: auto; }
.narrow-card { max-width: 480px; }
.section-title { font-size: 1.05rem; margin: 1.6rem 0 .7rem; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar p { margin: 0; }
.push-right { margin-left: auto; }
.gap { gap: 1rem; }
.quote { border-left: 3px solid var(--border); padding-left: .8rem; color: var(--muted); }
.disclaimer { color: var(--muted); font-size: .8rem; margin-top: 1.5rem; max-width: 80ch; }
.steps { margin: .4rem 0 .6rem; padding-left: 1.3rem; }
.steps li { margin: .3rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 9px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; font-size: .92rem; padding: .55rem 1rem; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-sm { padding: .38rem .7rem; font-size: .84rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: .35rem; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash-info { background: var(--accent-soft); color: var(--accent); }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; letter-spacing: .01em; }
.badge-current { background: var(--ok-bg); color: var(--ok); }
.badge-soon { background: var(--warn-bg); color: var(--warn); }
.badge-expired { background: var(--bad-bg); color: var(--bad); }
.badge-grace { background: var(--grace-bg); color: var(--grace); }
.badge-na, .badge-info { background: var(--na-bg); color: var(--na); }
.tag { display: inline-block; padding: .05rem .4rem; border-radius: 5px; font-size: .72rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.reg { font-size: .75rem; color: var(--muted); font-weight: 500; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .tabs { margin-bottom: 0; border-bottom: 0; }
.tabs a { padding: .5rem .9rem; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact th, .table.compact td { padding: .45rem .6rem; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.hl td { background: var(--accent-soft); }
.table .actions { text-align: right; white-space: nowrap; }
.logbook-table td { white-space: nowrap; }
.logbook-table td.route, .logbook-table td.remarks { white-space: normal; min-width: 140px; max-width: 280px; font-size: .84rem; }
.grid-8710 th, .grid-8710 td { font-size: .8rem; }
.grid-8710 thead th { white-space: normal; min-width: 70px; text-transform: none; letter-spacing: 0; }

/* ---------------------------------------------------------------- forms */
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 600; color: var(--text); margin-bottom: .8rem; }
.form label > span { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.form label.check, label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; }
.pad-top { padding-top: 1.6rem; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .7rem 1rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 700; font-size: .85rem; padding: 0 .3rem; }
fieldset.checks, fieldset.radios { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
fieldset.checks label, fieldset.radios label { margin-bottom: .4rem; }
.opt { font-weight: 400; color: var(--muted); font-size: .8rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: .8rem 0; z-index: 5; }
.form-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.form-row label { margin-bottom: 0; }
.form-row form { display: contents; }
.inline-label { display: flex; align-items: center; gap: .5rem; font-size: .88rem; font-weight: 600; }
.inline-label input { width: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 1rem; }
.grid-2.gap { gap: 1rem; }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (min-width: 801px) and (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.filters { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; padding: .8rem 1rem; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
.filters label.grow { flex: 1; min-width: 180px; }
.filters input, .filters select { padding: .38rem .55rem; font-size: .88rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: .5rem; }

.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 600; font-size: .9rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: var(--border); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

details.menu { position: relative; display: inline-block; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .5rem; min-width: 260px; z-index: 30; display: flex; flex-direction: column; gap: .35rem; text-align: left; }
.menu-body form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.menu-body .btn { justify-content: flex-start; }
.danger-zone { border-top: 1px solid var(--border); padding-top: .5rem; }
.danger-zone input { font-size: .8rem; padding: .3rem .5rem; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { font-family: var(--mono); font-size: .82rem; }

/* ---------------------------------------------------------------- dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.tile-value { font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; margin: .15rem 0; }
.tile-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.tile-sub { font-size: .8rem; color: var(--muted); }
.cur-list { list-style: none; margin: 0; padding: 0; }
.cur-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cur-list li:last-child { border-bottom: 0; }
.cur-list li > div { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- currency */
.cur-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.cur-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); border-top: 4px solid var(--na); }
.cur-card.status-current { border-top-color: var(--ok); }
.cur-card.status-soon { border-top-color: var(--warn); }
.cur-card.status-expired { border-top-color: var(--bad); }
.cur-card.status-grace { border-top-color: var(--grace); }
.cur-card header { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; margin-bottom: .4rem; }
.cur-card h3 { margin: 0; font-size: 1rem; }
.cur-summary { font-weight: 700; font-size: 1.05rem; margin: .3rem 0 .2rem; }
.cur-detail { color: var(--muted); font-size: .84rem; margin: 0 0 .5rem; }
.sub-list { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .84rem; }
.sub-list li { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; align-items: center; padding: .35rem 0; border-top: 1px dashed var(--border); }
.sub-list li > span:first-child { grid-column: 1 / -1; font-weight: 600; }
.progress-list { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.prog { display: grid; grid-template-columns: 96px 1fr 38px; gap: .5rem; align-items: center; font-size: .78rem; color: var(--muted); }
.prog-bar { height: 6px; background: var(--na-bg); border-radius: 99px; overflow: hidden; }
.prog-bar span { display: block; height: 100%; background: var(--warn); border-radius: 99px; }
.prog-bar span.full { background: var(--ok); }
.prog-num { text-align: right; font-variant-numeric: tabular-nums; }
.pax-table th[scope=row] { width: 24%; font-size: .92rem; }
.pax-table td { width: 38%; }
.pax-when { display: none; }
.pax-cell { display: flex; gap: .6rem; align-items: flex-start; }
.pax-cell > div { display: flex; flex-direction: column; }
.pax-table .progress-list { max-width: 320px; }
@media (max-width: 800px) {
  .pax-table, .pax-table tbody, .pax-table tr, .pax-table th, .pax-table td { display: block; width: 100% !important; }
  .pax-table thead { display: none; }
  .pax-table tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  .pax-table td, .pax-table th { border: 0; }
  .pax-when { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .2rem; }
}

/* ---------------------------------------------------------------- flight form */
.grid-flight-top { display: grid; grid-template-columns: 160px minmax(0, 2fr) 1fr 1fr; gap: 0 1rem; }
.grid-flight-top a.small { font-weight: 500; }
.grid-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 1rem; }
.grid-times .total-box { grid-column: 1 / -1; max-width: 240px; }
.grid-times .total-box input { font-size: 1.35rem; font-weight: 700; padding: .55rem .7rem; }
.grid-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 1rem; }
.grid-times input, .grid-counts input { font-variant-numeric: tabular-nums; }
.fill { border: 0; background: var(--accent-soft); color: var(--accent); font-size: .68rem; font-weight: 700; padding: .1rem .4rem; border-radius: 5px; cursor: pointer; }
.fill:hover { filter: brightness(.96); }
.checks-row { display: flex; gap: 1.4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.sim-note { background: var(--accent-soft); color: var(--accent); padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; }
.dim { opacity: .55; }
@media (max-width: 800px) {
  .grid-flight-top { grid-template-columns: 1fr 1fr; }
  .grid-flight-top > label:nth-child(2) { grid-column: 1 / -1; order: -1; }
  .grid-flight-top > label:first-child { grid-column: 1 / -1; }
  .sticky-actions a.btn-ghost { display: none; }
  .sticky-actions .btn { padding: .5rem .8rem; }
}

/* ---------------------------------------------------------------- records, endorsements, import, reports */
.record-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; align-items: start; }
.record-cards .card { margin: 0; }
.endorse-body { font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1.55; background: var(--surface-2); padding: .8rem 1rem; border-radius: 8px; margin: .5rem 0; }
.endorse .sig { font-size: .85rem; color: var(--muted); margin: 0; }
.template-pick { align-items: flex-end; }
.mono-ish { font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1.5; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.map-grid label { font-size: .82rem; }
.map-grid label.unmapped span { color: var(--muted); font-weight: 500; }
.map-grid select { font-size: .85rem; padding: .35rem .5rem; }
.stat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .6rem 1rem; margin: 0; }
.stat-list div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: .3rem 0; }
.stat-list dt { color: var(--muted); font-size: .88rem; }
.stat-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- auth pages */
body.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem;
  background: radial-gradient(1200px 600px at 20% -10%, #1f4a85 0%, transparent 60%), linear-gradient(160deg, #0b2545, #13315c 60%, #1c4273); }
.auth-card { background: var(--surface); border-radius: 16px; padding: 2rem 2rem 1.5rem; width: 100%; max-width: 420px; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.auth-card.wide { max-width: 760px; }
.auth-card .brand { color: var(--text); padding: 0 0 1.2rem; }
.brand-lg { font-size: 1.2rem; }
.auth-card h2 { font-size: 1.35rem; }
.grid-times label, .grid-counts label { height: calc(100% - .8rem); }
.grid-times label input, .grid-counts label input { margin-top: auto; }
