:root {
  --bg: #f4f6f9; --card: #fff; --text: #1b2430; --muted: #5d6b7c; --line: #dde3ea;
  --brand: #1f3a5f; --brand-2: #2d5b8f; --accent: #f2b632;
  --ok: #1e7b4b; --ok-bg: #e3f4ea; --bad: #b42318; --bad-bg: #fde8e6; --warn-bg: #fff4d6;
  --s1: #4b5fa8; --s2: #c58a12; --s3: #7a3f8f; --s4: #2f8a6b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --card: #1a212b; --text: #e6ebf1; --muted: #9aa8b8; --line: #2c3644;
    --brand: #16283f; --brand-2: #6d9bd1; --ok: #5fd193; --ok-bg: #173526; --bad: #ff8a80; --bad-bg: #3d1c1a; --warn-bg: #3a3116;
    --s1: #8b9cf0; --s2: #f0b84a; --s3: #c28ad6; --s4: #6fd1ad; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand-2); }
h2 { margin: 0 0 4px; font-size: 1.35rem; }
h3 { margin: 0 0 10px; font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
h4 { margin: 12px 0 4px; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--bad); }
.ok-text { color: var(--ok); font-weight: 600; }
code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--brand); color: #fff; flex-wrap: wrap; }
.brand { font-weight: 700; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #dbe6f3; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.navmenu { position: relative; margin: 0; }
.navmenu summary { list-style: none; cursor: pointer; color: #dbe6f3; padding: 6px 10px; border-radius: 6px; }
.navmenu summary::-webkit-details-marker { display: none; }
.navmenu summary::after { content: ' ▾'; font-size: .75em; }
.navmenu summary.active, .navmenu summary:hover, .navmenu[open] summary { background: rgba(255,255,255,.15); color: #fff; }
.navmenu > div { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 140px; display: flex; flex-direction: column;
  padding: 4px; background: var(--brand, #1f3a5f); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.who { font-size: .85rem; color: #dbe6f3; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

main { max-width: 1880px; margin: 0 auto; padding: 20px 20px 90px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.narrow { max-width: 420px; margin: 40px auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; align-items: start; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.loading { padding: 40px 0; text-align: center; }

label { display: block; margin: 0 0 12px; font-size: .9rem; font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
.days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.chk input { width: auto; min-height: 0; margin: 0; }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--brand-2); }

button, .btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; text-decoration: none; display: inline-block; min-height: 40px; }
button:hover, .btn:hover { border-color: var(--brand-2); }
button.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
button.danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
button.small { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
button.icon { border: 0; background: none; padding: 4px 8px; min-height: 32px; color: var(--muted); }
button.icon:hover { color: var(--text); }

.login { text-align: center; } .login label { text-align: left; } .login button { width: 100%; }

.tag { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-weight: 500; }
.tag.short { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill { display: inline-block; padding: 4px 10px; margin: 2px 4px 2px 0; border-radius: 8px; background: var(--bg); border-left: 4px solid var(--line); }
.pill.shift-1 { border-color: var(--s1); } .pill.shift-2 { border-color: var(--s2); } .pill.shift-3 { border-color: var(--s3); } .pill.shift-4 { border-color: var(--s4); }
.pill.leave { border-color: var(--ok); background: var(--ok-bg); } .pill.leave.pending { border-color: var(--accent); background: var(--warn-bg); }
.status { font-size: .75rem; text-transform: uppercase; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.status.pending { background: var(--warn-bg); } .status.approved { background: var(--ok-bg); color: var(--ok); }
.status.denied { background: var(--bad-bg); color: var(--bad); } .status.cancelled { background: var(--bg); color: var(--muted); }
.status.awaiting { background: var(--warn-bg); } .status.declined { background: var(--bad-bg); color: var(--bad); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #1f1f1f; font-size: .72rem; font-weight: 700; text-align: center; }
.subtabs { margin: 0 0 12px; flex-wrap: wrap; }
.swap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
@media (max-width: 520px) { .swap { grid-template-columns: 1fr; } }
.card.added .req-head h3 { margin: 0; }
.card.attention { border-left: 4px solid var(--accent); }
form.concur, form.review-swap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.concur input, form.review-swap input { flex: 1 1 200px; margin: 0; }

.agenda { list-style: none; padding: 0; }
.agenda li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.agenda li:last-child { border: 0; }
.agenda li.today .date { font-weight: 700; color: var(--brand-2); }
.agenda .date { width: 110px; flex-shrink: 0; }
.agenda .week-break { padding: 0; border-bottom: 3px solid var(--line); }

.list, .names, .vols, .menu { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.names li { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; border-bottom: 1px dashed var(--line); }
.menu a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }

.shifts { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0 16px; align-items: start; }
.card.shift { border-top: 5px solid var(--line); }
.card.shift-1 { border-top-color: var(--s1); } .card.shift-2 { border-top-color: var(--s2); } .card.shift-3 { border-top-color: var(--s3); } .card.shift-4 { border-top-color: var(--s4); }
.halves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.half { text-align: center; padding: 8px; border-radius: 8px; background: var(--bg); }
.half .count { font-size: 1.6rem; font-weight: 700; } .half .count span { font-size: 1rem; color: var(--muted); }
.half.short { background: var(--bad-bg); color: var(--bad); } .half.met { background: var(--ok-bg); color: var(--ok); }
.add-form { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.add-form input { flex: 2 1 180px; margin: 0; } .add-form select { flex: 1 1 140px; margin: 0; width: auto; }
.datenav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; } .datenav input { width: auto; margin: 0; }

.opening { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.opening:last-child { border: 0; }
.vols li { display: flex; gap: 8px; align-items: center; padding: 2px 0; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.table tr.inactive td { color: var(--muted); }
.cov th, .cov td { padding: 6px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cov td a { display: block; text-decoration: none; color: inherit; font-weight: 600; }
.cov td.short { background: var(--bad-bg); color: var(--bad); } .cov td.met { background: var(--ok-bg); color: var(--ok); }
.cov tr.shift-top th, .cov tr.shift-top td { border-top: 2px solid var(--line); }
.cov .shiftname { text-align: left; border-left: 4px solid; } .cov .shiftname.shift-1 { border-color: var(--s1); }
.cov .shiftname.shift-2 { border-color: var(--s2); } .cov .shiftname.shift-3 { border-color: var(--s3); } .cov .shiftname.shift-4 { border-color: var(--s4); }
.cov th.is-today { color: var(--brand-2); }

.tabs { display: flex; gap: 4px; } .tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; }
.tabs a.active { background: var(--brand-2); color: #fff; }
.request .req-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.review { display: flex; gap: 6px; flex-wrap: wrap; } .review input { flex: 1 1 200px; margin: 0; }

dialog { border: 0; border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 80px; z-index: 50; padding: 10px 16px; border-radius: 8px;
  background: var(--ok); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); }
@media (prefers-color-scheme: dark) { .toast { color: #111; } }

.bottomnav { display: none; }
@media (max-width: 1100px) {
  .topbar { padding: 10px 12px; gap: 4px; justify-content: space-between; }
  .topbar nav { display: none; }
  .bottomnav:not([hidden]) { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: 12px 2px; text-decoration: none; color: var(--muted); font-size: .8rem; font-weight: 600; }
  .bottomnav a.active { color: var(--brand-2); box-shadow: inset 0 3px 0 var(--brand-2); }
}
@media (max-width: 760px) {
  main { padding: 14px 12px 90px; }
  .shifts { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  .agenda .date { width: 90px; }
  .narrow { margin: 20px auto; }
}

.grouptabs { display: flex; gap: 4px; margin: 12px 0 4px; overflow-x: auto; padding-bottom: 2px; }
.grouptabs button { white-space: nowrap; min-height: 36px; padding: 6px 12px; border-radius: 99px; }
.grouptabs button.active { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; margin: 0; flex: 0 1 220px; }
.filters h3.full { flex-basis: 100%; margin: 0; }
.report td, .report th { white-space: nowrap; font-size: .85rem; }
.table.mins td, .table.mins th { padding: 6px; } .table.mins input { margin: 0; min-width: 64px; }

/* Schedule by post and bids */
.posts th, .posts td, .bids th, .bids td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; font-size: .85rem; }
.posts .postname { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; min-width: 96px; }
.posts .postname span { display: block; font-weight: 400; }
.posts .sun, .bids .sun { border-left: 2px solid var(--line); }
.posts th.is-today { color: var(--brand-2); }
.posts tr.extra th, .posts tr.extra td { background: var(--bg); }
.posts tfoot th, .posts tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
.posts tfoot td.short { background: var(--bad-bg); color: var(--bad); }
.slot { display: block; width: 100%; min-height: 28px; padding: 2px 6px; margin: 1px 0; font-size: .8rem; border-radius: 6px; white-space: nowrap; }
.slot.open { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); font-weight: 700; }
.slot .part { font-weight: 400; font-size: .72rem; }
.byofficer td { vertical-align: middle; min-width: 96px; max-width: 128px; white-space: normal; }
.byofficer td .duty { white-space: normal; line-height: 1.2; text-align: left; }
.duty { display: block; padding: 2px 6px; margin: 1px 0; font-size: .8rem; font-weight: 600; border-radius: 6px; border-left: 4px solid var(--line); background: var(--bg); white-space: nowrap; }
.duty .part { font-weight: 400; font-size: .72rem; }
.duty.shift-1 { border-left-color: var(--s1); } .duty.shift-2 { border-left-color: var(--s2); } .duty.shift-3 { border-left-color: var(--s3); } .duty.shift-4 { border-left-color: var(--s4); }
.byofficer td.dayoff { color: var(--muted); font-size: .8rem; }
.byofficer td.leave { background: var(--warn-bg); font-size: .8rem; font-weight: 600; }
.byofficer .removed { display: block; font-size: .8rem; font-weight: 600; } .byofficer td:not(.leave) .removed { background: var(--warn-bg); padding: 1px 4px; margin-bottom: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; } .legend .duty { display: inline-block; font-weight: 400; }
.bids td.off { color: var(--muted); }
.bids td.holder { text-align: left; min-width: 200px; } .bids td.holder .link { color: inherit; text-align: left; } .bids td.holder .link:hover { text-decoration: underline; } .bids td.holder .link.muted { color: var(--muted); }
.bids th .tag { display: block; margin-top: 2px; }
.bid-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.bid-day { display: flex; flex-direction: column; gap: 2px; font-size: .75rem; text-align: center; }
.bid-day > span { font-weight: 600; }
.bid-day input[name^=day] { padding: 6px 4px; margin: 0; text-align: center; font-size: .8rem; }
.bid-day input[name^=day]:disabled { background: var(--bg); }
.bid-day .chk { justify-content: center; font-size: .75rem; }
.bids th.bidno { white-space: nowrap; } .bids th.bidno button { margin-left: 6px; }
@media (max-width: 520px) { .bid-days { grid-template-columns: repeat(4, 1fr); } }

/* Printed sign-in sheets (Daily page → Print). Only the sheets print; each shift gets its own page. */
#print { display: none; }
@media print {
  @page { size: letter portrait; margin: 0.5in; }
  @page manning { size: letter portrait; margin: 0.25in; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body > :not(#print) { display: none !important; }
  #print { display: block; }
  .sheet { break-after: page; break-inside: avoid; }
  .sheet:last-child { break-after: auto; }
  .sheet header h1 { font-size: 15pt; margin: 0; }
  .sheet header p { margin: 2px 0 10px; }
  .sheet table { width: 100%; border-collapse: collapse; }
  .sheet th, .sheet td { border: 1px solid #000; padding: 0 6px; height: var(--row, 0.34in); font-size: var(--fs, 11pt); line-height: 1.1; text-align: left; vertical-align: middle; }
  .sheet th { background: #e6e6e6; font-size: 9.5pt; height: auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet tr { break-inside: avoid; }
  .sheet .sheet-post { width: 24%; } .sheet .sheet-name { width: 30%; } .sheet .sheet-sig { width: 18%; }
  .sheet td { white-space: nowrap; overflow: hidden; }
  .sheet small { margin-left: 6px; font-size: 0.8em; }
  .sheet footer { margin-top: 12px; }
  /* Manning sheet: four copies side by side, each a strip the height of the page bordered with a dashed line to cut along. */
  .manning { page: manning; display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); height: 10.45in; break-inside: avoid; }
}
/* A manning card. Styled outside print too, so the Daily page can measure it before printing. */
.mcard { border: 1px dashed #777; padding: 0.07in; overflow: hidden; font-size: var(--fs, 9pt); font-weight: 700; line-height: 1.15; }
.mtitle { font-weight: 700; margin-bottom: 2px; }
.mcard table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.mcard th, .mcard td { border: 0.5pt solid #000; padding: 0 3px; line-height: 1.15; text-align: left; font-size: var(--fs, 9pt); overflow-wrap: anywhere; vertical-align: top; }
.mcard td:first-child { width: 52%; }
.mcard .mhead th { background: #2f75b5; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mcard .mnone { color: #555; font-style: italic; }
label.check { display: flex; gap: 8px; align-items: center; margin-top: 8px; } label.check input { width: auto; margin: 0; }
label.check.module { align-items: flex-start; margin-top: 12px; } label.check.module input { margin-top: 4px; }
