/* Flight Ops Cockpit 3.1.18 — ergonomics.
   Loaded LAST in <head>, after every inline <style>, so these rules settle the cascade on purpose
   rather than by adding a 30th override block inside index.html. Each section names the finding
   from the Ergonomics & OCC Link Review it closes. */

/* ---------- 3. Night: the page itself goes dark, not just the body ---------- */
html:has(body.night-mode){background:#0d1115!important;color-scheme:dark}
body.night-mode{color-scheme:dark}

/* Day details pop-up (was white with pale text at night). */
body.night-mode .cms-day-modal-backdrop{background:rgba(0,0,0,.72)!important}
body.night-mode .cms-day-modal{background:#151a1e!important;color:#e9ebe8!important;border:1px solid #3a4146!important;box-shadow:0 18px 50px rgba(0,0,0,.6)!important}
body.night-mode .cms-day-modal-head{border-color:#2c3337!important}
body.night-mode .cms-day-modal-head h3{color:#f3f4f2!important}
body.night-mode .cms-day-modal-head small{color:#c9a95c!important}
body.night-mode .cms-day-close{background:#24292d!important;color:#f3f4f2!important;border:1px solid #454c51!important}
body.night-mode .cms-day-op{background:#1c2226!important;border-color:#3a4146!important;color:#e9ebe8!important}
body.night-mode .cms-day-op.mine{border-left-color:#d1b36c!important}
body.night-mode .cms-day-op-title{color:#f3f4f2!important}
body.night-mode .cms-day-op-sub{color:#b8bdb9!important}
body.night-mode .cms-day-detail-grid>div{background:#12171a!important;border-color:#343b40!important}
body.night-mode .cms-day-detail-grid label{color:#aab0ad!important}
body.night-mode .cms-day-detail-grid b{color:#f3f4f2!important}

/* Calendar chips and legend: dark fills, light text, the status kept in the left edge colour. */
body.night-mode .cms-cal-chip{background:#1d3442!important;color:#d7ecf8!important;border-color:#2f5a72!important}
body.night-mode .cms-cal-chip b,body.night-mode .cms-cal-chip span{color:inherit!important}
body.night-mode .cms-cal-chip.complete,body.night-mode .cms-cal-chip.completed{background:#1f3d29!important;color:#d9f2e0!important;border-color:#2f6a43!important}
body.night-mode .cms-cal-chip.maint,body.night-mode .cms-cal-chip.maintenance{background:#4a201d!important;color:#ffe1dc!important;border-color:#87362f!important}
body.night-mode .cms-cal-chip.booked,body.night-mode .cms-cal-chip.quote{background:#3b2a45!important;color:#efe2f6!important;border-color:#6a4a7c!important}
body.night-mode .cms-cal-chip.live,body.night-mode .cms-cal-chip.flying{background:#123e52!important;color:#dff4ff!important;border-color:#2a7aa0!important}
body.night-mode .cms-cal-chip.company{opacity:.92}
body.night-mode .cms-cal-legend span{background:#1c2226!important;color:#d9ddda!important;border-color:#3a4146!important}

/* Current Ops grid: the 3.1.13 night rules were losing to later day rules. */
body.night-mode #cmsScheduleCard .co-op{background:#1a2022!important;color:#e8e8e4!important}
body.night-mode #cmsScheduleCard .co-op.booked{background:#4a3156!important;color:#f3e9f7!important}
body.night-mode #cmsScheduleCard .co-op.crew{background:#3f3046!important;color:#f1e8f4!important}
body.night-mode #cmsScheduleCard .co-op.live{background:#17465b!important;color:#dff4ff!important}
body.night-mode #cmsScheduleCard .co-op.complete{background:#214b2d!important;color:#def5e4!important}
body.night-mode #cmsScheduleCard .co-op.maint{background:#632622!important;color:#ffe5e1!important}
body.night-mode #cmsScheduleCard .co-op b,body.night-mode #cmsScheduleCard .co-op span{color:inherit!important;opacity:1!important}
body.night-mode #cmsScheduleCard .co-op .co-billing{color:#f0ce79!important}
body.night-mode #cmsScheduleCard .co-table th.mine,body.night-mode #cmsScheduleCard .co-table td.mine{background:#2a2416!important;color:#f0d68e!important;border-color:#8a6d2f!important}

/* PDF previews: the empty state faded from white at night. */
body.night-mode .pdf-preview-empty{background:#12171a!important;color:#b8bdb9!important}

/* ---------- 4. Navigation ---------- */
/* The header scrolls away, so the nav pins to the very top (it pinned 78 px down, leaving a band). */
#nav{top:0!important;z-index:60!important}
/* The two empty duty buttons were drawn as a 16 x 6 sliver. */
#startDuty:empty,#finishDuty:empty{display:none!important}

/* iPad portrait and mini (744 / 820): every tab visible at once, no clipped labels, no sideways scroll. */
@media (max-width:900px){
  #nav{display:grid!important;grid-template-columns:repeat(9,minmax(0,1fr))!important;gap:4px!important;padding:6px 8px!important;overflow:visible!important;min-height:0!important}
  #nav>button{min-width:0!important;width:auto!important;min-height:52px!important;padding:6px 2px!important;flex-direction:column!important;justify-content:center!important;gap:3px!important;font-size:11px!important;line-height:1.1!important;white-space:normal!important;text-align:center!important}
  #nav>button .nav-label{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;font-size:11px!important;letter-spacing:.02em!important}
  #nav>button .nav-state{position:absolute!important;top:3px!important;right:3px!important}
  #nav>button{position:relative!important}
  #nav::after,#nav .nav-scroll-hint{display:none!important}
}

/* On duty, the Active Sector comes before the schedule. */
#today.screen.active.on-duty{display:flex!important;flex-direction:column}
#today.on-duty>.v6-layout{order:-1;margin-bottom:12px}
#today.on-duty>.syncbar{order:-2}

/* Current Ops never widens the page; it scrolls inside its card. */
#cmsScheduleCard,.cms-schedule-grid,.cms-schedule-pane,#cmsCompanySchedule{min-width:0;max-width:100%}
#cmsScheduleCard .co-scroll{max-width:100%!important;width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch}

/* ---------- 5. Touch targets: 44 px, and readable small type ---------- */
#nav>button,.btn,.theme-toggle button,[data-theme-set],#cmsViewToggle button,.cms-day-close{min-height:44px}
.btn.small{min-height:44px!important;padding-left:14px!important;padding-right:14px!important}
#certCheck,#fdpSplitEnabled{width:28px!important;height:28px!important;min-width:28px;accent-color:#b79143;flex:0 0 auto}
label:has(#certCheck){display:flex!important;align-items:center;gap:10px;min-height:44px;cursor:pointer}
#sectorList .btn,#sectorList button{min-height:44px}
body.night-mode .mini{color:#b8bdb9}

/* ---------- Banners added in 3.1.18 ---------- */
#undoBar{position:fixed;left:50%;bottom:calc(88px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:9000;display:none;align-items:center;gap:10px;padding:10px 12px 10px 16px;border-radius:14px;background:#111518;color:#f3f4f2;border:1px solid #b79143;box-shadow:0 10px 30px rgba(0,0,0,.35);font:600 15px/1.2 Poppins,system-ui,sans-serif;max-width:calc(100vw - 32px)}
#undoBar .btn{min-height:44px;min-width:76px}
#undoBar.show{display:flex}
#storageBanner,#occLinkBanner{display:flex;align-items:center;gap:12px;justify-content:space-between;margin:8px 12px;padding:10px 14px;border-radius:12px;font:600 14px/1.3 Poppins,system-ui,sans-serif}
#storageBanner{background:#7a1f19;color:#fff;border:1px solid #c0392b}
#occLinkBanner{background:#fff6dd;color:#5a4410;border:1px solid #d9b45a}
#occLinkBanner.refused{background:#7a1f19;color:#fff;border-color:#c0392b}
body.night-mode #occLinkBanner{background:#2a2416;color:#f0d68e;border-color:#8a6d2f}
body.night-mode #occLinkBanner.refused{background:#5a1a16;color:#ffe1dc;border-color:#a33}
#occLinkBanner .btn,#storageBanner .btn{min-height:44px;flex:0 0 auto}
#storageBanner[hidden],#occLinkBanner[hidden]{display:none}

/* ---------- Trim sheet frame: fills the screen below the header and nav ---------- */
.wandb-frame{display:block;width:100%;height:calc(100dvh - 190px - env(safe-area-inset-top) - env(safe-area-inset-bottom));min-height:560px;border:0;border-radius:14px;background:transparent}

/* Small type: nothing a pilot reads at arm's length below 11 px (the review measured 6–10 px). */
.cms-cal-num,.pill,.section-kicker,.v302-status-pill,.v302-theme-btn,.next-action,.seg,.badge,.eyebrow,.k,.rec-pill,.rec-group-title,.side-label,.v25-version{font-size:11px!important}
.cms-cal-chip,.cms-cal-chip b,.cms-cal-chip span,.cms-cal-legend span,.cms-next-label,#cmsMyNext small,#cmsMyNext b,#cmsMyNext span,.rec-src,table th{font-size:11px!important}
.cms-calendar-title small,.cms-calendar-weekdays>div,.compliance-tile .label{font-size:11px!important}
.cms-cal-num span{font-size:9px!important;padding:1px 5px!important}
.fdp-simple-strip span,.fdp-simple-strip small{font-size:11px!important}
