/* NTF Roster: app shell, roster grid, cell editor, day view, sheets and toasts.
   NUHS tokens (../nuhsdesign/tokens.css), Open Sans, navy. Light theme only. Phone layout at <= 720 px.
   Rule screens add css/rules.css on top of this file. */

:root {
  color-scheme: light;
  --navy: var(--n-navy, #002f6c);
  --navy-hover: var(--n-navy-hover, #2c6597);
  --navy-soft: #e8eef7;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --line: #e1e6ee;
  --line-strong: #c9d1dd;
  --grid-line: #e7ebf1;
  --ink: #26303d;
  --muted: #5b6573;          /* 5.6:1 on white, 5.1:1 on --bg */
  --link: #1f5f9e;
  --focus: var(--n-focus, #002f6c);
  --we: #eef1f6;             /* weekend column */
  --we-head: #e3e8f0;
  --hol: #fff1dd;            /* public holiday column */
  --hol-head: #ffe2b8;
  --today: #e6f0fd;
  --hard: #c62828;
  --hard-bg: #fdecec;
  --hard-ink: #9b1c1c;
  --soft: #e09a00;           /* amber marks */
  --soft-bg: #fff6e0;
  --soft-ink: #7a4b00;
  --ok: #1b7a3a;
  --ok-bg: #e7f5ec;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 1px 1px rgba(16, 30, 54, .04);
  --shadow-pop: 0 12px 32px rgba(16, 30, 54, .18), 0 2px 6px rgba(16, 30, 54, .08);
  --font: var(--n-font, "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif);
  /* grid sizes */
  --nm-w: 140px;
  --cw: 32px;
  --sw: 28px;
  --head-h: 40px;
  --bar-h: 0px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.45 var(--font);
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { color: var(--navy); }
.muted { color: var(--muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }
kbd { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f1f4f8; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; color: var(--ink); white-space: nowrap; }
.noscript { padding: 24px; }

.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--navy); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; }
.skip:focus { top: 8px; }

/* brand band: four equal quarters (tokens.css draws .n-stripe; this is the fallback) */
.n-stripe { display: grid; grid-template-columns: repeat(4, 1fr); height: 5px; flex: none; }
.n-stripe > :nth-child(1) { background: #e57200; }
.n-stripe > :nth-child(2) { background: #e4002b; }
.n-stripe > :nth-child(3) { background: #178fd7; }
.n-stripe > :nth-child(4) { background: #002f6c; }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
@media (hover: hover) { .btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); } }   /* no sticky hover after a tap */
.btn-ghost { background: var(--surface); color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--navy); background: #f7f9fc; }
.btn-danger { background: var(--hard); color: #fff; border-color: var(--hard); }
.btn-danger:hover { background: #a31f1f; }
.btn-danger-ghost { background: var(--surface); color: var(--hard-ink); border-color: #e9b9b9; }
.btn-danger-ghost:hover { border-color: var(--hard); background: var(--hard-bg); }
.btn:disabled, .btn[aria-disabled="true"] { background: #e9ecf1; color: #6b7380; border-color: #e9ecf1; cursor: default; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { min-height: 26px; padding: 0 8px; font-size: 12px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--navy);
}
.icon-btn:hover:not(:disabled) { background: var(--navy-soft); }
.icon-btn:disabled { color: #9aa3af; cursor: default; }

.linkish { background: none; border: 0; padding: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.input, input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 14px;
}
textarea { min-height: 60px; resize: vertical; line-height: 1.4; }
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--navy); }
.input:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0; padding: 10px 12px; }
legend { font-weight: 600; color: var(--navy); padding: 0 4px; }

/* toggle switch: <label class="switch"><input type=checkbox><span class="sw-track"></span><span>Label</span></label> */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0; cursor: pointer; }
.sw-track { width: 36px; height: 20px; border-radius: 999px; background: #b9c2cf; position: relative; flex: none; transition: background .15s; }
.sw-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .sw-track { background: var(--navy); }
.switch input:checked + .sw-track::after { transform: translateX(16px); }
.switch input:focus-visible + .sw-track { outline: 3px solid var(--focus); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.warn-box { background: var(--soft-bg); color: var(--soft-ink); border: 1px solid #f1d699; border-radius: var(--radius-sm); padding: 10px 12px; }
.ok-box { display: flex; align-items: center; gap: 8px; background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3cb; border-radius: var(--radius-sm); padding: 10px 12px; font-weight: 600; }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--ink); }
.pill-hol { background: var(--hol-head); color: #6b3a00; }
.pill-we { background: var(--we-head); color: #344055; }
.pill-today { background: var(--navy); color: #fff; }

/* ---------- top bars ---------- */
.demobar, .savebar {
  flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 16px; font-size: 13px;
}
.demobar { background: #fff4d1; color: #5a4300; border-bottom: 1px solid #f0dc9c; }
.demo-pill { background: #8a6200; color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.demo-text { flex: 1 1 auto; min-width: 0; }
.demobar .linkish { color: #5a4300; font-size: 13px; display: inline-flex; align-items: center; }
.savebar { background: var(--hard-bg); color: var(--hard-ink); border-bottom: 1px solid #f2c4c4; }
.savebar span { flex: 1; }

/* ---------- header ---------- */
.top { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.top-row { display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 12px 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); min-width: 0; flex: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: var(--navy); color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .04em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-dept { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

.tabs { display: flex; align-items: stretch; height: 100%; gap: 2px; margin-left: 8px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--muted); text-decoration: none;
  font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; border-top: 3px solid transparent; white-space: nowrap;
}
.tab .ic { width: 18px; height: 18px; }
.tab:hover { color: var(--navy); }
.tab[aria-current="page"] { color: var(--navy); border-bottom-color: var(--navy); }
.tab:focus-visible { outline-offset: -3px; }
.top-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; flex: none; }

.ctx-row { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 6px 12px 6px 16px; background: #f8fafc; border-top: 1px solid var(--line); }
.monthnav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.m-short { display: none; }
.month-title { margin: 0 6px; font-size: 19px; font-weight: 600; color: var(--navy); min-width: 9.4em; text-align: center; white-space: nowrap; }   /* fixed width: the arrows don't move between months */
body[data-tab="people"] .ctx-row { display: none; }   /* the month and Auto-fill do nothing on People */
.monthnav #today { margin-left: 8px; }
.ctx-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.problems {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 13px; border: 1px solid transparent; white-space: nowrap;
}
.problems .ic { width: 18px; height: 18px; }
.problems.has-hard { background: var(--hard-bg); color: var(--hard-ink); border-color: #f1c3c3; }
.problems.is-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.problems:hover { filter: brightness(.97); }
.p-soft { color: var(--muted); font-weight: 400; padding-left: 8px; border-left: 1px solid rgba(0, 0, 0, .15); }

.main { flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; }
.main:focus { outline: none; }
.view { min-height: 100%; }
.view-host { min-height: 100%; }
.view-roster, .view-roster > .view-host { height: 100%; min-height: 0; }
.view-roster { display: flex; flex-direction: column; }
.view-roster > .view-host { flex: 1 1 auto; }
/* views other than roster and day get a comfortable page */
.view-people .view-host, .view-rules .view-host, .view-check .view-host, .view-more .view-host { max-width: 1180px; margin: 0 auto; padding: 16px; }
.view-more > .link-card { margin: 16px 16px 0; }

.bottombar { display: none; }

/* ---------- placeholders, welcome ---------- */
.empty-card, .welcome-card { max-width: 560px; margin: 48px auto; text-align: center; padding: 32px 28px; }
.empty-card h2, .welcome-card h2 { margin: 12px 0 8px; font-size: 22px; font-weight: 600; }
.empty-card p, .welcome-card p { margin: 0 0 12px; }
.empty-ic { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--navy-soft); color: var(--navy); }
.empty-ic .ic { width: 28px; height: 28px; }
.welcome { padding: 0 16px; }
.welcome-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.link-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); padding: 14px 16px; }
.lc-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--navy-soft); color: var(--navy); flex: none; }
.lc-text { display: flex; flex-direction: column; flex: 1; }
.lc-text strong { color: var(--navy); }
.lc-text span { color: var(--muted); font-size: 13px; }
.lc-go { color: var(--muted); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 6px 6px 16px;
  background: #1d2735; color: #fff; border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 14px;
  animation: toast-in .18s ease-out; max-width: 100%;
}
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.toast-warn { background: #5a3d00; }
.toast-error { background: #8e1a1a; }
.toast-msg { flex: 1; min-width: 0; }
.toast-act { background: none; border: 0; color: #9fd0ff; font-weight: 700; padding: 8px 10px; border-radius: 6px; }
.toast-act:hover { background: rgba(255, 255, 255, .1); }
.toast-x { display: grid; place-items: center; width: 32px; height: 32px; background: none; border: 0; color: #c9d3df; border-radius: 6px; }
.toast-x:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.toast-x .ic { width: 16px; height: 16px; }
.toast :focus-visible { outline-color: #9fd0ff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- sheets (modal on desktop, bottom sheet on phone) ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 80; background: rgba(10, 24, 46, .42); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in .14s ease-out; }
.sheet-back.out { opacity: 0; transition: opacity .15s; }
.sheet { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-pop); width: 100%; max-width: 540px; max-height: min(88vh, 900px); display: flex; flex-direction: column; animation: sheet-in .16s ease-out; }
.sheet.wide { max-width: 880px; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.sheet-title { margin: 0; flex: 1; font-size: 18px; font-weight: 600; min-width: 0; }
.sheet-body { padding: 16px 20px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.sheet-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 12px 12px; }
.confirm-msg { margin: 0; font-size: 15px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.kbd-table { border-collapse: collapse; width: 100%; }
.kbd-table th, .kbd-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-weight: 400; vertical-align: middle; }
.kbd-table th { width: 46%; }

/* ======================================================================
   Roster: toolbar, grid, cover rows, cell marks
   ====================================================================== */
.roster { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.r-toolbar { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.r-searchwrap { position: relative; display: flex; align-items: center; }
.r-search-ic { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.r-search-ic .ic { width: 16px; height: 16px; }
.r-searchwrap .r-search { width: 190px; padding-left: 30px; min-height: 34px; }
.r-sel { min-height: 34px; max-width: 220px; padding-right: 28px; }
.tbtn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13px;
}
.tbtn .ic { width: 17px; height: 17px; color: var(--muted); }
.tbtn:hover { border-color: var(--navy); }
.tbtn[aria-pressed="true"] { background: var(--navy-soft); border-color: var(--navy); color: var(--navy); }
.tbtn[aria-pressed="true"] .ic { color: var(--navy); }
.typed { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.typed kbd { font-size: 13px; background: var(--navy); color: #fff; border-color: var(--navy); }

.r-paintbar { flex: none; display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; padding: 8px 16px; background: #f5f8fc; border-bottom: 1px solid var(--line); }
.pb-label { font-weight: 700; color: var(--navy); font-size: 13px; }
.pb-group { display: inline-flex; flex-wrap: wrap; gap: 4px; padding-right: 8px; border-right: 1px solid var(--line); }
.pb-hint { color: var(--muted); font-size: 12px; flex: 1 1 200px; }
.pchip {
  min-width: 36px; min-height: 30px; padding: 0 8px; border-radius: 5px; font-weight: 700; font-size: 12px;
  background: var(--c); color: var(--i); border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.pchip.k-request { background: var(--surface); color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.pchip[aria-pressed="true"] { border-color: var(--navy); box-shadow: 0 0 0 2px #fff inset, 0 0 0 1px var(--navy); transform: translateY(-1px); }
.pchip-clear { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pchip-clear .ic { width: 15px; height: 15px; }

.r-banner { flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 16px 0; padding: 10px 14px; background: #eef4fc; border: 1px solid #cbdcf2; border-radius: var(--radius); color: #1d3557; }
.rb-ic { color: var(--navy); }
.rb-text { flex: 1 1 280px; font-size: 13px; }

.r-body { flex: 1 1 auto; min-height: 0; position: relative; padding: 10px 12px 12px; display: flex; flex-direction: column; }
.r-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overscroll-behavior: contain; }
.r-scroll:focus { outline: none; }

.grid {
  border-collapse: separate; border-spacing: 0; table-layout: fixed;
  width: max(100%, calc(var(--nm-w) + var(--days) * var(--cw) + var(--sums) * var(--sw)));
  font-size: 12px;
}
.grid col.col-nm { width: var(--nm-w); }
.grid col.col-s { width: var(--sw); }
.grid th, .grid td { padding: 0; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); background: var(--surface); }
.grid td.we { background: var(--we); }
.grid td.hol { background: var(--hol); }
.grid td.td { background: var(--today); }
.grid td.we.td, .grid td.hol.td { background: #dde9fa; }

/* header row */
.grid thead th { position: sticky; top: 0; z-index: 4; height: var(--head-h); background: #f7f9fc; border-bottom: 1px solid var(--line-strong); font-weight: 600; }
.grid th.nh { left: 0; z-index: 6; text-align: left; padding: 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; border-right: 1px solid var(--line-strong); }
.grid th.dh { text-align: center; }
.grid th.dh.we { background: var(--we-head); }
.grid th.dh.hol { background: var(--hol-head); }
.grid th.dh.td { background: var(--navy); color: #fff; }
.grid th.dh.td .wd { color: #d6e2f3; }
.dh-in { display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; line-height: 1.05; cursor: default; }
.dh-in .wd { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.dh-in .dn { font-size: 13px; font-weight: 700; }
.grid th.dh.hol .dh-in::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: #c45f00; margin-top: 2px; }
.grid th.sh { font-size: 11px; color: var(--muted); text-align: center; cursor: help; }
.grid .s1 { border-left: 2px solid var(--line-strong); }
.grid th.sh abbr { text-decoration: none; }

/* group rows */
.grp-row th.grp { position: sticky; top: var(--head-h); z-index: 3; height: 24px; text-align: left; background: #edf1f7; border-bottom: 1px solid var(--line-strong); color: var(--navy); }
.grp-label { position: sticky; left: 0; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.grp-n { font-weight: 600; color: var(--muted); background: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; letter-spacing: 0; }

/* name column */
.grid th.nm { position: sticky; left: 0; z-index: 2; text-align: left; font-weight: 400; border-right: 1px solid var(--line-strong); }
.nm-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 31px; padding: 0 8px 0 10px;
  border: 0; background: transparent; text-align: left; color: var(--ink); font-size: 13px; font-weight: 600;
}
.nm-btn:hover { color: var(--navy); background: #f3f6fb; }
.nm-btn:focus-visible { outline-offset: -3px; }
.nm-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagb { flex: none; font-size: 10px; font-weight: 700; line-height: 15px; padding: 0 4px; border-radius: 3px; background: #fff0c2; color: #6d4c00; }
.tagb-pt { background: #e6eef9; color: #234a7d; }
.grid tbody tr:hover th.nm, .grid tbody tr:hover th.nm .nm-btn { background: #f3f6fb; }

/* cells */
.grid td.c { height: 32px; }
.grid td.off { background: repeating-linear-gradient(135deg, #f5f6f8 0 4px, #eceef2 4px 8px); }
.cell {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 100%; min-height: 31px; padding: 2px 1px; border: 0; background: transparent; color: inherit; overflow: hidden;
}
.cell:hover { background: rgba(0, 47, 108, .06); }
.cell:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; z-index: 1; }
.cell[tabindex="0"] { box-shadow: inset 0 0 0 2px rgba(0, 47, 108, .55); }
/* painting: a mouse drags across cells; on touch a swipe still scrolls and a tap paints one cell */
.painting .cell { cursor: crosshair; }
.r-paintbar { position: sticky; top: 0; z-index: 6; }
.pb-done { flex: none; margin-left: auto; }

.chip {
  display: inline-block; max-width: 100%; min-width: 22px; padding: 0 3px; border-radius: 3px;
  background: var(--c, #e0e0e0); color: var(--i, #333); font-weight: 700; font-size: 11px; line-height: 15px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: clip; letter-spacing: -.01em;
}
.chip.sm { font-size: 10.5px; letter-spacing: -.05em; padding: 0 1px; }
.chip.rq { background: transparent; color: var(--c, #0b5394); box-shadow: inset 0 0 0 1px var(--c, #0b5394); font-weight: 600; }
.chip.au { background-image: linear-gradient(to top, rgba(255, 255, 255, .5) 0 2px, transparent 2px); }
.chip.dx { background: transparent; color: #5f6773; font-weight: 600; min-width: 0; }
.chip.unk { background: #fff; color: #333; box-shadow: inset 0 0 0 1px #999; border-style: dashed; }
.chip.ghost { background: #eef1f6; color: var(--ink); }
.no-req .chip.rq { display: none; }

/* marks: violation corner, note dot, lock */
.vx { position: absolute; top: 0; right: 0; width: 0; height: 0; border-style: solid; border-width: 0 9px 9px 0; border-color: transparent; pointer-events: none; }
.vx.vh { border-right-color: var(--hard); }
.vx.vs { border-right-color: var(--soft); }
/* a problem about the person's whole month (fair share, monthly minimum): a dot after the name */
.vx-nm { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-left: 2px; }
.vx-nm.vh { background: var(--hard); }
.vx-nm.vs { background: var(--soft); }
.nd { position: absolute; left: 3px; top: 3px; width: 5px; height: 5px; border-radius: 50%; background: #1f5f9e; pointer-events: none; }
.lk {
  position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; pointer-events: none; opacity: .75;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4' y='10' width='16' height='12' rx='2' fill='%23384456'/%3E%3Cpath d='M8 10V7a4 4 0 018 0v3' fill='none' stroke='%23384456' stroke-width='3'/%3E%3C/svg%3E");
}

/* highlight one code: other chips fade (rules added per render) */
.grid.hi .chip.dx { opacity: .14; }

/* paint preview */
.cell.p-add { background: rgba(0, 47, 108, .1); box-shadow: inset 0 0 0 2px var(--navy); }
.cell.p-add[data-paint]::after { content: attr(data-paint); position: absolute; inset: auto 1px 1px auto; font-size: 9px; font-weight: 700; color: var(--navy); }
.cell.p-del { background: rgba(198, 40, 40, .1); box-shadow: inset 0 0 0 2px var(--hard); }
.cell.p-del .chip { text-decoration: line-through; opacity: .6; }

/* summary columns */
.grid td.sc { text-align: center; font-weight: 700; font-size: 12px; color: var(--ink); background: #fafbfd; font-variant-numeric: tabular-nums; }
.grid td.sc.zero { color: #9aa3af; font-weight: 400; }
.nobody { padding: 32px !important; text-align: center; color: var(--muted); }

/* cover rows (stick to the bottom of the grid on laptops) */
.grid tfoot th, .grid tfoot td { position: sticky; bottom: var(--b, 0); z-index: 3; height: 24px; background: #f7f9fc; border-top: 0; }
.grid tfoot tr:first-child th, .grid tfoot tr:first-child td { box-shadow: inset 0 1px 0 var(--line-strong); }
.grid tfoot th.cov-nm { left: 0; z-index: 5; padding: 0 10px; font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.grid td.cov { text-align: center; font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; cursor: help; }
.grid td.cov.ok { color: var(--ok); }
.grid td.cov.short { background: var(--hard-bg); color: var(--hard-ink); }
.grid td.cov.over { background: var(--soft-bg); color: var(--soft-ink); }
.grid td.cov.na { background: #f7f9fc; }

.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { background: #ffe9a8; } 100% { } }

/* ---------- cell editor (popover on laptops, bottom sheet on phones) ---------- */
.popover {
  position: fixed; z-index: 60; width: 380px; max-width: calc(100vw - 16px); max-height: min(82vh, 760px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: var(--shadow-pop); animation: sheet-in .12s ease-out;
}
.pop-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 8px 10px 16px; border-bottom: 1px solid var(--line); }
.pop-title { margin: 0; flex: 1; font-size: 16px; font-weight: 600; display: flex; flex-direction: column; min-width: 0; }
.pop-sub { font-size: 13px; font-weight: 400; color: var(--muted); }
.pop-body { overflow: auto; padding: 12px 16px 14px; }

.ced { display: flex; flex-direction: column; gap: 12px; }
.ced-info { margin: 0; font-size: 12.5px; color: var(--muted); background: #f5f7fa; border-radius: 6px; padding: 7px 10px; }
.ced-info .chip { margin-right: 4px; }
.ced-viol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ced-viol li, .plist li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.35; padding: 6px 8px; border-radius: 6px; }
.ced-viol li.vh, .plist li.vh { background: var(--hard-bg); color: var(--hard-ink); }
.ced-viol li.vs, .plist li.vs { background: var(--soft-bg); color: var(--soft-ink); }
.vi { flex: none; margin-top: 1px; }
.vi .ic { width: 16px; height: 16px; }
.ced-viol .muted { color: inherit; opacity: .8; }
.ced-sec { display: flex; flex-direction: column; gap: 6px; }
.ced-h { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ced-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tchip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 9px 0 0; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); font-size: 12px; overflow: hidden;
}
.tc-code { align-self: stretch; display: grid; place-items: center; min-width: 34px; padding: 0 6px; font-weight: 700; background: var(--c); color: var(--i); }
.tchip.k-request .tc-code { background: var(--surface); color: var(--c); box-shadow: inset -1px 0 0 var(--line); }
.tc-name { color: var(--muted); max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tchip:hover { border-color: var(--navy); }
.tchip.on { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); background: var(--navy-soft); }
.tchip.on .tc-name { color: var(--navy); font-weight: 600; }
.tchip.on::after { content: ""; width: 12px; height: 12px; margin-left: -1px; flex: none; background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23002f6c' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tchip.au .tc-code { background-image: linear-gradient(to top, rgba(255, 255, 255, .55) 0 2px, transparent 2px); }
/* the editor shows only the common codes by default: name labels hide on narrow chips */
.ced-note { width: 100%; min-height: 56px; }
.ced-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); }
.ced-row .switch { flex: 1 1 100%; font-size: 13px; }

/* ---------- one person's month ---------- */
.roster.person-mode { height: auto; }
.person-host { max-width: 1000px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.ps-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ps-id { flex: 1; min-width: 0; }
.ps-name { margin: 0; font-size: 22px; font-weight: 600; }
.ps-meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ps-nav { display: flex; gap: 4px; }
.ps-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); }
.stat .chip { font-size: 12px; line-height: 20px; min-width: 30px; }
.stat-n { font-size: 18px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--muted); }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-hdr { background: #f7f9fc; border-bottom: 1px solid var(--line-strong); }
.cal-wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 0; text-transform: uppercase; }
.cal-pad { background: #fafbfc; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 86px; padding: 5px 6px;
  border: 0; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); background: var(--surface); text-align: left; overflow: hidden;
}
.cal-day.we { background: var(--we); }
.cal-day.hol { background: var(--hol); }
.cal-day.td { box-shadow: inset 0 0 0 2px var(--navy); }
.cal-day.off { background: repeating-linear-gradient(135deg, #f5f6f8 0 4px, #eceef2 4px 8px); color: #8a929d; cursor: default; }
.cal-day:hover:not(:disabled) { background-color: #f1f5fb; }
.cal-day:focus-visible { outline-offset: -3px; }
.cd-num { display: flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: 13px; color: var(--ink); width: 100%; min-width: 0; }
.cd-hol { font-size: 10.5px; font-weight: 600; color: #8a4a00; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.cd-chips .chip { font-size: 11.5px; line-height: 18px; padding: 0 5px; }
.cd-note { font-size: 11px; color: var(--muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-day .vx { border-width: 0 12px 12px 0; }
.cal-day .lk { width: 11px; height: 11px; right: 4px; bottom: 4px; }
.ps-probs h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

/* ======================================================================
   Day view
   ====================================================================== */
.dayv { max-width: 1000px; margin: 0 auto; padding: 12px 16px 24px; }
.day-head { display: flex; align-items: center; gap: 8px; }
.day-title { flex: 1; min-width: 0; text-align: center; }
.day-h { margin: 0; font-size: 22px; font-weight: 600; }
.day-sub { margin: 4px 0 0; display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.day-arrow { width: 44px; height: 44px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 50%; }
.day-strip { display: flex; gap: 4px; overflow-x: auto; padding: 10px 2px 8px; margin: 6px 0 8px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.ds {
  flex: none; width: 44px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); scroll-snap-align: center; padding: 4px 0;
}
.ds.we { background: var(--we); }
.ds.hol { background: var(--hol); border-color: #f2cf9c; }
.ds.td { border-color: var(--navy); }
.ds[aria-current] { background: var(--navy); color: #fff; border-color: var(--navy); }
.ds[aria-current] .ds-wd { color: #d6e2f3; }
.ds:hover:not([aria-current]) { border-color: var(--navy); }
.ds-wd { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.ds-n { font-size: 15px; font-weight: 700; line-height: 1.1; }
.ds-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 2px; }
.ds-dot.vh { background: var(--hard); }
.ds-dot.vs { background: var(--soft); }
.ds-dot.none { background: transparent; }
.ds[aria-current] .ds-dot.vh { background: #ff8a8a; }
.ds[aria-current] .ds-dot.vs { background: #ffd166; }

.day-content { display: flex; flex-direction: column; gap: 12px; }
.day-card { padding: 14px 16px; }
.dc-h { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--navy); }
.dc-h .chip { font-size: 12px; line-height: 20px; min-width: 32px; padding: 0 6px; }
.dc-ic { display: grid; place-items: center; color: var(--muted); }
.dc-ic.vh { color: var(--hard); }
.dc-ic .ic { width: 18px; height: 18px; }
.dc-name { flex: 1; min-width: 0; }
.dc-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); background: #eef1f6; border-radius: 999px; padding: 1px 9px; }
.day-probs { border-color: #f1c3c3; }
.day-probs .plist li { align-items: center; }
.pl-msg { flex: 1; min-width: 0; }
.day-probs .btn-xs { flex: none; background: var(--surface); }
.day-duties { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.duty-card { border-top: 4px solid var(--c, var(--navy)); }
.cov-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 10px; }
.cov-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 6px; border-radius: 999px; }
.cov-pill .ic { width: 14px; height: 14px; }
.cov-pill.ok { background: var(--ok-bg); color: var(--ok); }
.cov-pill.short { background: var(--hard-bg); color: var(--hard-ink); }
.cov-pill.over { background: var(--soft-bg); color: var(--soft-ink); }
.who { list-style: none; margin: 0; padding: 0; }
.who li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.who li:first-child { border-top: 0; }
.who-n { font-weight: 600; }
.who-g { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; }
.who-auto { font-size: 11px; font-weight: 600; color: #3d5a80; background: #e8eef7; border-radius: 4px; padding: 0 6px; }
.who-req { font-size: 11px; font-weight: 600; color: #0b5394; box-shadow: inset 0 0 0 1px #0b5394; border-radius: 3px; padding: 0 5px; }
.dc-empty { margin: 0; font-size: 13px; }
.away { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 8px 14px; margin: 0; align-items: baseline; }
.away dt { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.away dt .chip { font-size: 11.5px; line-height: 19px; min-width: 32px; padding: 0 5px; }
.away-name { color: var(--muted); }
.away dd { margin: 0; font-size: 14px; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.notes li { padding: 6px 10px; background: #f7f9fc; border-radius: 6px; }
.day-foot { margin: 4px 0 0; text-align: center; }

/* ======================================================================
   Auto-fill dialog
   ====================================================================== */
.af { display: flex; flex-direction: column; gap: 14px; }
.af p { margin: 0; }
.af-keep { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.af-time { display: flex; gap: 8px; flex-wrap: wrap; }
.af-opt { flex: 1 1 120px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; }
.af-opt:has(input:checked) { border-color: var(--navy); background: var(--navy-soft); box-shadow: 0 0 0 1px var(--navy); }
.af-opt input { margin: 0; accent-color: var(--navy); }
.af-opt-l { font-weight: 600; }
.af-opt-s { color: var(--muted); font-size: 12px; margin-left: auto; }
.af-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.af-status { font-weight: 600; color: var(--navy); }
.af-bar { height: 8px; border-radius: 999px; background: #e6eaf0; overflow: hidden; }
.af-bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #178fd7, var(--navy)); border-radius: inherit; transition: width .25s linear; }
.af-live { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.af-num { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; background: #f7f9fc; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; color: var(--muted); }
.af-n { font-size: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.af-hard { color: var(--hard-ink); }
.af-hard.zero { color: var(--ok); }
.af-headline { font-size: 16px; font-weight: 600; color: var(--navy); }
.af-headline .muted { font-weight: 400; font-size: 13px; }
.af-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.af-cmp { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: #f7f9fc; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.af-cmp-l { font-size: 12px; color: var(--muted); }
.af-cmp-v { font-size: 20px; font-variant-numeric: tabular-nums; }
.af-before { color: var(--muted); }
.af-cmp-v .good { color: var(--ok); }
.af-cmp-v .bad { color: var(--hard-ink); }
.af-unf { background: var(--soft-bg); border: 1px solid #f1d699; border-radius: var(--radius-sm); padding: 10px 14px; color: var(--soft-ink); }
.af-unf h3 { margin: 0 0 6px; font-size: 14px; color: var(--soft-ink); }
.af-unf ul { margin: 0 0 6px; padding-left: 18px; font-size: 13px; columns: 2; column-gap: 24px; }
.af-unf .muted { color: inherit; opacity: .85; font-size: 12px; }

/* ======================================================================
   Wide screens: a little more room per day
   ====================================================================== */
@media (min-width: 1500px) {
  :root { --nm-w: 180px; }
}

/* Tablets and small laptops: icon tabs (labels stay for screen readers and tooltips) */
@media (min-width: 721px) and (max-width: 1080px) {
  .brand-dept { display: none; }
  .tabs { margin-left: 0; }
  .tab { padding: 0 11px; }
  .tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tab .ic { width: 20px; height: 20px; }
  .r-search { width: 150px !important; }
}

/* ======================================================================
   Phone (<= 720 px): compact header, bottom tab bar, bottom sheets
   ====================================================================== */
@media (max-width: 720px) {
  :root { --nm-w: 104px; --cw: 38px; --sw: 30px; --head-h: 38px; }
  body { font-size: 15px; }

  .demobar { padding: 4px 12px; font-size: 12px; gap: 8px; flex-wrap: nowrap; }
  .demo-text { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .demo-long, .demo-leave { display: none; }
  .demobar .linkish { font-size: 12px; min-height: 32px; }

  .top-row { height: 50px; padding: 0 4px 0 12px; gap: 8px; }
  .tabs { display: none; }
  .brand-mark { width: 30px; height: 30px; font-size: 10px; }
  .brand-dept { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .ctx-row { gap: 6px; padding: 4px 8px; min-height: 52px; }
  .monthnav { flex: 1 1 auto; }
  .month-title { font-size: 17px; min-width: 5.2em; margin: 0 2px; flex: 0 1 auto; }
  .m-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .m-short { display: inline; }
  .monthnav #today { margin-left: 2px; padding: 0 10px; min-height: 36px; }
  .ctx-tools { gap: 6px; }
  .problems { display: none; }   /* the Check tab in the bottom bar carries the count */
  #autofill { min-height: 44px; padding: 0 12px; }   /* the main feature keeps its label on phones */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .btn-xs { min-height: 36px; padding: 0 12px; }

  .bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr); flex: none; background: var(--surface);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20;
    box-shadow: 0 -1px 4px rgba(16, 30, 54, .05);
  }
  .bb-tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
  }
  .bb-tab .ic { width: 22px; height: 22px; }
  .bb-tab[aria-current="page"] { color: var(--navy); }
  .bb-tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--navy); }
  .bb-tab:focus-visible { outline-offset: -3px; }
  .bb-badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--hard); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

  .toasts { bottom: calc(68px + env(safe-area-inset-bottom)); }

  /* bottom sheets */
  .sheet-back { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 16px 16px 0 0; max-height: 92dvh; animation: sheet-up .2s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  .sheet.wide { max-width: none; }
  .sheet-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: #cdd4de; margin: 8px auto 0; }
  .sheet-head { padding: 6px 4px 8px 16px; }
  .sheet-body { padding: 14px 16px; }
  .sheet-foot { padding: 10px 16px; border-radius: 0; }
  .sheet-foot .btn { flex: 1 1 auto; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

  /* roster */
  .r-toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
  .r-toolbar::-webkit-scrollbar { display: none; }
  .r-toolbar > * { flex: none; }
  .r-searchwrap .r-search { width: 140px; min-height: 40px; }
  .r-sel { min-height: 40px; max-width: 160px; }
  .tbtn { min-height: 40px; }
  .r-paintbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; }
  .r-paintbar > * { flex: none; }
  .pb-group { flex-wrap: nowrap; }
  .pb-hint { display: none; }
  .r-paintbar .pb-done { order: -1; margin-left: 0; }   /* first on phones: the bar scrolls sideways */
  .pchip { min-height: 40px; min-width: 44px; }
  .r-banner { margin: 8px 12px 0; }
  .rb-text { flex-basis: 200px; }
  .r-body { padding: 8px 0 0; }
  .r-scroll { border-radius: 0; border-left: 0; border-right: 0; }
  .grid td.c { height: 36px; }
  .cell { min-height: 35px; }
  .nm-btn { font-size: 12.5px; padding: 0 4px 0 8px; min-height: 36px; }
  .grp-label { font-size: 10.5px; }
  .grid tfoot th, .grid tfoot td { position: static; }
  .grid tfoot th.cov-nm { position: sticky; left: 0; bottom: auto; }
  .grid th.dh.hol .dh-in::after { display: none; }

  .popover { display: none; }
  /* code with its name underneath, so OTC, Creg, Inj… explain themselves */
  .ced-sheet .tchip { flex-direction: column; align-items: stretch; }
  .ced-sheet .tc-name { display: block; max-width: 84px; padding: 1px 4px 2px; font-size: 10.5px; line-height: 13px; text-align: center; }
  .ced-sheet .ced-chips { gap: 6px; }
  .ced-sheet .tchip { position: relative; min-height: 42px; min-width: 52px; padding: 0; gap: 0; }
  .ced-sheet .tc-code { flex: none; min-height: 28px; min-width: 50px; font-size: 13px; }
  .ced-sheet .tchip.on { box-shadow: 0 0 0 2px var(--navy); }
  .ced-sheet .tchip.on::after { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; margin: 0; border-radius: 50%; background-color: #fff; background-size: 12px; box-shadow: 0 0 0 1.5px var(--navy); }
  .ced-sheet .tchip { overflow: visible; }
  .ced-sheet .tc-code { border-radius: 5px; }

  .person-host { padding: 12px; gap: 10px; }
  .ps-name { font-size: 19px; }
  .stat { padding: 6px 10px; }
  .cal-day { min-height: 64px; padding: 4px 3px; gap: 2px; }
  .cd-num { font-size: 12px; }
  .cd-hol, .cd-note { display: none; }
  .cd-chips .chip { font-size: 10px; line-height: 15px; padding: 0 3px; }
  .cal-wd { font-size: 10px; }

  .dayv { padding: 10px 12px 20px; }
  .day-h { font-size: 19px; }
  .day-strip { margin: 4px -12px 6px; padding: 8px 12px; }
  .day-duties { grid-template-columns: 1fr; }
  .away { grid-template-columns: 1fr; gap: 2px; }
  .away dd { margin: 0 0 8px; padding-left: 42px; }

  .af-live { gap: 6px; }
  .af-unf ul { columns: 1; }
  .af-compare { grid-template-columns: 1fr; }

  .empty-card, .welcome-card { margin: 24px auto; padding: 24px 18px; }
  .welcome-actions .btn { flex: 1 1 100%; }
  .view-people .view-host, .view-rules .view-host, .view-check .view-host, .view-more .view-host { padding: 12px; }
  .view-more > .link-card { margin: 12px 12px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  body { height: auto; overflow: visible; display: block; }
  .top-tools, .ctx-tools, .tabs, .bottombar, .r-toolbar, .r-paintbar, .r-banner, .demobar, .toasts, .skip { display: none !important; }
  .main { overflow: visible; }
  .r-scroll { overflow: visible; border: 0; box-shadow: none; }
  .grid thead th, .grid th.nm, .grp-row th.grp, .grid tfoot th, .grid tfoot td { position: static; }
}
.demo-leave-s { display: none; }
@media (max-width: 720px) { .demo-leave-s { display: inline; } }

/* ---------- More screen (ui-more.js) ---------- */
.more { display: grid; gap: 16px; max-width: 860px; margin: 0 auto; }
.more-sec { display: grid; gap: 10px; }
.more-sec > h2 { margin: 0; font-size: 18px; }
.more-sec > p, .more-p { margin: 0; color: var(--muted, #5b6573); }
.more-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.more-row label.more-lbl { font-weight: 600; }
.more-file { position: relative; }
.more-file:focus-within { outline: 3px solid var(--focus, #002f6c); outline-offset: 2px; }
.more-sub { font-size: 14px; margin: 6px 0 0; color: var(--navy, #002f6c); }
.more-hols { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.more-hols li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line, #e1e6ee); }
.more-hols .hd { min-width: 132px; font-variant-numeric: tabular-nums; }
.more-hols .hn { flex: 1; min-width: 0; }
.more-year { font-weight: 700; color: var(--navy, #002f6c); margin-top: 8px; }
.more-danger { border-color: #e9b9b9; }
.more-foot { display: grid; gap: 2px; padding: 4px 4px 24px; font-size: 12px; color: var(--muted, #5b6573); }
.imp { display: grid; gap: 14px; }
.imp h3 { margin: 0; font-size: 15px; }
.imp ul.imp-months { margin: 0; padding-left: 18px; }
.imp-people { display: grid; gap: 0; max-height: 46vh; overflow: auto; border: 1px solid var(--line, #e1e6ee); border-radius: 6px; }
.imp-person { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line, #e1e6ee); }
.imp-person:last-child { border-bottom: 0; }
.imp-person .pn { min-width: 0; }
.imp-person .pn small { display: block; color: var(--muted, #5b6573); }
.imp-person select { max-width: 190px; }
.imp-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.imp-tag.new { background: #e7f5ec; color: #1b6b35; }
.imp-tag.match { background: #e8eef7; color: #002f6c; }
.imp-codes { display: grid; gap: 6px; }
.imp-code { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.imp-code code { font-weight: 700; min-width: 54px; }
.imp-code label { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
@media (max-width: 720px) {
  .imp-person { grid-template-columns: minmax(0, 1fr) auto; }
  .imp-person .pn { grid-column: 1 / -1; }
  .imp-person select { max-width: none; width: 100%; }
  .more-row .btn { flex: 1 1 auto; }
  .more-hols .hd { min-width: 104px; }
}

/* ---------- Team sharing panel (ui-team.js) ---------- */
.team { display: grid; gap: 10px; }
.team-p { margin: 0; color: var(--muted, #5b6573); }
.team-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.team-h { margin: 8px 0 0; font-size: 15px; color: var(--navy, #002f6c); }
.team-status { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.team-status li { overflow-wrap: anywhere; }
.team-new { color: var(--soft-ink, #7a4b00); font-weight: 600; }
.team-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line, #e1e6ee); border-radius: 6px; }
.team-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line, #e1e6ee); }
.team-item:last-child { border-bottom: 0; }
.team-who { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.team-who small { display: block; color: var(--muted, #5b6573); }
.team-role { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--navy-soft, #e8eef7); color: var(--navy, #002f6c); }
.team-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) auto; gap: 8px; align-items: end; }
.team-add label { display: grid; gap: 2px; font-size: 13px; font-weight: 600; }
@media (max-width: 720px) {
  .team .btn, .team select, .team input { min-height: 44px; }
  .team-add { grid-template-columns: 1fr; }
}

/* first run: the next steps */
.welcome-steps { text-align: left; margin: 4px auto 14px; padding-left: 1.4em; max-width: 34em; color: var(--ink); font-size: 14px; line-height: 1.5; }
.welcome-steps li + li { margin-top: 4px; }

/* the grid key */
.gk { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gk-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.gk-mark { flex: none; width: 44px; display: inline-flex; justify-content: center; }
.gk-cell { position: relative; display: inline-block; width: 30px; height: 24px; border: 1px solid var(--line); background: var(--surface); }
.gk-txt { font-weight: 700; font-size: 12px; color: var(--navy); }

/* ======================================================================
   First-time help (guide.js, tour.js): Getting started, the tour, Help, Try it yourself.
   NUHS: square panels with a navy top rule; only controls are rounded (5 px), badges 3 px.
   ====================================================================== */
.guide-slot { flex: none; padding: 12px 12px 0; }
.welcome .guide-slot { padding: 0; }
.welcome-card.has-guide { max-width: 640px; }
.welcome-intro { text-align: center; }

/* ---------- Getting started ---------- */
.gs { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--navy); text-align: left; }
.gs-head { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-height: 56px; padding: 8px 12px 8px 16px; }
.gs-headtext { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gs-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.gs-fold { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; margin: -4px 0 -4px -4px; padding: 0 4px; border: 0; border-radius: var(--radius-sm); background: none; color: inherit; font: inherit; }
@media (hover: hover) { .gs-fold:hover { background: var(--navy-soft); } }   /* no sticky hover after a tap */
.gs-chev .ic { width: 16px; height: 16px; transition: transform .15s; }
.gs-chev.is-open .ic { transform: rotate(90deg); }
.gs-progress { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gs-meter { flex: none; display: inline-flex; gap: 3px; }
.gs-meter i { width: 16px; height: 6px; background: #dce3ec; }
.gs-meter i.on { background: var(--navy); }
.gs-sub { margin: 0; font-size: 13px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-nextline { margin: 0; font-size: 13px; color: var(--muted); }
.gs-nextline strong { color: var(--navy); font-weight: 600; }
.gs-note { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.gs-hide { min-height: 36px; padding: 0 6px; font-size: 13px; color: var(--muted); }
.gs-hide:hover { color: var(--navy); }
.gs-body { border-top: 1px solid var(--line); }

/* laptop: the six steps in a row, the open one's words and buttons underneath */
.gs-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.gs-step { display: contents; }
.gs-step-btn {
  grid-row: 1; display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 8px 10px 6px 12px;
  border: 0; border-right: 1px solid var(--line); border-bottom: 3px solid transparent; background: var(--surface);
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.25;
}
.gs-step:last-child .gs-step-btn { border-right: 0; }
.gs-step-btn:hover { background: #f7f9fc; }
.gs-step-btn:focus-visible { outline-offset: -3px; }
.gs-step.is-open .gs-step-btn { background: #f1f5fa; border-bottom-color: var(--navy); color: var(--navy); }
.gs-num { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--line-strong); border-radius: 3px; background: var(--surface); font-size: 12px; font-weight: 700; color: var(--muted); }
.gs-num .ic { width: 15px; height: 15px; stroke-width: 3; }
.gs-step.is-open .gs-num { border-color: var(--navy); color: var(--navy); }
.gs-step.is-done .gs-num { background: var(--navy); border-color: var(--navy); color: #fff; }
.gs-step.is-done .gs-step-title { color: var(--muted); }
.gs-step.is-done.is-open .gs-step-title { color: var(--navy); }
.gs-step-title { flex: 1; min-width: 0; }
.gs-step-chev { display: none; color: var(--muted); }
.gs-step-chev .ic { width: 16px; height: 16px; transition: transform .15s; }
.gs-detail { grid-row: 2; grid-column: 1 / -1; display: flex; align-items: center; gap: 10px 24px; flex-wrap: wrap; padding: 12px 16px; background: #f1f5fa; }
.gs-text { flex: 1 1 360px; max-width: 72ch; margin: 0; font-size: 14px; line-height: 1.5; }
.gs-wait { font-weight: 600; color: var(--soft-ink); }
.gs-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.gs-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; padding: 6px 16px 8px; border-top: 1px solid var(--line); }
.gs-link { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 13px; font-weight: 600; color: var(--link); text-underline-offset: 2px; }
.gs-link .ic { width: 17px; height: 17px; }

/* phones and the welcome screen: the steps as a list that opens one at a time */
.gs.is-vertical .gs-steps { display: block; }
.gs.is-vertical .gs-step { display: block; border-top: 1px solid var(--line); }
.gs.is-vertical .gs-step:first-child { border-top: 0; }
.gs.is-vertical .gs-step-btn { width: 100%; min-height: 50px; padding: 8px 12px 8px 14px; border: 0; font-size: 14px; }
.gs.is-vertical .gs-step.is-open .gs-step-btn { background: none; }
.gs.is-vertical .gs-step-chev { display: grid; }
.gs.is-vertical .gs-step.is-open .gs-step-chev .ic { transform: rotate(90deg); }
.gs.is-vertical .gs-detail { display: block; padding: 0 14px 14px 46px; background: none; }
.gs.is-vertical .gs-text { margin-bottom: 10px; }
.gs.is-welcome { border: 0; margin-top: 20px; }
.gs.is-welcome .gs-head { padding: 0 0 10px; min-height: 0; border-top: 1px solid var(--line); padding-top: 16px; }
.gs.is-welcome .gs-body { border: 1px solid var(--line); border-top: 3px solid var(--navy); }
.gs.is-welcome .gs-foot { justify-content: space-between; }

/* all six done: a short "All set" before the card goes */
.gs-allset { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top-color: var(--ok); }
.gs-allset-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 3px; background: var(--ok); color: #fff; }
.gs-allset-ic .ic { stroke-width: 3; }
.gs-allset .gs-sub { white-space: normal; }

/* ---------- the tour ---------- */
.tour { position: fixed; inset: 0; z-index: 85; animation: fade-in .15s ease-out; }
.tour.is-leaving, .tour-spot.is-leaving { opacity: 0; transition: opacity .15s; }
.tour-shade { position: absolute; inset: 0; }
.tour-holes { position: fixed; inset: 0; pointer-events: none; }
.tour-dim { position: absolute; left: 0; top: 0; display: block; }
.tour-dim path { fill: rgba(8, 22, 44, .56); }
.tour-ring { position: absolute; left: 0; top: 0; border: 3px solid #178fd7; border-radius: 6px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .7); pointer-events: none; }
.tour-card {
  position: absolute; left: 0; top: 0; padding: 16px 16px 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); transition: transform .22s cubic-bezier(.2, .7, .3, 1);
}
.tour-card:focus { outline: none; }   /* (the card takes focus after a tap; keyboard use focuses Next) */
.tour.is-still .tour-card, .tour.is-still .tour-prog span { transition: none; }
.tour-prog { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: #dce3ec; }
.tour-prog span { display: block; width: 0; height: 100%; background: var(--navy); transition: width .22s; }
.tour-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -4px 2px 0; }
.tour-count { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tour-skip { min-height: 32px; padding: 0 4px; font-size: 13px; color: var(--muted); }
.tour-skip:hover { color: var(--navy); }
.tour-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; line-height: 1.25; color: var(--navy); }
.tour-text { margin: 0 0 14px; font-size: 14px; line-height: 1.5; }
.tour-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.tour-next { min-width: 92px; }

/* "Show me": the control lit, the page still usable underneath */
.tour-spot { position: fixed; inset: 0; z-index: 84; pointer-events: none; animation: fade-in .15s ease-out; }
.tour-spot .tour-dim path { fill: rgba(8, 22, 44, .38); }
.tour-tip { position: absolute; left: 0; top: 0; margin: 0; padding: 8px 12px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; line-height: 1.35; }

/* ---------- Help sheet ---------- */
.help-list { list-style: none; margin: -16px -20px; padding: 0; }
.help-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 66px; padding: 10px 20px;
  border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); text-align: left; text-decoration: none;
}
.help-list li:last-child .help-row { border-bottom: 0; }
.help-row:hover { background: #f5f8fc; }
.help-row:focus-visible { outline-offset: -3px; }
.help-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--navy-soft); color: var(--navy); }
.help-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.help-txt strong { font-size: 15px; font-weight: 600; color: var(--navy); }
.help-txt span { font-size: 13px; color: var(--muted); }
.help-go { flex: none; color: var(--muted); }

/* ---------- Try it yourself ---------- */
.task-card {
  position: fixed; right: 16px; bottom: 16px; z-index: 81; width: 350px; max-width: calc(100vw - 24px);
  padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--line-strong);
}
/* the task card stays above windows (the cell editor, Add rule, Auto-fill), which make room for it underneath */
body.has-taskcard .sheet-back { padding-bottom: calc(var(--task-h, 0px) + 32px); }
body.has-taskcard .sheet { max-height: calc(100vh - var(--task-h, 0px) - 64px); }
.task-prog { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; height: 4px; }
.task-prog i { background: #dce3ec; }
.task-prog i.on { background: var(--navy); }
.task-card.is-done .task-prog i.on:last-of-type, .task-card.is-done .task-prog i.on { background: var(--ok); }
.task-kicker { margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.task-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--navy); }
.task-title:focus:not(:focus-visible) { outline: none; }
.task-tick { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 3px; background: var(--ok); color: #fff; }
.task-tick .ic { width: 14px; height: 14px; stroke-width: 3; }
.task-text { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.task-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.task-stop { min-height: 32px; padding: 0 4px; font-size: 13px; color: var(--muted); }
.task-stop:hover { color: var(--navy); }

@media (max-width: 720px) {
  .guide-slot { padding: 8px 8px 0; }
  .gs-head { padding: 6px 4px 6px 12px; gap: 4px 8px; flex-wrap: nowrap; }
  .gs-headtext { flex: 1 1 auto; }
  .gs-next { display: none; }
  .gs-hide { min-height: 44px; padding: 0 10px; }
  .gs-fold { min-height: 44px; margin: -8px 0 -8px -4px; }
  .gs.is-vertical .gs-step-btn { min-height: 52px; }
  .gs.is-vertical .gs-detail { padding: 0 12px 14px 12px; }
  .gs-acts .btn, .gs-foot .btn { flex: 1 1 auto; }
  .gs-link { min-height: 44px; }
  .gs.is-welcome .gs-head { padding: 14px 0 10px; }
  .welcome-card.has-guide { padding: 22px 14px; }

  .tour-card { padding: 14px 14px 10px; }
  .tour-card .btn { min-height: 44px; }
  .tour-skip { min-height: 44px; padding: 0 10px; margin-right: -6px; }
  .tour-foot .tour-next { flex: 1 1 auto; }
  .tour-title { font-size: 17px; }

  .help-list { margin: -14px -16px; }
  .help-row { padding: 10px 16px; }

  .task-card { left: 8px; right: 8px; width: auto; max-width: none; bottom: calc(56px + env(safe-area-inset-bottom) + 8px); padding: 14px 14px 8px; }
  .task-acts .btn, .task-acts .linkish { min-height: 44px; }
  .task-stop { padding: 0 10px; }
  body.has-taskcard .main { padding-bottom: calc(var(--task-h, 0px) + 12px); }
  /* with a window open the tab bar is covered: the card goes to the bottom, the window sits above it */
  body.has-taskcard:has(.sheet-back) .task-card { bottom: calc(8px + env(safe-area-inset-bottom)); }
  body.has-taskcard .sheet-back { padding-bottom: calc(var(--task-h, 0px) + 16px + env(safe-area-inset-bottom)); }
  body.has-taskcard .sheet { max-height: calc(100dvh - var(--task-h, 0px) - 40px); border-radius: 16px; }
  body.has-taskcard .toasts { bottom: calc(68px + var(--task-h, 0px) + 10px + env(safe-area-inset-bottom)); }
}
@media print { .tour, .tour-spot, .task-card, .guide-slot { display: none !important; } }
