/* =====================================================================
   MGEN x EPD Field Operations & Reporting Platform
   Mobile-first stylesheet.

   Written for a crew member holding a phone in one hand at a refuse
   collection point, not for a designer at a 27" monitor:

   - every control is at least 44px tall (Apple's minimum touch target)
   - nothing is revealed only on :hover, because a touchscreen has no hover
   - wide tables collapse into stacked cards below 720px
   - base font size is 16px so iOS Safari does not zoom on focus
   ===================================================================== */

:root {
  /* REQ-099 (GOV.UK 「頂欄同內容同一闊度」): one width and one side padding
     drive both the header bar and <main>, so the nav, the page title and the
     first card start on the same vertical line at every window size. */
  --page-max: 1280px;
  --page-pad: 1rem;

  --c-bg: #f6f8fb;
  --c-surface: #ffffff;
  --c-border: #e6e8eb;
  /* N1: form controls get their own, darker border (≈3:1 on white); cards and
     tables keep the pale --c-border. */
  --c-input-border: #8a96a3;
  --c-text: #182433;
  --c-muted: #5f6e7f;
  --c-primary: #066fd1;
  --c-primary-dark: #0558a8;
  --c-success: #1a7f4b;
  --c-success-dark: #14633b;
  --c-warning: #a86400;
  --c-danger: #b3261e;
  --c-danger-bg: #fdecea;
  --c-warning-bg: #fff5e0;
  --c-success-bg: #e7f5ec;
  --c-info-bg: #e6f1fa;

  --radius: 4px;
  --gap: 1rem;
  --touch: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK",
    "Microsoft JhengHei", "Noto Sans HK", "Noto Sans TC", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- layout */
.wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--gap) var(--page-pad);
}

/* REQ-099: a *worked* page (staffing grids, activity list) takes the window and
   the header bar follows it. `body:has(main.wide)` rather than a second template
   block or a body class: base.html already receives "wide" through main_class,
   and a duplicate block cannot be declared, so the stylesheet reads it from <main>.
   The side padding grows with the window (12px laptop, ~32px at 2000) so the
   page never sits on the glass (David, 2026-09-17), and bar and <main> use the
   same value. The old 1900px / 1680px caps went with it: a capped column under a
   full-width bar is exactly the misalignment REQ-099 removes. */
body:has(main.wide) {
  --page-max: none;
  --page-pad: clamp(0.75rem, 1.6vw, 2rem);
}

.wrap.wide {
  padding-block: 0.6rem 1rem;
}

.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .bar {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.5rem var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--c-text);
  text-decoration: none;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--c-muted);
}

/* 2026-10-04 品牌：Logo ＋ MGEN FieldOps／前線營運平台。Logo 高度約 48–52px，
   mobile 收細一點，避免 header 太高。 */
.brand.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-logo img {
  height: 52px;
  width: auto;
  display: block;
}

.brand-logo .brand-name {
  display: block;
  font-size: 1.08rem;
  line-height: 1.15;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.login-brand img {
  height: 64px;
  width: auto;
}

@media (max-width: 719px) {
  .brand-logo img {
    height: 44px;
  }
  .brand-logo .brand-name {
    font-size: 1rem;
  }
}

/* Navigation scrolls sideways on a phone instead of wrapping into a wall. */
.nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  padding-bottom: 0.25rem;
}

.nav a {
  flex: 0 0 auto;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  padding: 0 0.9rem;
  border-radius: var(--radius);
  color: var(--c-muted);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav a.active,
.nav a[aria-current="page"] {
  background: var(--c-info-bg);
  color: var(--c-primary-dark);
  font-weight: 600;
}

.user-chip {
  font-size: 0.85rem;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.card > h2,
.card > h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 560px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.stat .n {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat .l {
  font-size: 0.78rem;
  color: var(--c-muted);
}

/* --------------------------------------------------------------- tables */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}

table.data th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--c-muted);
}

/* Below 720px each row becomes its own card, labelled from data-label.
   A horizontally scrolling table is unusable one-handed. */
@media (max-width: 719px) {
  table.data thead {
    display: none;
  }
  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }
  table.data tr {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--c-surface);
  }
  table.data td {
    border-bottom: none;
    padding: 0.35rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
  table.data td::before {
    content: attr(data-label);
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--c-muted);
    flex: 0 0 40%;
  }
}

/* ---------------------------------------------------------------- forms */
.field {
  margin-bottom: var(--gap);
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.6rem 0.7rem;
  font-size: 1rem; /* 16px prevents iOS zoom-on-focus */
  font-family: inherit;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

textarea {
  min-height: 5rem;
}

.helptext {
  display: block;
  font-size: 0.82rem;
  color: var(--c-muted);
  margin-top: 0.25rem;
}

.errorlist {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.7rem;
  background: var(--c-danger-bg);
  color: var(--c-danger);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

ul.checkboxes {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.checkboxes li label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--touch);
  font-weight: 400;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
}

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--c-primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:active {
  background: var(--c-primary-dark);
}

.btn.secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn.danger {
  background: var(--c-danger);
}

.btn.success {
  background: var(--c-success);
  color: #fff;
}

.btn.block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: var(--gap);
}

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--c-info-bg);
  color: var(--c-primary-dark);
}

.badge.SCHEDULED { background: var(--c-info-bg); color: var(--c-primary-dark); }
.badge.RESCHEDULED { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.CANCELLED { background: var(--c-danger-bg); color: var(--c-danger); }
.badge.COMPLETED { background: var(--c-success-bg); color: var(--c-success); }
.badge.PENDING { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.ACTIVE { background: var(--c-success-bg); color: var(--c-success); }
.badge.INACTIVE { background: #eceff2; color: var(--c-muted); }
.badge.SUSPENDED { background: var(--c-danger-bg); color: var(--c-danger); }
.badge.internal { background: #efe6ff; color: #5b2ea6; }

/* Shift application window (WP01). Prefixed so the values cannot collide with
   the schedule statuses above. */
.badge.APP_NOT_OPEN { background: #eceff2; color: var(--c-muted); }
.badge.APP_OPEN { background: var(--c-success-bg); color: var(--c-success); }
.badge.APP_CLOSED { background: var(--c-warning-bg); color: var(--c-warning); }
/* Individual application status. */
.badge.SUBMITTED { background: var(--c-success-bg); color: var(--c-success); }
.badge.WITHDRAWN { background: #eceff2; color: var(--c-muted); }
/* No answer on record. Grey like WITHDRAWN on purpose: 「未提交」 is the absence
   of an answer, not a refusal, and must not read as one. */
.badge.APP_NONE { background: #eceff2; color: var(--c-muted); }

/* A POST button that sits inline next to other controls. */
.inline-form {
  display: inline-block;
  margin: 0.15rem 0;
}

.btn.small {
  min-height: 36px;
  padding: 0 0.7rem;
  font-size: 0.9rem;
}

/* A prominent notice — used for "the pool is not the roster". */
.notice {
  border: 1px solid var(--c-warning);
  background: var(--c-warning-bg);
  color: var(--c-warning);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: var(--gap);
  font-weight: 600;
}

/* Crew shift cards: one card per shift, no horizontal table on a phone. */
.shift-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.shift-card {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--c-surface);
}

/* David UAT, 2026-10-02: today's own card should be the one a leader spots
   first, not sorted in among every other scheduled day. */
.shift-card.is-today {
  background: var(--c-info-bg);
  box-shadow: inset 0 0 0 2px var(--c-primary);
}

.shift-card .shift-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shift-card .shift-card-date {
  font-weight: 700;
}

.shift-card dl {
  margin: 0.4rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.95rem;
}

.shift-card dt {
  color: var(--c-muted);
  font-size: 0.8rem;
}

.shift-card dd {
  margin: 0;
}

.shift-card .btn-row {
  margin-top: 0.6rem;
}

/* One day inside an activity card (我的更次). The day and the answer are two
   blocks rather than one run of text: at 390px 「第 1 日 · 2026-10-09 (星期五)
   13:30–21:30」 plus a badge wrapped wherever it happened to run out of room,
   and the answer — the one thing the person opened the page to check — landed
   in the middle of a broken line. */
.day-rows {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.day-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
}

.day-row-when {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.day-row-date {
  font-weight: 600;
  font-size: 0.95rem;
}

.day-row-time {
  color: var(--c-muted);
  font-size: 0.85rem;
}

/* The answer keeps its own column so it never wraps into the date. */
.day-row-answer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  text-align: right;
}

/* A day nobody can change any more is quieter, not hidden. */
.day-row-frozen {
  opacity: 0.75;
}

/* The estate's district, beside its name — the same pairing the round answer
   page uses, so a colleague reading both sees one estate named one way. */
.day-estate-district {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--c-muted);
}

/* ------------------------------------------------------------- messages */
.messages {
  list-style: none;
  margin: 0 0 var(--gap);
  padding: 0;
}

.messages li {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.messages li.success { background: var(--c-success-bg); color: var(--c-success); }
.messages li.error { background: var(--c-danger-bg); color: var(--c-danger); }
.messages li.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.messages li.info { background: var(--c-info-bg); color: var(--c-primary-dark); }

/* ---------------------------------------------------------------- misc */
.muted { color: var(--c-muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--gap);
}

.page-title h1 {
  font-size: 1.35rem;
  margin: 0;
}

.filters {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
  margin-bottom: var(--gap);
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
  }
}

/* 類型 is several ticks, shown as a menu once the script runs. */
.type-multi { position: relative; }
.type-multi-btn { display: none; width: 100%; text-align: left; cursor: pointer; }
.type-multi-panel label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0;
  padding: 0.28rem 0.15rem;
  font-weight: 400;
  cursor: pointer;
}
.type-multi-ready .type-multi-btn { display: block; }
.type-multi-ready .type-multi-panel {
  display: none;
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  min-width: 14rem;
  background: #fff;
  border: 1px solid var(--c-border, #ccc);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.type-multi-ready.is-open .type-multi-panel { display: block; }
.type-multi-panel hr { border: none; border-top: 1px solid #eee; margin: 0.25rem 0; }

.empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--c-muted);
}

.placeholder {
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--c-muted);
  background: var(--c-surface);
}

.internal-block {
  border-left: 3px solid #5b2ea6;
  background: #faf7ff;
  padding: 0.6rem 0.8rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-top: 0.5rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  border-left: 2px solid var(--c-border);
  padding: 0 0 1rem 0.9rem;
  margin-left: 0.3rem;
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -0.34rem;
  top: 0.4rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--c-primary);
}

.site-footer {
  padding: var(--gap);
  text-align: center;
  color: var(--c-muted);
  font-size: 0.8rem;
}

/* Roster block inside the activity workspace (S2-005 / S2-015). One row per
   person, wrapping on a phone rather than scrolling sideways. */
.roster-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
}

.roster-block h3 {
  margin: 12px 0 6px;
  font-size: 0.95rem;
}

.assignment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--c-border);
}

.assignment-row .input {
  width: auto;
  min-width: 140px;
  flex: 1 1 140px;
}

/* Paste-from-Excel grid (S5-001). Dense on purpose: the operator is checking a
   block of rows against a spreadsheet, so compact rows beat comfortable ones. */
table.data.grid td {
  padding: 4px 6px;
  vertical-align: middle;
}

table.data.grid .grid-number {
  color: var(--c-muted);
  font-size: 0.85rem;
  text-align: right;
}

.grid-input {
  width: 100%;
  min-width: 6rem;
  padding: 5px 7px;
  font-size: 0.9rem;
}

.grid-status .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f6f8fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* The estate cell is a picker, so it needs room for a full name plus the
   browser's dropdown arrow. */
table.data.grid td .grid-input[list] {
  min-width: 13rem;
}

table.data.grid td .row-select,
table.data.grid th #select-all-rows {
  width: 16px;
  height: 16px;
}

/* U-08 (David, 2026-09-14 UAT): the header and the body were misaligned
   because the table carries the class "grid", which the layout utility above
   turns into display:grid — so <thead> and <tbody> became two independent grid
   items, each sizing its own columns. The table is forced back to being a
   table, a <colgroup> fixes the column plan, the header does not wrap, and
   every status cell always carries a badge (「未填」 for an empty row).
   Narrower screens scroll the .table-wrap container, never the page. */
table.data.grid {
  display: table;
  gap: 0;
  table-layout: fixed;
  width: 100%;
  min-width: 1000px;
}
table.data.grid th,
table.data.preview-grid th {
  white-space: nowrap;
  text-transform: none;
  padding: 0.5rem 0.4rem;
}
table.data.grid .th-exception .small { display: block; text-transform: none; letter-spacing: 0; }
table.data.grid col.col-select { width: 2.25rem; }
table.data.grid col.col-num    { width: 2.5rem; }
table.data.grid col.col-estate { width: 13rem; }
table.data.grid col.col-date   { width: 7.25rem; }
table.data.grid col.col-head   { width: 4.75rem; }
table.data.grid col.col-ref    { width: 6.5rem; }
table.data.grid col.col-notes  { width: auto; }   /* takes whatever is left */
table.data.grid col.col-status { width: 6.5rem; }
table.data.grid col.col-remove { width: 2.5rem; }
table.data.grid td .grid-input,
table.data.grid td .grid-input[list] {
  min-width: 0;             /* the column, not the input, sets the width now */
  width: 100%;
  box-sizing: border-box;
}
table.data.grid td.grid-status { overflow: hidden; }
.badge.EMPTY { background: #f1f3f5; color: var(--c-muted); }
.badge.CONFLICT { background: #fff1e0; color: #9a4b00; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
table.data tr.row-problem td { background: #fff7f7; }
table.data tr.row-problem td:first-child { border-left: 3px solid var(--c-danger); }
.text-danger { color: var(--c-danger); }

/* .xlsx preview (S5-001 §8): twelve read-only columns sized by the browser's
   automatic layout; dates and short Chinese labels never wrap, and a row's
   problems/reminders sit in a full-width detail row directly under it. */
table.data.preview-grid { table-layout: auto; width: 100%; min-width: 1000px; }
table.data.preview-grid td { vertical-align: top; }
table.data.preview-grid td.mono,
table.data.preview-grid td.nowrap { white-space: nowrap; }
table.data.preview-grid tr:has(+ tr.row-detail) td { border-bottom: 0; }
table.data.preview-grid tr.row-detail td.td-issues { padding-top: 0; padding-left: 2.75rem; }

@media (max-width: 719px) {
  /* Phones: the grid keeps its table shape inside the scrolling container
     (a card-per-row grid cannot be pasted into); the preview turns into
     cards like every other data table. */
  table.data.grid { display: table; }
  table.data.grid thead { display: table-header-group; }
  table.data.grid tbody { display: table-row-group; }
  table.data.grid tr { display: table-row; border: 0; margin: 0; padding: 0; background: transparent; }
  table.data.grid td { display: table-cell; width: auto; border-bottom: 1px solid var(--c-border); padding: 4px 6px; }
  table.data.grid td::before { content: none; }
  table.data.preview-grid { min-width: 0; }
  table.data.preview-grid colgroup { display: none; }
  table.data.preview-grid td.mono,
  table.data.preview-grid td.nowrap { white-space: normal; }
  /* the detail card hangs off the bottom of its row's card */
  table.data.preview-grid tr:has(+ tr.row-detail) { margin-bottom: 0; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
  table.data.preview-grid tr.row-detail { border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
  table.data.preview-grid tr.row-detail td.td-issues { padding: 0.35rem 0.25rem 0.5rem; display: block; }
  table.data.preview-grid tr.row-detail td.td-issues::before { display: block; margin-bottom: 0.2rem; }
}

/* Month calendar with quick create (U-10, DOC-032 §9). Seven columns on a
   desk; on a phone the weeks stack and only days with something in them (or
   today) take up room, so a month is a short scroll rather than 42 tiny
   squares. Every entry is estate + green dot + 「已報更／所需」 and nothing
   else — the dot means "a promotion day exists here" (D-U10-02). */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cal-month { margin: 0; font-size: 1.15rem; }
.cal-help { margin: 0.5rem 0 0.75rem; }
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.cal th { font-size: 0.8rem; color: var(--c-muted); padding: 0.35rem 0; text-align: center; font-weight: 600; }
table.cal td.cal-day {
  vertical-align: top; border: 1px solid var(--c-border); padding: 0.25rem 0.3rem;
  min-height: 5.5rem; height: 5.5rem; background: var(--c-surface); cursor: pointer;
}
table.cal td.cal-other { background: var(--c-bg); cursor: default; }
table.cal td.cal-today { box-shadow: inset 0 0 0 2px var(--c-primary); }
.cal-head { display: flex; justify-content: space-between; align-items: center; }
.cal-num { font-size: 0.85rem; font-weight: 600; color: var(--c-text); }
.cal-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; text-decoration: none;
  color: var(--c-primary-dark); background: var(--c-info-bg); font-weight: 700; line-height: 1;
}
.cal-entries { list-style: none; margin: 0.2rem 0 0; padding: 0; }
.cal-entry a {
  display: flex; align-items: center; gap: 0.3rem; text-decoration: none; color: var(--c-text);
  font-size: 0.82rem; line-height: 1.3; padding: 0.1rem 0; white-space: nowrap; overflow: hidden;
}
/* UAT-200: the list's 「改期／取消」, on the chip. Opens the days tab; not 「不開」. */
.cal-entry a.cal-reschedule {
  display: inline-flex; align-self: flex-start; width: auto; max-width: 100%;
  margin: 0.05rem 0 0.15rem; padding: 0 0.28rem; overflow: visible; gap: 0;
  font-size: 0.72rem; font-weight: 700; line-height: 1.45;
  color: var(--c-danger); background: var(--c-danger-bg); border-radius: 0.25rem;
}
.cal-estate { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-dot {
  display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--c-success); flex: 0 0 auto;
}
.cal-fraction { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--c-success); }
.cal-fraction-label { margin-left: auto; font-size: 0.8em; color: var(--c-muted, #5b6770); }
.cal-dialog { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--gap); max-width: 26rem; width: calc(100% - 2rem); }
.cal-dialog::backdrop { background: rgba(28, 39, 51, 0.45); }
.cal-dialog[open]:not(:modal) { position: fixed; left: 50%; top: 10%; transform: translateX(-50%); z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.cal-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.cal-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.cal-type-choices { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; }
.cal-type-choices .btn { text-align: center; }
.cal-headcounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.cal-headcounts .field { margin-bottom: 0.5rem; }
.cal-headcounts .field label { font-size: 0.85rem; }
/* REQ-111: EPD's read-only calendar — estate on one line, time and status under it. */
table.cal.epd-cal td.cal-day { height: auto; cursor: default; }
.epd-cal-entry + .epd-cal-entry { border-top: 1px dashed var(--c-border); }
.epd-cal-entry a { flex-direction: column; align-items: flex-start; gap: 0.1rem; white-space: normal; padding: 0.2rem 0; }
.epd-cal-entry .cal-estate { max-width: 100%; }
.epd-cal-meta { font-size: 0.78rem; color: var(--c-muted); }

@media (max-width: 719px) {
  table.cal thead { display: none; }
  table.cal, table.cal tbody, table.cal tr { display: block; width: 100%; }
  table.cal td.cal-day { display: block; width: 100%; height: auto; min-height: 0; border-radius: var(--radius); margin-bottom: 0.4rem; padding: 0.4rem 0.6rem; }
  table.cal td.cal-other { display: none; }
  table.cal td.cal-day .cal-num::after { content: " 日"; font-weight: 400; color: var(--c-muted); }
  .cal-entry a { font-size: 0.95rem; white-space: normal; }
  .cal-entry a.cal-reschedule { font-size: 0.85rem; min-height: var(--touch, 44px); padding: 0 0.45rem; }
  .cal-headcounts { grid-template-columns: 1fr; }
}

/* --- Pagination ----------------------------------------------------------
   The page strip under a long list (templates/_pagination.html). Wraps on a
   phone rather than pushing the table sideways, and the current page is a
   filled button so the eye finds it without reading the numbers. */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.9rem;
}
.pager .btn.small { min-width: 2.2rem; text-align: center; }
.pager-current { pointer-events: none; }
.pager .disabled { opacity: 0.45; pointer-events: none; }
.pager-gap { padding: 0 0.15rem; color: var(--c-muted); }
.pager-summary { margin-top: 0.5rem; }

/* The round day-picker, grouped one promotion at a time (U-18). David,
   2026-09-15: 「報更個位置，可能一條邨連續出三日，可能會容易啲睇」. The head row
   carries the estate; the three days under it are indented so a group reads as
   one block on a phone as well as a desktop. */
table.shift-picker tbody.shift-group + tbody.shift-group { border-top: 2px solid var(--c-border); }
table.shift-picker .shift-group-head td { background: var(--c-bg); }
table.shift-picker .shift-group-head label { cursor: pointer; }
table.shift-picker .shift-group-head strong { margin-right: 0.4rem; }
table.shift-picker tbody.shift-group tr:not(.shift-group-head) td:nth-child(2) { padding-left: 1.2rem; }

/* ===================================================================
   The staffing matrix (U-23). David, 2026-09-15: 「好似 Excel 個 Matrix
   佢 tick tick tick 咁 / 全部 show 晒出嚟」. A fortnight is fifteen columns
   and fifty rows, so the name column and the two header rows stay put
   while the grid scrolls under them — a name that scrolls away turns the
   grid into a puzzle.

   U-25 (2026-09-17, 「個畫面可唔可以用盡少少」) took the chrome off the top of
   the page and tightened the cells: the prose and the legend are behind a
   「點用？」 fold, the filters sit on the title line, and the grid gets the rest
   of the window. Nothing was deleted — it is one click away — but the grid now
   starts near the top of the screen instead of halfway down it.
   =================================================================== */
.mx-bar { margin-bottom: 0.5rem; row-gap: 0.35rem; }
.mx-bar h1 { font-size: 1.15rem; }
.mx-period { font-size: 0.85rem; font-weight: 400; color: var(--c-muted); }
/* Cross-period details live in the top layer; opening them never resizes
   the title bar or the matrix. The small trigger keeps its existing slot. */
body:has(#mx_form) .mx-spill {
  flex: 0 0 auto;
  align-self: center;
  max-width: 100%;
  margin: 0;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--c-muted);
  border-radius: 0.3rem;
  background: transparent;
  color: var(--c-text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
}
body:has(#mx_form) .mx-spill:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
body:has(#mx_form) .mx-spill-break {
  flex-basis: 100%;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
@media (min-width: 1600px) {
  body:has(#mx_form) .mx-spill-break { display: none; }
}
@media (max-width: 1599.98px) {
  body:has(#mx_form) .mx-bar:has(> .mx-spill) > h1 {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
  }
}
.mx-spill-dialog {
  box-sizing: border-box;
  width: min(46rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1rem;
  border: 1px solid var(--c-muted);
  border-radius: 0.5rem;
  background: var(--c-bg, white);
  color: var(--c-text);
  overflow: auto;
  overflow-wrap: anywhere;
}
.mx-spill-dialog::backdrop { background: rgb(0 0 0 / 35%); }
.mx-spill-heading { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.mx-spill-heading h2 { flex: 1; min-width: 0; margin: 0; font-size: 1.1rem; }
.mx-spill-heading button { flex: 0 0 auto; }
.mx-spill-activity + .mx-spill-activity {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--c-border);
}
.mx-spill-activity-title { margin: 0 0 0.2rem; font-size: 1rem; line-height: 1.4; }
.mx-spill-activity-title a { color: inherit; }
.mx-spill-meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--c-muted);
}
.mx-spill-days { margin: 0; padding: 0; list-style: none; line-height: 1.75; }
.mx-spill-day { white-space: normal; overflow-wrap: anywhere; }
.mx-spill-note { margin: 0.75rem 0 0; color: var(--c-muted); }
.mx-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  font-size: 0.85rem;
  /* Without these the row refuses to wrap and walks off the right edge of a
     narrower monitor instead — which is how 「下一段」 ended up half off David's
     screen. min-width:0 lets a flex item shrink below its content width. */
  flex: 1 1 22rem;
  min-width: 0;
}
.mx-filters .input { width: auto; padding: 0.2rem 0.35rem; font-size: 0.85rem; }
.mx-filters .btn { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.mx-allpeople { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }

/* The explanation is not gone, it is folded. Everything an administrator needs
   on day one is one click away; on day twenty they never open it again. */
.hint {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
}
.hint > summary { cursor: pointer; font-size: 0.85rem; color: var(--c-muted); }
.hint[open] > summary { margin-bottom: 0.4rem; }
.hint p:last-child { margin-bottom: 0; }

/* A fold around a block of work, not a hint: the housing-application forms and
   the 可派人選 list on the activity workspace, the blank private fields on a
   colleague's page. The summary carries whatever a colleague scans for, so
   folding costs no information; opening one is what costs a tap. */
.fold {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  padding: 0.35rem 0.6rem;
  margin: 0.4rem 0;
}

.fold > summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.fold[open] > summary {
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--c-border);
}

.fold > :last-child { margin-bottom: 0; }

.mx-actions { margin-top: 0.5rem; align-items: center; }

/* Report photographs: thumbnails on screen (David, 2026-09-21, 「會唔會有 preview」). */
.thumb { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--c-border); background: var(--c-bg); }
.thumb-duty { width: 100%; max-width: 240px; height: auto; aspect-ratio: 4 / 3; }
.thumb-sm { display: inline-block; width: 48px; height: 48px; vertical-align: middle; margin: 0 0.4rem; }
.thumb-link { display: inline-block; margin: 0.25rem 0; }
.photo-grid { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.6rem; }
.photo-grid li { display: flex; flex-direction: column; gap: 0.15rem; align-items: flex-start; }
.photo-grid form.inline { display: inline; margin: 0; }

/* The report's photo list: a tick, the picture and its one line, as one
   target on a phone. */
.report-pick { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.report-pick input[type="checkbox"] { width: 1.3rem; height: 1.3rem; flex: none; }
.report-pick .thumb { flex: none; }

/* The two turn buttons sit on one line and stay thumb-sized on a phone: the
   person pressing them is standing on an estate, not at a desk. */
.btn-row.photo-turn { flex-wrap: wrap; gap: 0.3rem; align-items: center; margin: 0.25rem 0; }
.btn-row.photo-turn form.inline { display: inline; margin: 0; }
.btn-row.photo-turn .btn { min-height: 2.2rem; }
.photo-checkboxes label { display: flex; align-items: center; gap: 0.25rem; }
.pick-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.4rem 0; }
.pick-preview .pick-count { flex-basis: 100%; }
.pick-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--c-border); }

/* The red bar across the top of every staging page (base.html). Full width,
   impossible to miss, and absent on production. */
.stack-banner {
  background: #b3261e; color: #fff; text-align: center; font-weight: 700;
  padding: 0.4rem 0.75rem; font-size: 0.9rem; letter-spacing: 0.02em;
}

.matrix-wrap {
  overflow: auto;
  max-height: 82vh;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; }
table.matrix th,
table.matrix td {
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  padding: 0.12rem 0.25rem;
  text-align: center;
  white-space: nowrap;
  background: var(--c-surface);
}
/* Colleague rows only. 當日隊長 / 已派／所需 / 報了可以 sit in tbody.mx-summary
   and 加人 sits in tfoot; those keep the 1px line. The 3px rule is the cell
   border, so the sticky name and the pinned counts get it as well as the
   dates. border-right stays the pale vertical line above. */
table.matrix tbody:not(.mx-summary) > tr > th,
table.matrix tbody:not(.mx-summary) > tr > td {
  border-bottom: 3px solid #000;
}
table.matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--c-bg); }
table.matrix thead tr:nth-child(2) th { top: 1.7rem; }
table.matrix .mx-name {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: var(--c-bg);
  min-width: 6.5rem;
  font-weight: 600;
}
table.matrix thead .mx-name,
table.matrix thead .mx-total { z-index: 4; }
/* REQ-016: 本段已派 and 本月日數 sit right of 同事 and are pinned with it.
   The offsets are the widths of the columns to their left; the roster
   matrix's script measures them (names vary in width), and the fallbacks are
   the name column's minimum and a count column's width for the frame before
   it runs, or a browser without scripts. */
table.matrix .mx-pin {
  position: sticky;
  z-index: 2;
  background: var(--c-bg);
  min-width: 2.6rem;
}
table.matrix .mx-pin-1 { left: var(--mx-pin-1-left, 6.5rem); }
table.matrix .mx-pin-2 { left: var(--mx-pin-2-left, 9.1rem); border-right: 2px solid #c9d6dd; }
table.matrix thead .mx-pin { z-index: 4; }
table.matrix tfoot .mx-pin { z-index: 3; }
table.matrix .mx-summary .mx-pin { background: var(--c-info-bg); }
table.matrix .mx-group { background: var(--c-info-bg); font-weight: 600; }

/* The per-day sort button (David, 2026-09-24). Quiet until it is doing
   something: the day's date is what the administrator reads, and forty of
   these down the header must not compete with it. */
button.mx-sort {
  display: block;
  margin: .1rem auto 0;
  padding: 0 .2rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  color: var(--c-muted, #6b7a80);
  font-size: .8rem;
  line-height: 1.1;
  cursor: pointer;
}
button.mx-sort:hover,
button.mx-sort:focus-visible { border-color: currentColor; color: var(--c-fg, #12333d); }
button.mx-sort.is-on {
  background: var(--c-info-bg, #e8eef7);
  border-color: currentColor;
  color: var(--c-fg, #12333d);
  font-weight: 700;
}
table.matrix tfoot th,
table.matrix tfoot td { position: sticky; bottom: 0; background: var(--c-bg); z-index: 2; }
table.matrix tfoot .mx-name { z-index: 3; }

/* A cell is read by colour first and by its mark second: the grid is
   scanned, not read. */
.mx-cell { min-width: 2.7rem; }
/* David, 2026-09-21, first look at the grid on staging: 「如果剔了 yes，全格變成
   紅色，已報更綠色字，No 直接寫空格，咁會易睇啲」. A ticked cell is the loud one
   now — red, the whole cell — because the tick is the roster and the roster
   is what the administrator is checking. What the colleague said is quiet
   green text under it. A cell nobody ticked and nobody answered is simply
   blank; the 「否」 that used to sit under every unanswered box is gone. */
.mx-assigned { background: #f5c2bc; color: #7a1410; font-weight: 700; }
select.mx-leader { background: #f5c2bc; color: #7a1410; font-weight: 700; box-shadow: inset 0 0 0 2px #b3261e; }
.mx-can      { background: #fff; }
.mx-cannot   { background: #fff; }
.mx-blank    { color: var(--c-muted); }
.mx-said-can { color: var(--c-success); font-weight: 600; opacity: 1; }
/* Already on another estate that date. Grey and shut, not red: nothing is
   wrong here — the person is working, just not on this column's estate — and
   the cell that IS red is the one where they are actually rostered. */
.mx-taken      { background: #f1f3f5; }
.mx-taken-note { color: var(--c-muted); font-weight: 600; opacity: 1; }
.mx-tag { display: inline-block; min-width: 1.1rem; padding: 0 0.25rem; border-radius: 3px; font-size: 0.7rem; font-weight: 700; background: var(--c-info-bg); color: #1f4e79; text-align: center; }
.mx-star { background: #fff3c4; color: #8a6100; }
table.matrix .mx-summary th,
table.matrix .mx-summary td { background: var(--c-info-bg); border-bottom: 2px solid #c9d6dd; }
.mx-short    { background: var(--c-warning-bg); }

/* The whole cell is the target, not just the box: this screen is used with
   a mouse, fast, for an hour at a time. */
/* Every cell is a visible control, because twice it was not one: the tick was
   an invisible checkbox behind the cell's text, and the administrator could
   not tell what was clickable — 「派更個位咩都按唔到」, then 「不如好似 Leader
   咁俾人揀喇, 會簡單好多」 (David, 2026-09-16). A bordered dropdown, the same
   shape as the leader picker beside it, says both things at once: this is a
   control, and this is what it is currently set to. */
.mx-pick {
  display: block;
  width: 100%;
  min-width: 3.2rem;
  font-size: 0.75rem;
  padding: 0.05rem 0.15rem;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-surface);
  cursor: pointer;
  /* The 44px touch floor every other control keeps is what made this grid
     twice as tall as it needed to be: fifty rows of it is a second screenful
     of nothing. This one screen is the exception the comment above already
     names — it is worked with a mouse, for an hour at a time — so the boxes
     drop to a mouse-sized 28px. */
  min-height: 1.75rem;
}
.mx-assigned .mx-pick, .mx-leader-cell .mx-pick { font-weight: 600; }
.mx-answer { display: block; font-size: 0.64rem; line-height: 1.2; opacity: 0.7; }
/* .mx-said-can sets opacity 1 above, but this rule is later and wins for
   class="mx-answer mx-said-can", so 已報更 was faint inside the Yes cell. */
.mx-answer.mx-said-can { opacity: 1; }
/* Status notes toggled by the matrix must respect the HTML hidden state. */
.mx-answer[hidden] { display: none; }
.mx-flat { display: block; opacity: 0.7; }
.mx-leader-select, select.mx-leader { min-width: 5rem; min-height: 1.75rem; font-size: 0.75rem; padding: 0.05rem; }
.mx-key { display: inline-block; padding: 0 0.35rem; border-radius: 4px; }
/* Full is full (U-24, David: 「超過咗個村嘅需要人數係要制止行政主任」). The box
   stops accepting a tick where the decision is made, and the day's count says
   why; the server refuses the same thing for a browser with no JavaScript. */
.mx-over { background: var(--c-danger-bg); color: var(--c-danger); font-weight: 600; }
.mx-locked .mx-pick { cursor: not-allowed; opacity: 0.45; }

/* The cell answers back the moment it is set, before anything is saved.
   David, 2026-09-23, working the real grid: 「如果 Yes 的同事, 都用綠色框圈住,
   如果做 On Click 轉色可以嗎, 隊長一樣」. Green ring = 揀咗 Yes, red ring =
   當日隊長 — the same red the saved leader cell already wears, so a cell looks
   the same before and after 儲存. The page script puts these on and takes them
   off; the background colours above stay what the server drew. */
table.matrix .mx-cell.is-yes { box-shadow: inset 0 0 0 2px var(--c-success); }
table.matrix .mx-cell.is-leader { box-shadow: inset 0 0 0 2px var(--c-danger); }

/* 實際出席 folds away (David, 2026-09-23): on an ordinary day the duty
   photograph has already reported everybody, so the list of cards is a screen
   of nothing to do. The summary line stays, and it says what the day is. */
details.att-rows > summary {
  cursor: pointer;
  padding: 0.35rem 0;
  font-weight: 600;
  color: var(--c-muted);
}
details.att-rows[open] > summary { margin-bottom: 0.35rem; }

/* ------------------------------------------- the round answer grid (U-26)

   One column per day, one row per colleague, so it is wide by nature and
   scrolls sideways inside .table-wrap rather than stretching the page.

   These rules used to sit in round.css, which base.html does not load, so the
   grid rendered as bare unruled text: no borders, no green, no red, while the
   sentence above it told the reader to look for exactly those colours (David,
   2026-09-17: 「答覆沒有了顏色」、「要加個表格, 否則好難睇到」). They live
   here now because this grid is an administrator screen and app.css is the
   stylesheet the administrator screens load. */
table.round-matrix {
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 0.9rem;
}

table.round-matrix th,
table.round-matrix td {
  border: 1px solid var(--c-border);
  padding: 0.35rem 0.55rem;
  text-align: center;
  vertical-align: middle;
}

/* The colleague column stays put while the days scroll past it; without this
   a scroll to late October leaves a grid of 可/否 belonging to nobody. */
table.round-matrix th.person,
table.round-matrix td.person {
  text-align: left;
  white-space: normal;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--c-surface);
}

/* Three lines per heading — date, estate, district — instead of one run-on
   label (David, 2026-09-17). Centred and non-wrapping keeps the columns
   narrow; the district is the quietest of the three because it is there to
   disambiguate the estate, not to be scanned. */
table.round-matrix th .mx-day-estate { display: block; font-size: 0.8rem; }
table.round-matrix th .mx-day-district {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--c-muted);
}

.round-cell-yes { background: var(--c-success-bg); color: var(--c-success); font-weight: 600; }
.round-cell-no { background: var(--c-danger-bg); color: var(--c-danger); }
.round-cell-blank { background: var(--c-bg); color: var(--c-muted); }

/* SSB-R1 UI: deliberately scoped to the answer overview, not the whole app. */
.round-admin { color: #18333d; }
.round-admin > .page-title { color: #173f4b; letter-spacing: -.02em; }
.round-admin .card { border-radius: 12px; border-color: #d6e2e5; box-shadow: 0 3px 14px #173d4808; }
.round-admin .btn { border-radius: 9px; }
.round-admin .btn:not(.secondary) { background: #146b79; }
.round-admin .btn:focus-visible { outline: 3px solid #208397; outline-offset: 3px; }
.round-admin .table-wrap { border: 1px solid #d6e2e5; border-radius: 12px; }
.round-admin table.round-matrix { width: 100%; font-variant-numeric: tabular-nums; }
.round-admin table.round-matrix th,
.round-admin table.round-matrix td { padding: .75rem .85rem; border-color: #d6e2e5; }
.round-admin table.round-matrix thead th { background: #eaf2f4; color: #183d48; }
.round-admin table.round-matrix th .mx-day-estate { margin-top: .25rem; font-size: .9rem; }
.round-admin table.round-matrix th .mx-day-district { color: #536b73; font-size: .85rem; font-weight: 400; }
.round-admin .round-cell-yes { background: #e8f5ed; color: #216443; font-weight: 700; }
.round-admin .round-cell-no { background: #fff0ec; color: #984032; font-weight: 700; }
.round-admin .round-cell-blank { background: #f6f8f9; color: #62777e; }
.round-admin .card > .mono { overflow-wrap: anywhere; }
@media print { .round-admin .card { box-shadow: none; } }

/* ------------------------------------------------------------------ tabs
   David, 2026-09-20: 「個用戶介面可唔可以用 tab 的方式」. The panels are in the
   page whether or not the script runs — see static/js/tabs.js — so these
   rules only matter once it has, which is why the bar is hidden until then.
   A page that never gets the script reads exactly as it did before: one long
   scroll, nothing unreachable. */
.tabs [data-tab-bar] {
  display: none;
}

.tabs.tabs-on [data-tab-bar] {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  padding: 0.35rem 0.35rem 0;
  margin-bottom: var(--gap);
  position: sticky;
  /* Under the site header, which is sticky too. tabs.js measures it and sets
     --tab-top, because the header's height follows the number of navigation
     links the role has. The 0 fallback is what it was before the measurement
     lands, for the one frame that matters. */
  top: var(--tab-top, 0px);
  z-index: 3;
}

.tabs .tab {
  min-height: var(--touch);
  padding: 0 0.85rem;
  border: 0;
  background: transparent;
  color: var(--c-muted);
  font: inherit;
  font-size: 0.95rem;
  white-space: nowrap;
  cursor: pointer;
}

.tabs .tab.is-on {
  color: var(--c-text);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--c-primary);
}

/* The grouping switch: 按功能 / 按日. Hidden with the bar, for the same
   reason — with no script there is nothing to switch. */
.tab-group-switch {
  display: none;
}

.tabs.tabs-on .tab-group-switch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--c-muted);
}

.tab-group-switch button {
  min-height: 36px;
  padding: 0 0.7rem;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tab-group-switch button.is-on {
  border-color: var(--c-primary);
  background: var(--c-info-bg);
  color: var(--c-primary-dark);
  font-weight: 600;
}

/* 今次改動 — what this person has already changed here (DOC-046 §7.12).
   Outside the tabs on purpose: it is the answer to 「轉咗 tab 唔知自己做過乜」,
   so putting it inside one would be the joke telling itself. */
.change-log {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  max-height: 15rem;
  overflow-y: auto;
}

.change-log li {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--c-border);
}

.change-log .when {
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.change-log .what {
  flex-grow: 1;
  min-width: 0;
}

/* The running build, at the foot of every signed-in page. David, 2026-09-21:
   「但我唔肯定，而家 NAS 係邊個版本」 — the one fact that decides whether the
   screen you are looking at is this week's work or last week's, and it used to
   live inside an SSH session. Quiet: it is for the one person who needs it. */
.site-footer .version {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* 派更(L): days down, leaders across (David, 2026-09-24). A month of days
   against a row of leaders is read across, and a table that wide loses the
   eye between the date and the mark — so the row is banded and lit on hover,
   the mark is a filled block rather than a dot, and the name, the date and
   the totals all stay on screen while it scrolls. */
table.lx { border-collapse: separate; border-spacing: 0; }
table.lx th,
table.lx td { border-bottom: 1px solid var(--c-line, #dde5e8); }

table.lx .lx-leader {
  min-width: 4.2rem;
  max-width: 6rem;
  white-space: normal;
  line-height: 1.15;
  vertical-align: bottom;
}
table.lx .lx-who { display: block; }
/* The same number as the foot. A column can be a month long, and the answer
   should not be only at the end of it. */
table.lx .lx-count {
  display: block;
  margin-top: .15rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--c-fg, #12333d);
}
table.lx .lx-count.is-zero { color: var(--c-muted, #8a9aa1); font-weight: 400; }

table.lx .mx-name { min-width: 8.5rem; line-height: 1.2; }
table.lx .lx-date { font-weight: 700; }
table.lx .lx-dow { margin-left: .3rem; font-weight: 400; color: var(--c-muted, #6b7a80); }
table.lx .lx-estate {
  display: block;
  font-size: .82rem;
  font-weight: 400;
  color: var(--c-muted, #6b7a80);
}

/* The whole cell is the target, not the circle inside it. */
table.lx .mx-cell { text-align: center; padding: 0; }
table.lx .lx-pick {
  /* Keep the transparent native radio focus target inside its own cell. */
  position: relative;
  display: block;
  padding: .3rem .1rem;
  cursor: pointer;
  line-height: 1.1;
}
table.lx .lx-pick input { position: absolute; opacity: 0; pointer-events: none; }
table.lx .lx-pick span {
  display: inline-block;
  min-width: 1.5rem;
  padding: .12rem 0;
  border: 1px solid var(--c-line, #cfd9dd);
  border-radius: 4px;
  background: var(--c-surface, #fff);
  color: transparent;
  font-size: .82rem;
  font-weight: 700;
}
table.lx .lx-pick:hover span { border-color: var(--c-muted, #8a9aa1); }
table.lx .lx-pick input:focus-visible + span { outline: 2px solid var(--c-fg, #12333d); }
table.lx .lx-pick input:checked + span {
  border-color: #2f7d4f;
  background: #2f7d4f;
  color: #fff;
}
table.lx .lx-none .lx-pick input:checked + span { border-color: #b3382f; background: #fff; color: #b3382f; }

table.lx tbody tr:nth-child(even) { background: var(--c-row-alt, #f7fafb); }
table.lx tbody tr:hover { background: var(--c-info-bg, #e8eef7); }
/* Where one estate's block of days ends and the next begins. */
table.lx tbody tr.lx-newblock th,
table.lx tbody tr.lx-newblock td { border-top: 2px solid var(--c-line, #c3d0d5); }
table.lx tbody tr.lx-unled th.mx-name { color: #b3382f; }
table.lx tbody tr.lx-unled th.mx-name .lx-date::after { content: " ⚠"; font-size: .8em; }

/* The totals stay in view: the question the page answers is at the foot. */
table.lx tfoot th,
table.lx tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--c-bg, #fff);
  border-top: 2px solid var(--c-line, #c3d0d5);
  font-variant-numeric: tabular-nums;
}
table.lx tfoot .mx-name { z-index: 3; }
table.lx tfoot td.mx-total { text-align: center; font-weight: 700; }
/* Already working another estate that day: the pick would be refused, so the
   cell reads as closed rather than empty. */
table.lx .lx-blocked .lx-pick { cursor: not-allowed; }
table.lx .lx-blocked .lx-pick span {
  border-style: dashed;
  border-color: var(--c-line, #dde5e8);
  background: var(--c-row-alt, #f2f5f6);
  color: var(--c-muted, #b6c2c7);
}

/* The housing signature pad (David, 2026-09-24). Plain white, because what is
   drawn here goes onto a printed form. */
#sig-canvas {
  width: 100%;
  max-width: 600px;
  height: 200px;
  background: #fff;
  border: 1px solid var(--c-line, #cfd9dd);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
#sig-or { margin-top: 1rem; }

/* 派更(L) marks: L leads, Y is on the day but not leading, · is at another
   estate. Y has to read as "already here" without competing with L. */
table.lx .lx-pick span.lx-mark.is-crew {
  border-color: #6f8f7c;
  background: #eef5f0;
  color: #3f6b52;
  font-weight: 600;
}
table.lx .lx-pick input:checked + span.lx-mark { border-color: #2f7d4f; background: #2f7d4f; color: #fff; }
/* The three footer rows: leading, otherwise on the roster, and both. */
table.lx tfoot tr.lx-sum-l td.mx-total { color: #2f7d4f; }
table.lx tfoot tr.lx-sum-y th.mx-name,
table.lx tfoot tr.lx-sum-y td.mx-total { font-weight: 400; color: var(--c-muted, #55686f); }
table.lx tfoot tr.lx-sum-all th.mx-name,
table.lx tfoot tr.lx-sum-all td.mx-total { border-top: 1px solid var(--c-line, #c3d0d5); }

/* The estate heading above its own block of days (David, 2026-09-24). */
table.lx tbody.lx-block + tbody.lx-block tr.lx-blockhead th,
table.lx tbody.lx-block + tbody.lx-block tr.lx-blockhead td { border-top: 2px solid var(--c-line, #c3d0d5); }
table.lx tr.lx-blockhead th.mx-name {
  background: var(--c-info-bg, #e8eef7);
  font-weight: 700;
  padding-top: .35rem;
  padding-bottom: .35rem;
}
table.lx tr.lx-blockhead td { background: var(--c-info-bg, #e8eef7); }
table.lx .lx-district { margin-left: .4rem; font-size: .8rem; font-weight: 400; color: var(--c-muted, #556870); }
/* The row head is just the date now; the estate is the heading above it. */
table.lx tbody.lx-block tr:not(.lx-blockhead) th.mx-name { padding-left: 1.1rem; }

/* The signature already on file, shown beside the picker it belongs to. */
#sig-current-img {
  display: block;
  max-width: 320px;
  max-height: 110px;
  margin-top: .3rem;
  padding: .2rem;
  border: 1px solid var(--c-line, #cfd9dd);
  border-radius: 6px;
  background: #fff;
}

/* Payroll summary search row (REQ-014): start date, end date, 預覽 and
   下載工資摘要 on one line, wrapping on a phone. Since REQ-019 one POST form
   holds all four (預覽 is sent back to the GET address); the row stays the
   flex container and the form lays its controls out inline. */
.payroll-search {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.payroll-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0;
}

.payroll-search-form .field {
  margin: 0;
}

/* ------------------------------------------------------------ activity list
   REQ-017 (PM template Version 3): an Excel-style table, one row per day,
   the activity's own cells spanning its days. About 1680px wide; the table
   scrolls inside its frame and the page itself never does. Straight rules,
   a heavier rule between activities, the header and the 活動 column pinned.
   Below 560px the same rows are cards (017-13). */

.alist-frame {
  overflow: auto;
  max-height: 80vh;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
table.alist-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1280px;
  font-size: 0.9rem;
}
table.alist-table th,
table.alist-table td {
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  padding: 0.35rem 0.6rem;
  text-align: left;
  vertical-align: middle;
  background: var(--c-surface);
}
table.alist-table th { background: var(--c-bg); font-size: 0.8rem; white-space: nowrap; }
/* The whole header sticks as one block: a fixed offset for the second row
   (it was 2.4rem) left a gap whenever the first row came out shorter, and
   the rows scrolling underneath showed through it (UAT 2026-10-02). */
table.alist-table thead { position: sticky; top: 0; z-index: 3; }
table.alist-table .c { text-align: center; }
table.alist-table td.alist-span { vertical-align: top; }
table.alist-table .alist-name { position: sticky; left: 0; z-index: 2; min-width: 11rem; }
table.alist-table thead .alist-name { z-index: 4; }
table.alist-table tbody.alist-activity tr:first-child td { border-top: 2px solid #9fb3bb; }

.alist-cards { display: none; }
.alist-card { display: grid; gap: 0.35rem; }
.alist-card-days { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }

@media (max-width: 559px) {
  .alist-frame { display: none; }
  .alist-cards { display: grid; gap: 0.6rem; }
}

/* REQ-025 report page ----------------------------------------------------- */
.report-bar { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; justify-content: space-between; }
.report-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.report-days { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
@media (max-width: 900px) { .report-days { grid-template-columns: 1fr; } }
.report-tabs, .report-switch { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; }
.report-tabs:not(:has(.tab)) { display: none; }
.report-page:not(.tabs-on) .report-tabs, .report-page:not(.tabs-on) .report-switch .tab { display: none; }
.report-page .tab { border: 1px solid #c4d3d7; background: #fff; border-radius: 8px; padding: 0.3rem 0.7rem; cursor: pointer; }
.report-page .tab.is-on { background: #0b6f77; color: #fff; border-color: #0b6f77; }
.report-panel[hidden], .upload-box[hidden] { display: none; }
.report-panel textarea, .report-panel input.input { width: 100%; box-sizing: border-box; }
.report-picks { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; }
.report-pick-item { display: flex; flex-direction: column; gap: 0.3rem; }
.report-pick { display: block; position: relative; }
.report-pick input { position: absolute; top: 4px; left: 4px; z-index: 1; width: 1.2rem; height: 1.2rem; }
.report-page .thumb, .report-preview .thumb { max-width: 100%; height: auto; max-height: 140px; border-radius: 6px; }
.duty-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.duty-row figure { margin: 0; width: 90px; }
.auto-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.8rem; margin: 0 0 0.5rem; }
.auto-fields dt { color: #5b6b70; } .auto-fields dd { margin: 0; font-weight: 600; }
.raw-ref { white-space: pre-wrap; font: inherit; margin: 0; max-height: 14rem; overflow: auto; }
.upload-status { list-style: none; padding: 0; }
.report-preview table { width: 100%; margin-bottom: 0.8rem; }
.report-preview th { text-align: left; white-space: nowrap; }

/* Payroll totals: the adjustment inputs sit mid-row with the figures. */
table.data.payroll-totals td { vertical-align: middle; }

/* Phones: small buttons still need a full fingertip (attendance, 改期／取消),
   and a list cell's dates wrap instead of being cut off. */
@media (max-width: 719px) {
  .btn.small { min-height: var(--touch, 44px); }
  table.data td .nowrap { white-space: normal; }
}

/* Activity board: search, two filters, sort, direction and the button on one row. */
@media (min-width: 900px) {
  .filters.filters--board { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }
}
.photo-tools { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
.photo-tools .tool { padding: 0.15rem 0.5rem; min-width: 2rem; }
.duty-item { margin: 0; width: 110px; }
.duty-item .thumb { max-height: 90px; }
.input.has-error { border-color: #c0392b; background: #fdf1f0; }
.field-error { color: #c0392b; margin: 0.15rem 0 0.4rem; }
.form-errors { border-color: #c0392b; color: #c0392b; }
.thumb-link { display: block; }
.report-status { margin: 0.5rem 0; font-weight: 600; }
.report-status.is-complete { border-color: #2e8b57; color: #1d6b40; }
.report-status.is-gap { border-color: #d98e04; color: #8a5a00; }

/* Desktop: the main menu wraps onto a second line instead of scrolling
   sideways (UAT 2026-10-02). Phones keep the one-line swipe. */
@media (min-width: 720px) {
  .nav { flex-wrap: wrap; overflow-x: visible; }
}

/* Wide screens: the whole main menu fits on one line (UAT 2026-10-02). */
@media (min-width: 1200px) {
  .nav a { padding: 0 0.65rem; }
}

/* ------------------------------------------------------------ form grid
   REQ-036／REQ-038 (David, 2026-10-04): forms are compressed on a desktop —
   short fields three to a row, long content across the whole row — and go back
   to one column on a phone. Labels, errors and the tab order are the same
   elements in the same order, so keyboard and screen reader use is unchanged. */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 1rem;
}

@media (min-width: 720px) {
  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .form-grid > .field.wide {
    grid-column: 1 / -1;
  }
  .form-grid > .field.span-2 {
    grid-column: span 2;
  }
}

.form-grid > .field {
  min-width: 0;
}

/* The tab name repeats as a heading only when the script has not run, so the
   long no-script page still says where each part starts. */
.tabs.tabs-on .tab-heading {
  display: none;
}

.tab-heading {
  font-size: 1.05rem;
  margin: 1rem 0 0.5rem;
}

/* The save row stays in reach on a long page: it sticks to the bottom of the
   window while the form is longer than the screen. */
.action-bar {
  position: sticky;
  bottom: 0;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  margin: 1rem calc(-1 * var(--gap)) calc(-1 * var(--gap));
  padding: 0.6rem var(--gap);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
  z-index: 2;
}

.action-bar .field {
  margin-bottom: 0.5rem;
}

.crumb {
  margin: 0 0 0.4rem;
}

/* REQ-045 / REQ-048 (David, 2026-10-04): the report page's top right — the
   estate badge, the 服務地點（樓宇）box under it, and 上載報告檔. */
.report-head { align-items: flex-start; }
.report-head-side { display: flex; flex-direction: column; align-items: stretch; gap: 0.25rem; min-width: 18rem; max-width: 28rem; }
.report-head-side .badge { align-self: flex-end; }
.report-head-side p { margin: 0; }
.report-file-upload { margin-top: 0.5rem; }
.report-file-upload .btn-row { flex-wrap: nowrap; }
.report-file-list { margin: 0; padding-left: 1.2rem; }
.report-file-list li { margin: 0.2rem 0; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .report-head-side { min-width: 0; max-width: none; width: 100%; }
  .report-head-side .badge { align-self: flex-start; }
  .report-file-upload .btn-row { flex-wrap: wrap; }
}

/* REQ-054 venue picker (templates/estates/_venue_picker.html) */
.venue-picker { position: relative; }
.venue-picker-row { display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: nowrap; }
.venue-picker-field { position: relative; flex: 1 1 auto; min-width: 0; }
.venue-picker-add { flex: 0 0 auto; white-space: nowrap; }
.venue-picker-list {
  position: absolute; left: 0; right: 0; z-index: 20; margin: 0.15rem 0 0; padding: 0;
  list-style: none; background: #fff; border: 1px solid #c8ccd0; border-radius: 6px;
  max-height: 16rem; overflow-y: auto; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.venue-picker-list li { padding: 0.65rem 0.75rem; cursor: pointer; min-height: 44px; }
.venue-picker-list li:hover, .venue-picker-list li.active { background: #eef3fb; }
.venue-picker-list li.venue-picker-newrow { border-top: 1px solid #e3e6ea; font-weight: 600; color: #1a56c4; }
.venue-picker-dialog { border: 1px solid #c8ccd0; border-radius: 8px; padding: 1rem 1.25rem; width: min(30rem, 92vw); }
.venue-picker-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

/* REQ-054 estate form: sections on one page (same grid as the account edit page) */
.form-section { font-size: 1rem; margin: 0.9rem 0 0.4rem; padding-bottom: 0.2rem; border-bottom: 1px solid #e3e6ea; }
.form-section:first-of-type { margin-top: 0; }
.estate-form .field { margin-bottom: 0.6rem; }
.estate-form textarea.input { min-height: 3.2rem; }
.estate-form .helptext { display: block; font-size: 0.8rem; margin-top: 0.15rem; }
.estate-form .field { margin-bottom: 0.45rem; }
.estate-form .field input[type=checkbox] { margin-top: 0.6rem; }
/* REQ-056 (David, 2026-10-04): the report page's head on one row on a desktop
   — title and estate badge, 服務地點（樓宇）with its own 儲存, 上載報告檔 —
   stacking on a phone. Nothing overlaps the report below it. */
.report-head-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem 1.25rem;
  align-items: end;
  margin-bottom: var(--gap);
}
@media (min-width: 1024px) {
  .report-head-row { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(0, 1fr); }
}
.report-head-title h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.report-head-buildings p, .report-head-upload p { margin: 0.2rem 0 0; }
.report-head-buildings label, .report-head-upload label { display: block; margin-bottom: 0.2rem; }
.report-head-inline { flex-wrap: nowrap; margin: 0; }
.report-head-inline .input { flex: 1 1 auto; min-width: 0; }
.report-head-inline .btn { flex: 0 0 auto; white-space: nowrap; }
.offscreen-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* REQ-056 (David, 2026-10-04: 「可否同 view 版面咁細」): choice lists across
   the row, part headings like the account view's cards, and the notes row —
   合規備註／備註／原因, a third each — under every part. */
.field.choices-inline > div { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.field.choices-inline > div > div { margin: 0; }
.field.choices-inline label[for] { font-weight: normal; }
.field.choices-inline > div label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
.part-heading { font-size: 1.05rem; margin: 0.25rem 0 0.4rem; }
.notes-row textarea { min-height: 0; resize: vertical; }
.inline-details { display: inline; margin-left: 0.4rem; }
.inline-details summary { display: inline; cursor: pointer; text-decoration: underline; }

/* REQ-056: with the notes row in it the save bar is three boxes tall, which on
   a phone would cover most of the screen; it only sticks where it fits beside
   the content (a desktop). On a phone it is simply the end of the form. */
@media (max-width: 719px) {
  .action-bar { position: static; box-shadow: none; }
}

/* REQ-079 dashboard: 「即將舉行的活動」 — the first eight days and the folded
   remainder share one colgroup and fixed layout, so the columns line up. */
.notify-btns { display: inline-flex; gap: 0.4rem; }
.notify-btns a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 0.7rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
table.data td.center { text-align: center; }
.day-badge { min-width: 3.6rem; text-align: center; }
@media (min-width: 720px) {
  table.data.upcoming { table-layout: fixed; }
  /* The fold adds a border and padding; undo them so both tables are as wide as the card. */
  .fold > .table-wrap { margin: 0 calc(-0.6rem - 1px); }
  table.data.upcoming .c-date { width: 12.5rem; }
  table.data.upcoming .c-estate { width: 20%; }
  table.data.upcoming .c-notify { width: 12.25rem; }
  table.data.upcoming .c-time { width: 7.25rem; }
  table.data.upcoming .c-head { width: 5.75rem; }
  table.data.upcoming th:last-child { text-align: center; }
  table.data.upcoming .notify-btns { display: flex; }
  table.data.upcoming .notify-btns a { flex: 1 1 0; min-width: 0; }
  table.data.upcoming .shift-title { margin-right: 0.4rem; }
  table.data.upcoming td { overflow-wrap: anywhere; }
}
@media (max-width: 719px) {
  .notify-btns { justify-content: flex-end; }
}

/* UI batch 1: compact stat cards, tabular figures, 13px floor, numeric columns. */
.stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.5rem; margin-bottom: 0.75rem; }
.stat { padding: 0.5rem; }
.stat .n { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) {
  .stats.stats-5 { grid-template-columns: repeat(5, 1fr); }
  .stats.stats-8 { grid-template-columns: repeat(8, 1fr); }
}
table.data th, table.data td { font-variant-numeric: tabular-nums; }
table.data th { font-size: 0.8125rem; }
.badge { font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
@media (min-width: 720px) {
  /* Payroll totals: the numeric columns (3-8, 10) read right-aligned, header and cell alike. */
  table.payroll-totals :is(th, td):is(:nth-child(n+3):nth-child(-n+8), :nth-child(10)) { text-align: right; }
}

/* =====================================================================
   REQ-099 part 2 — Tabler look (https://tabler.io, MIT License,
   Copyright (c) 2018-2024 Tabler / Paweł Kuna). Only design tokens (colours,
   radius, shadow, badge "-lt" recipe) are taken, written as plain CSS on top of
   the classes this project already has. No framework and no tabler.css.
   ===================================================================== */

.site-header { box-shadow: none; }
.site-header .bar { padding-bottom: 0; }
.brand.brand-logo { padding-bottom: 0.4rem; }
.user-chip { padding-bottom: 0.4rem; }

/* Navigation as horizontal tabs: the current page has a blue underline. */
.nav { padding-bottom: 0; gap: 0; }
.nav a {
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.nav a:hover { color: var(--c-text); }
.nav a.active,
.nav a[aria-current="page"] {
  background: transparent;
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: 600;
}

.card { box-shadow: 0 1px 3px rgba(24, 36, 51, 0.04); }

/* Page head: bold title on the left, the main action on the right. */
.page-title { align-items: center; }
.page-title h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }

/* Stat cards: small label on top, large figure underneath, left aligned. */
.stat { display: flex; flex-direction: column; text-align: left; box-shadow: 0 1px 3px rgba(24, 36, 51, 0.04); }
.stat .l { order: -1; margin-bottom: 0.15rem; }

/* Tables: quiet grey header on a tinted bar, thin row rules, light hover. */
table.data thead th { background: #f6f8fb; font-weight: 600; border-bottom: 1px solid var(--c-border); }
table.data tbody tr:hover > td { background: rgba(6, 111, 209, 0.035); }

/* Buttons: blue primary, white secondary with a grey border. */
.btn { font-weight: 500; box-shadow: 0 1px 2px rgba(24, 36, 51, 0.06); }
.btn:hover { background: var(--c-primary-dark); }
.btn.secondary:hover { background: #f6f8fb; border-color: #c8d0d9; }
.btn.danger:hover { background: #8f1f19; }
.btn.success:hover,
.btn.success:active { background: var(--c-success-dark); }

/* Status badges, Tabler "-lt": pale fill, dark text, square-ish corners.
   Five meanings only — blue 已排定, green 完成／夠人, grey 已取消,
   orange 要處理, red 錯誤／未派隊長. */
.badge { border-radius: 4px; padding: 0.15rem 0.5rem; }
.badge.CANCELLED { background: #eceff2; color: #4a5868; }
.badge.leader-missing { background: var(--c-danger-bg); color: var(--c-danger); }

/* Phones: every button is at least 40px tall (PM report P3). */
@media (max-width: 719px) {
  .btn.small,
  .btn-row.photo-turn .btn,
  .tab-group-switch button,
  .notify-btns a,
  button.mx-sort { min-height: 40px; }
  button.mx-sort { min-width: 40px; }
}

/* Links: the house blue instead of the browser's purple "visited". Class rules
   (.btn, .nav a, .brand, .badge …) are more specific and keep their colours. */
a { color: var(--c-primary); }

/* REQ-102: 更表頁 row 1 = dates + buttons, row 2 = 活動類別 chips. The native
   checkbox stays in the tab order and answers the space bar; it is only
   visually hidden (never display:none), and its focus ring is drawn on the chip. */
.handout-filters { display: block; }
.handout-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.handout-row .field { margin: 0; }
.handout-date .input { width: 11.5rem; max-width: 100%; }
.handout-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* The four exports share one width so 「原版(PDF)」 and 「同事版 (Excel)」 match. */
.handout-exports .btn {
  flex: 0 0 11rem;
  width: 11rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  white-space: nowrap;
}
.handout-cats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  margin: 0.75rem 0 0; padding: 0.75rem 0 0; border: 0; border-top: 1px solid var(--c-border);
}
.handout-cats legend { float: left; padding: 0; margin-right: 0.25rem; font-weight: 700; }
.handout-cats .chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.handout-cats-hint { flex-basis: 100%; margin: 0; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; cursor: pointer;
  min-height: 44px; padding: 0 1rem 0 0.75rem; border: 1px solid var(--c-border); border-radius: 999px;
  background: var(--c-surface); color: var(--c-text); font-weight: 500; white-space: nowrap;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; overflow: hidden; }
.chip::before {
  content: ""; box-sizing: border-box; flex: 0 0 1.15rem; width: 1.15rem; height: 1.15rem;
  border: 2px solid #b7c0ca; border-radius: 50%; background: #fff;
}
.chip:has(input:checked) { background: var(--c-info-bg); border-color: var(--c-primary); color: var(--c-primary-dark); font-weight: 700; }
.chip:has(input:checked)::before {
  content: "\2713"; border-color: var(--c-primary); background: var(--c-primary); color: #fff;
  font-size: 0.8rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--c-primary); outline-offset: 2px; }
@media (max-width: 639px) {
  .handout-date { flex: 1 1 calc(50% - 0.5rem); min-width: 0; }
  .handout-date .input { width: 100%; }
  .handout-buttons { flex: 1 1 100%; }
  .handout-buttons .btn { flex: 1 1 0; }
}

/* REQ-103 (David: 「行距真係太大」) — tighter spacing for the desktop only.
   A phone keeps its 44px touch targets. */
.clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
@media (min-width: 720px) {
  /* Forms: 8px between fields, 2px label→box, 36px boxes, ~2-line textarea. */
  .field { margin-bottom: 0.5rem; }
  .field label { margin-bottom: 2px; }
  .helptext { font-size: 0.8rem; margin-top: 2px; line-height: 1.35; }
  .input, input[type="text"], input[type="password"], input[type="email"], input[type="number"],
  input[type="date"], input[type="time"], select { min-height: 36px; padding: 0.3rem 0.65rem; }
  textarea { min-height: 58px; padding: 0.35rem 0.65rem; }
  /* Tables: 6px above and below every cell; label/value tables ≤30px a row. */
  table.data th, table.data td { padding-block: 6px; }
  table.data:not(:has(thead)) td { padding-block: 0.2rem; line-height: 1.35; }
  /* Audit log: a row is at most two lines of 13px text. */
  table.audit-table td { font-size: 0.8125rem; line-height: 1.25; padding-block: 2px; }
  table.audit-table .badge { padding-block: 0; }
  /* Page head: title and status on the left, every action on the right. */
  .page-title { justify-content: flex-start; gap: 0.5rem 0.75rem; }
  .page-title > :is(a, button, form, div, .btn-row) { margin-left: auto; }
  .page-title > :is(a, button, form, div, .btn-row) ~ :is(a, button, form, div, .btn-row) { margin-left: 0; }
}

/* N1 (PR #144 review): input, select, textarea and checkbox borders use
   --c-input-border (≈3:1 against white); card and table borders stay pale. */
.input, input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], select, textarea { border-color: var(--c-input-border); }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 1.125rem; height: 1.125rem; margin: 0 0.35rem 0 0; vertical-align: -0.2rem;
  border: 1.5px solid var(--c-input-border); border-radius: 3px; background: #fff; cursor: pointer;
}
input[type="checkbox"]:checked {
  background: var(--c-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--c-primary);
}
input[type="checkbox"]:indeterminate {
  background: var(--c-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-width='2.4' stroke-linecap='round' d='M4 8h8'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--c-primary);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* REQ-089: input width follows the length of the answer. Desktop only; on a
   phone every box stays full width in one column. Notes and reasons are not
   given a w- class and stay full width. */
@media (min-width: 720px) {
  .field.w-xs > input, .field.w-xs > select { max-width: calc(10ch + 1.6rem); }
  .field.w-s > input, .field.w-s > select { max-width: calc(20ch + 1.6rem); }
  .field.w-m > input, .field.w-m > select { max-width: calc(32ch + 1.6rem); }
}
.mx-inactive { background: var(--c-danger-bg); color: #8a1f1f; }

/* REQ-105: 「我的更次」 month calendar (templates/portals/_my_calendar.html).
   Desktop: a 7-column grid with a chip per entry. Phone (<720px): the cells
   keep only a coloured dot and the days that have something are listed below. */
.my-cal-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.my-cal-title { flex: 1 1 auto; text-align: center; font-size: 1.1rem; }
.my-cal-stats { margin: 8px 0; }
.my-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.my-cal-dow { text-align: center; font-weight: 600; color: var(--c-muted); padding: 4px 0; }
.my-cal-cell { display: flex; flex-direction: column; gap: 2px; min-height: 76px; padding: 4px; border: 1px solid var(--c-border); border-radius: 6px; background: var(--c-surface); color: inherit; text-decoration: none; overflow: hidden; }
.my-cal-cell.is-blank { border-color: transparent; background: transparent; }
.my-cal-cell.is-today { outline: 2px solid var(--c-primary); }
.my-cal-cell.is-selected { background: #eef4ff; }
.my-cal-day { font-size: .8rem; color: var(--c-muted); }
.my-cal-chip { display: block; padding: 1px 4px; border-radius: 4px; font-size: .78rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
.my-cal-chip.k-crew { background: #dff3e6; color: #14532d; }
.my-cal-chip.k-leader { background: #ffe8c7; color: #7a3e00; }
.my-cal-chip.k-worked { background: #e6e9ed; color: #3d4a57; }
.my-cal-chip.k-absent { background: #fbd9d6; color: #8a1c14; }
.my-cal-chip.k-norecord { background: #eef0f2; color: #5b6b7c; }
.my-cal-chip.k-cancelled { background: #f4f4f4; color: #777; text-decoration: line-through; }
.my-cal-chip.k-apply_yes { background: #fff; color: #1a5ac4; border: 1px dashed #1f6feb; }
.my-cal-chip.k-apply_no { background: #fafafa; color: #9aa5b1; }
.my-cal-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; padding: 0; margin: 8px 0; }
.my-cal-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.my-cal-dot.k-crew { background: #2ea05a; }
.my-cal-dot.k-leader { background: #f08c00; }
.my-cal-dot.k-worked { background: #8a96a3; }
.my-cal-dot.k-absent { background: #d93a30; }
.my-cal-dot.k-norecord { background: #c3cad1; }
.my-cal-dot.k-cancelled { background: #fff; border: 1px solid #999; }
.my-cal-dot.k-apply_yes { background: #fff; border: 1px dashed #1f6feb; }
.my-cal-dot.k-apply_no { background: #e8ebee; }
.my-cal-detail-row + .my-cal-detail-row { border-top: 1px solid var(--c-border); padding-top: 8px; margin-top: 8px; }
.my-cal-list { list-style: none; padding: 0; margin: 12px 0; display: none; }
.my-cal-list li { padding: 6px 0; border-bottom: 1px solid var(--c-border); }
.my-cal-list li.is-today { background: #eef4ff; }
.my-cal-list a { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: inherit; text-decoration: none; }
@media (max-width: 719px) {
  .my-cal-cell { min-height: 44px; padding: 2px; align-items: center; }
  .my-cal-chip { width: .6rem; height: .6rem; padding: 0; border-radius: 50%; border-width: 0; }
  .my-cal-chip .my-cal-chip-text { display: none; }
  .my-cal-chip.k-crew { background: #2ea05a; }
  .my-cal-chip.k-leader { background: #f08c00; }
  .my-cal-chip.k-worked { background: #8a96a3; }
  .my-cal-chip.k-absent { background: #d93a30; }
  .my-cal-chip.k-norecord { background: #c3cad1; }
  .my-cal-chip.k-cancelled { background: #fff; border: 1px solid #999; }
  .my-cal-chip.k-apply_yes { background: #fff; border: 1px dashed #1f6feb; }
  .my-cal-chip.k-apply_no { background: #e8ebee; }
  .my-cal-list { display: block; }
  .my-cal-list .my-cal-chip { width: auto; height: auto; padding: 1px 4px; border-radius: 4px; }
  .my-cal-list .my-cal-chip .my-cal-chip-text { display: inline; }
  .my-cal-list .my-cal-chip.k-crew { background: #dff3e6; color: #14532d; }
  .my-cal-list .my-cal-chip.k-leader { background: #ffe8c7; color: #7a3e00; }
  .my-cal-list .my-cal-chip.k-worked { background: #e6e9ed; color: #3d4a57; }
  .my-cal-list .my-cal-chip.k-absent { background: #fbd9d6; color: #8a1c14; }
  .my-cal-list .my-cal-chip.k-norecord { background: #eef0f2; color: #5b6b7c; }
  .my-cal-list .my-cal-chip.k-cancelled { background: #f4f4f4; color: #777; }
  .my-cal-list .my-cal-chip.k-apply_yes { color: #1a5ac4; }
  .my-cal-list .my-cal-chip.k-apply_no { background: #fafafa; color: #9aa5b1; }
}

/* ===================================================================
   REQ-101 / REQ-104 — activity edit page: three lines of estate facts,
   server-chosen tabs, one-page days table (reschedule / cancel).
   =================================================================== */
.activity-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.activity-head-left { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; min-width: 0; }
.activity-head-left h1 { margin: 0; }
.activity-head-right { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; }
.estate-lines { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.estate-lines .estate-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1.25rem; padding: 0.25rem 0; }
.estate-lines .estate-line + .estate-line { border-top: 1px solid var(--line, #e5e7eb); }
.estate-lines .contact-missing { color: #b45309; font-weight: 600; }
.edit-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.75rem 0 0.5rem; border-bottom: 2px solid var(--line, #e5e7eb); }
.edit-tabs a { padding: 0.5rem 0.9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; text-decoration: none; color: inherit; }
.edit-tabs a.active { background: var(--card, #fff); border-color: var(--line, #e5e7eb); font-weight: 600; margin-bottom: -2px; border-bottom: 2px solid var(--card, #fff); }
.days-helpers { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; margin: 0.5rem 0; }
.days-table td input[readonly] { background: #f3f4f6; }
.days-table .cancel-note { color: #b91c1c; }
.day-summary { list-style: none; padding: 0; margin: 0.5rem 0; }
.day-summary li { padding: 0.4rem 0.6rem; border-left: 4px solid #2563eb; background: #f8fafc; margin-bottom: 0.4rem; }
.day-summary li.cancel { border-left-color: #b91c1c; }
@media (max-width: 719px) {
  .activity-head-right { margin-left: 0; }
  .edit-tabs a { flex: 1 1 auto; text-align: center; }
}
/* Market week grid: week group, Promoter 1–3, six dates. The select and the
   headcount box use the whole date column so the digit is not under the
   spinner. Horizontal scroll keeps the columns wide on a phone. */
.market-week-scroll { overflow-x: auto; }
table.market-week-grid { border-collapse: collapse; min-width: 72rem; width: 100%; text-transform: none; }
table.market-week-grid th,
table.market-week-grid td { text-align: center; vertical-align: middle; text-transform: none; }
table.market-week-grid .mw-week { width: 8.5rem; background: #eef3ff; font-weight: 600; text-align: left; vertical-align: middle; }
table.market-week-grid .mw-promoter { width: 7rem; background: #fafafa; font-weight: 600; text-align: left; white-space: nowrap; }
table.market-week-grid .mw-wd { display: block; font-weight: 400; font-size: 0.75rem; color: var(--c-muted, #666); }
table.market-week-grid select.input { width: 100%; min-width: 9.5rem; }
.market-slot { display: block; position: relative; text-align: left; }
.market-slot[hidden],
select.market-slot-native[hidden],
.market-slot-list[hidden],
.market-slot-list li[hidden] { display: none !important; }
.market-slot input[data-market-search] {
  width: 100%;
  min-width: 9.5rem;
  text-align: left;
}
.market-slot input[data-market-search]:focus {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
  border-color: var(--c-primary);
}
.market-slot-list {
  position: fixed;
  z-index: 30;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--c-input-border, #8a96a3);
  border-radius: 6px;
  max-height: 16rem;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  text-align: left;
}
.market-slot-list li {
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  min-height: 44px;
  line-height: 1.3;
}
.market-slot-list li.is-active,
.market-slot-list li:hover { background: #eef3fb; }
.market-slot-list li.market-slot-empty { color: var(--c-muted); cursor: default; }
table.market-week-grid input.mw-headcount {
  width: 100%;
  min-width: 4.75rem;
  box-sizing: border-box;
  margin-top: 0.35rem;
  padding-left: 0.55rem;
  padding-right: 1.6rem;
}
table.market-week-grid td.mw-off { background: #e0e0e0; color: #555; }
.mw-read-count { display: block; font-size: 0.75rem; color: var(--c-muted, #666); font-weight: 400; }
.mw-panel:not(.editing) .mw-edit,
.mw-panel:not(.editing) .mw-bar { display: none; }
.mw-panel.editing .mw-read { display: none; }
.mw-panel.editing .mw-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.mw-save-note { margin: 0.4rem 0 0; font-weight: 600; }
.mw-save-note:empty { display: none; }
.mw-save-note.is-error { color: #8a1f11; }
@media (max-width: 719px) {
  .market-week-scroll { overflow-x: auto; }
  table.data.market-week-grid { display: table; min-width: 72rem; width: max-content; }
  table.data.market-week-grid thead { display: table-header-group; }
  table.data.market-week-grid tbody { display: table-row-group; }
  table.data.market-week-grid tr {
    display: table-row;
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
  }
  table.data.market-week-grid th,
  table.data.market-week-grid td {
    display: table-cell;
    width: auto;
    border-bottom: 1px solid var(--c-border);
  }
  table.data.market-week-grid td::before { content: none; }
}
.market-name-lines { display: block; min-width: 8rem; }
.market-name-line { display: block; white-space: normal; }
.days-table input.input[type="date"] { width: 9.5rem; max-width: 100%; }
.days-table input.input.w-xs { width: 5rem; display: inline-block; text-align: center; }
.days-table select.input { width: auto; min-width: 6.5rem; }
.days-table td .btn.small { margin: 0 0.25rem 0.25rem 0; }
@media (max-width: 719px) {
  .days-table td { flex-wrap: wrap; justify-content: flex-start; }
  .days-table td::before { flex: 0 0 100%; }
  .days-table td .btn.small { width: auto; white-space: nowrap; }
  .days-table input.input.w-xs { width: 4.5rem; }
  .days-table td[colspan] { display: block; }
  .days-table td[colspan]::before { content: none; }
}
/* REQ-104: keep the title block on the left when a later rule pushes .page-title children right. */
@media (min-width: 720px) {
  .page-title.activity-head > .activity-head-left { margin-left: 0; }
  .page-title.activity-head > .activity-head-right { margin-left: auto; }
}
/* REQ-112 */
/* P01-02: the 「今日」 line on the MGEN dashboard. Label above the figure, as on .stat. */
.today-bar { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 0.6rem 0.75rem; margin-bottom: 0.75rem; }
.today-title { font-size: 1rem; margin: 0 0 0.5rem; }
.today-date { font-weight: 400; font-size: 0.875rem; color: var(--c-muted); }
.today-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.today-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.3rem; min-width: 0; padding: 0.5rem 0.6rem; border: 1px solid var(--c-border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.today-item .l { order: -1; flex: 1 0 100%; font-size: 0.8125rem; color: var(--c-muted); overflow-wrap: anywhere; }
.today-item .l small { font-size: 0.75rem; }
.today-item .n { font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.today-item .u { font-size: 0.875rem; color: var(--c-muted); }
a.today-item .n { color: var(--c-primary); }
a.today-item:hover, a.today-item:focus-visible { border-color: var(--c-primary); background: var(--c-info-bg); }
/* P04-02: 「日報」 beside the day's 已填／未填 on the activity list. */
.day-report-link { margin-left: 0.35rem; font-size: 0.875rem; white-space: nowrap; }
/* P01-04: below 640px each upcoming day is one compact card — date and time on
   top, the activity, the estate, then 通知 and 所需人數 — and nothing is held on
   one line, so even 320px never scrolls sideways. Same markup as the desktop
   table (data-label stays the contract, test_mobile_layout). */
@media (max-width: 639px) {
  table.data.upcoming tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "date time" "shift shift" "estate estate" "notify head";
    gap: 0.2rem 0.75rem;
    padding: 0.55rem 0.7rem;
  }
  table.data.upcoming td { display: block; width: auto; min-width: 0; padding: 0; white-space: normal; overflow-wrap: anywhere; }
  table.data.upcoming td::before { content: none; }
  table.data.upcoming td[data-label="日期"] { grid-area: date; font-weight: 600; overflow-wrap: normal; word-break: keep-all; }
  table.data.upcoming td[data-label="時間"] { grid-area: time; text-align: right; }
  table.data.upcoming td[data-label="更次"] { grid-area: shift; }
  table.data.upcoming td[data-label="屋邨"] { grid-area: estate; font-size: 0.875rem; color: var(--c-muted); }
  table.data.upcoming td[data-label="通知"] { grid-area: notify; align-self: center; }
  table.data.upcoming td[data-label="所需人數"] { grid-area: head; align-self: center; text-align: right; }
  table.data.upcoming td[data-label="所需人數"]::before { content: attr(data-label); margin-right: 0.3rem; font-size: 0.78rem; color: var(--c-muted); }
  table.data.upcoming td.empty { grid-column: 1 / -1; }
  table.data.upcoming .notify-btns { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; justify-content: flex-start; }
}
/* At 320–359px the date and the time no longer fit side by side: the date takes
   the whole first line, so 「2026-10-07 (星期三)」 is never cut at a hyphen. */
@media (max-width: 359px) {
  table.data.upcoming tr { grid-template-areas: "date date" "time time" "shift shift" "estate estate" "notify head"; }
  table.data.upcoming td[data-label="時間"] { text-align: left; }
}

/* REQ-106 — staffing matrix speed (PM P03-03, P03-20, P01-03).
   A cell is a real checkbox laid over its label, not a <select>: the browser
   drew two thousand drop-downs before, and drew them for 3–4 seconds. The
   checkbox is invisible but stays focusable (Tab, Space), and the label is the
   box you see: a bordered square with a faint ＋ that says "press me" when it
   is empty and the mark ("Yes", "Yes(L)") when it is ticked — David,
   2026-09-16: 「派更個位咩都按唔到」. */
label.mx-pick {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 100%; min-width: 3.2rem; min-height: 1.75rem; margin: 0; padding: 0;
  border: 1px solid #c3ccd5; border-radius: 4px; background: var(--c-surface);
  font-size: 0.75rem; cursor: pointer; user-select: none;
}
label.mx-pick:hover { border-color: #5b6b7c; background: #f6f8fb; }
input.mx-box { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; appearance: none; -webkit-appearance: none; border: 0; background: transparent; }
.mx-mark::before { content: "\FF0B"; color: #b4bcc6; font-weight: 400; }
.mx-box:checked + .mx-mark::before { content: attr(data-mark); color: inherit; font-weight: 600; }
label.mx-pick:has(.mx-box:checked) { border-color: transparent; background: transparent; }
label.mx-pick:has(.mx-box:focus-visible) { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.mx-box:disabled { cursor: not-allowed; }
.mx-taken .mx-mark::before { content: ""; }
.mx-locked label.mx-pick { cursor: not-allowed; opacity: 0.45; }
.mx-filters select.input { width: auto; min-width: 9rem; }
/* The day's 當日隊長 and 加人 pickers hold 100+ names each. With an automatic
   width the browser measures every option of every picker before it can lay the
   table out — about two seconds of the page's three. A fixed width skips that
   (3.0s → 0.9s on 82 people, half a month), and a column no longer grows to
   the longest name in the list. */
table.matrix select.mx-leader { width: 6.5rem; min-width: 0; max-width: 6.5rem; }
table.matrix .mx-summary .mx-cell, table.matrix tfoot .mx-cell { width: 6.5rem; min-width: 6.5rem; max-width: 6.5rem; }
@media (max-width: 639px) {
  /* P01-03: every place that can be pressed is at least 40px on a phone. */
  label.mx-pick, .mx-cell label.mx-pick { min-height: 40px; min-width: 3.4rem; }
  button.mx-sort { min-height: 40px; min-width: 40px; }
  .mx-leader-select, select.mx-leader, .mx-filters .input, .mx-filters select.input { min-height: 40px; }
  .mx-filters .btn, .mx-actions .btn { min-height: 40px; }
  .mx-allpeople { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px; }
  .mx-allpeople input[type="checkbox"] { width: 1.5rem; height: 1.5rem; }
  .mx-hint > summary { display: flex; align-items: center; min-height: 40px; }
}

/* REQ-114 (P01-03, PM simulation 2026-10-06): on a phone, nothing on the two
   report pages — 日報 (.shift-report-page) and 報告相片頁 (.report-page) —
   is tapped through a target under 40px. Measured at 390px before: 6 and 20
   targets under 32px (docs/evidence/req114-2026-10-06/). Phone width only; the
   desktop layout is unchanged. 派更矩陣 is REQ-106's, not this block's. */
@media (max-width: 719px) {
  .shift-report-page input[type="file"],
  .report-page input[type="file"] {
    min-height: 40px;
    box-sizing: border-box;
  }
  .shift-report-page input[type="file"]::file-selector-button,
  .report-page input[type="file"]::file-selector-button {
    min-height: 40px;
    padding: 0 0.85rem;
  }
  .shift-report-page input[type="checkbox"],
  .report-page input[type="checkbox"] {
    width: 40px;
    height: 40px;
    margin: 0 0.4rem 0 0;
    flex: none;
    vertical-align: middle;
  }
  .report-page .tab {
    min-height: 40px;
  }
  .shift-report-page summary,
  .report-page summary {
    padding-block: 0.65rem;
  }
}

/* REQ-115: 「本月返工總結」 on 我的更次, and the pay-check link page. */
.pay-summary-list { list-style: none; padding: 0; margin: 8px 0; }
.pay-summary-list li { display: grid; grid-template-columns: 7rem 1fr 5rem minmax(0, 1.4fr); gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--c-border); min-height: 44px; align-items: center; }
.pay-check-totals { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.pay-check-totals dt { color: var(--c-muted); }
.pay-check-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.pay-check-generate { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.pay-check-link { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--c-border); }
@media (max-width: 719px) {
  .pay-summary-list li { grid-template-columns: 1fr auto; }
  .pay-summary-list li > span:nth-child(2) { grid-column: 1 / -1; order: 3; }
  .pay-summary-list li > span:nth-child(4) { grid-column: 1 / -1; order: 4; }
}

/* REQ-118 / REQ-119 / REQ-120 — staffing matrix top row, ⇅ on the 同事 column,
   sticky title row. Scoped to the matrix page (it is the one with #mx_form)
   so the leader matrix, which shares .mx-bar, is untouched.
   A classic scrollbar is about 15px. Reserving the gutter keeps the title
   bar the same width whether or not the page itself scrolls, so measuring
   the bar cannot show and hide that scrollbar forever. */
html:has(#mx_form) { scrollbar-gutter: stable; }
/* 派更(L) is measured against the staffing page. Reserve the same gutter
   so the main column is the same width when only one of them scrolls. */
html:has(#lx_form) { scrollbar-gutter: stable; }
.mx-topactions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-left: auto; }
.mx-help-link { font-size: 0.85rem; white-space: nowrap; }
button.mx-sort-people { margin-left: 0.3rem; }
@media (min-width: 640px) {
  body:has(#mx_form) .mx-bar {
    position: sticky; top: var(--mx-top, 0px); z-index: 9;
    background: var(--c-bg); margin-bottom: 0; padding-block: 0.35rem;
  }
  /* Title on its own line, dates/filters on the left and the actions on the
     right of the second line, so the sticky bar is two rows even at 1366. */
  body:has(#mx_form) .mx-bar h1 { flex: 1 1 100%; margin: 0; }
  body:has(#mx_form) .mx-bar .mx-filters { flex: 1 1 auto; }
  /* The grid takes what is left of the window, less the footer, so the page
     itself does not scroll at 1366×768 or 1440×900 and the thead is never
     slid under the bar. */
  body:has(#mx_form) .matrix-wrap {
    max-height: calc(100vh - var(--mx-top, 0px) - var(--mx-bar-h, 0px) - 4.5rem);
    min-height: 12rem;
  }
}
@media (max-width: 639px) {
  .mx-topactions { margin-left: 0; width: 100%; }
  .mx-topactions .btn { min-height: 40px; }
  .mx-help-link { display: inline-flex; align-items: center; min-height: 40px; }
}

/* REQ-126 (batch 11 WS3) — 人手矩陣 and 派更（Beta）.
   G12: the second line of the top row (由／至／屋邨…) starts under the title;
   儲存／出更表 PDF／常見問題 stay on the right. `.mx-filters` used to be pushed
   right twice — `justify-content: flex-end` on itself and the page head's
   `margin-left: auto` on its first non-title child. Scoped to the two pages
   so the leader matrix, which shares .mx-bar, is untouched. */
body:has(#mx_form) .mx-bar > .mx-filters,
.sb-bar > .mx-filters { justify-content: flex-start; margin-left: 0; }
body:has(#mx_form) .mx-bar > .mx-topactions { margin-left: auto; }
.sb-bar > h1 { flex: 1 1 100%; }

/* G27: 本月總工時 is the third pinned column, so the frame line moves to it. */
table.matrix .mx-pin-2 { border-right: none; }
table.matrix .mx-pin-3 { left: var(--mx-pin-3-left, 11.7rem); border-right: 2px solid #c9d6dd; }
table.matrix .mx-total button.mx-sort { margin-top: .15rem; }

/* G1: ⇆ beside each name orders the days for that colleague. Inline, so the
   name stays on one line; while it is on, each date says its own estate. */
table.matrix button.mx-sort-days { display: inline-block; margin: 0 0 0 .3rem; vertical-align: baseline; }
table.matrix .mx-col-estate,
table.matrix .mx-day-market { display: block; font-size: .75rem; font-weight: 600; white-space: nowrap; }
table.matrix .mx-col-estate[hidden] { display: none; }
table.matrix .mx-group-flat { text-align: left; font-weight: 400; font-size: .85rem; }
.sb-table .sb-sort-days { margin: 0 .3rem 0 0; }
.sb-table .sb-col-estate { display: block; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.sb-table .sb-col-estate[hidden] { display: none; }
.sb-table .sb-estate-flat { text-align: left; font-weight: 400; font-size: .8rem; }
/* On a phone four frozen columns would leave about one day of grid; 本月總工時
   scrolls with the days there, and the frame line stays after 本月日數. */
@media (max-width: 639px) {
  table.matrix .mx-pin-3 { position: static; border-right: none; }
  table.matrix .mx-pin-2 { border-right: 2px solid #c9d6dd; }
}

/* ===================================================================
   REQ-125 (batch 11 WS2, G8／G9／G10) — 「我的更次」.
   Only two kinds of day remain: crew (green) and the person's own leader day
   (orange, 「隊長：你」). These rules come last, so they win over the REQ-105
   block above for those two; the other kinds there are no longer drawn.
   REQ-122 (contrast): every pair here is held to WCAG by
   apps/portals/tests/test_req125_my_shifts.py — text 4.5:1, borders and
   dots 3:1 on white.
   =================================================================== */
.my-cal-chip.k-crew { background: #dff3e6; color: #14532d; border-color: #2e9e57; white-space: normal; }
.my-cal-chip.k-leader { background: #ffe8c7; color: #7a3e00; border-color: #c46a00; white-space: normal; font-weight: 700; }
.my-cal-chip .my-shift-lead { display: block; font-style: normal; font-size: .72rem; }
.my-cal-cell.is-today { outline: 2px solid var(--c-primary); outline-offset: -1px; }
.my-cal-cell.is-today .my-cal-day { color: #0558a8; font-weight: 700; }
.my-shift-disabled { opacity: .45; pointer-events: none; cursor: default; }
.my-shift-limit { font-size: .85rem; color: #44515e; background: #f1f3f5; border-radius: 4px; padding: 6px 8px; margin: 8px 0; }
.my-shift-me { font-weight: 700; color: #7a3e00; }
.my-shift-list li { display: block; }
.my-shift-list a { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 8px; align-items: start; flex-wrap: nowrap; }
.my-shift-date { font-weight: 700; font-variant-numeric: tabular-nums; }
.my-shift-date small { display: block; font-weight: 400; font-size: .72rem; color: var(--c-muted); }
.my-shift-list li.is-today .my-shift-date small { color: #0558a8; font-weight: 700; }
.my-shift-boxes { display: grid; gap: 4px; min-width: 0; }
.my-shift { display: block; border: 1px solid; border-radius: 4px; padding: 4px 8px; }
.my-shift b { display: block; }
.my-shift .my-shift-lead { display: block; font-size: .8rem; }
.my-shift.k-crew { background: #dff3e6; color: #14532d; border-color: #2e9e57; }
.my-shift.k-leader { background: #ffe8c7; color: #7a3e00; border-color: #c46a00; }
.my-shift.k-leader .my-shift-lead { font-weight: 700; }
.my-shift-pill { display: inline-block; border-radius: 3px; padding: 0 6px; font-weight: 500; background: #f1f3f5; color: #44515e; border: 1px solid #8a96a3; }
.my-shift-pill.is-today { background: #e6f1fa; color: #0558a8; border-color: #066fd1; }
.my-shift-pill.is-later { background: #fff; color: #182433; border-color: #8a96a3; }
@media (max-width: 719px) {
  .my-cal-chip.k-crew { background: #2e9e57; }
  .my-cal-chip.k-leader { background: #c46a00; }
  .my-cal-cell .my-shift-today-tag { display: none; }
  .my-shift-list li.is-today { background: transparent; }
}

/* REQ-127 (batch 11 WS4): 每日更次 — 備註 cell, 預覽改動／取消整個活動 on one row,
   排程歷史 as a table. */
.days-table textarea.days-notes { min-width: 9rem; min-height: 2.25rem; resize: vertical; }
.days-actions { align-items: center; }
.revision-table td[data-label="改動"] .nowrap { margin-right: 0.5rem; }

/* REQ-133 H1 (batch 11 UAT W3-a, David: 「好似有啲核突，轉 Tab」): 常見問題.
   The two screens are tabs (the shared .tabs strip above); each question is a
   card that opens on a tap. The marker is drawn here, ▸ shut and ▾ open, so it
   is the same on every browser. Nothing is wider than the screen at 390px:
   the summary text wraps, and the legend's key column is fixed and narrow. */
.help-section .faq {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: var(--c-surface);
  margin: 0 0 0.5rem;
}
.help-section .faq > summary {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: var(--touch);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  list-style: none;
}
.help-section .faq > summary::-webkit-details-marker { display: none; }
.help-section .faq > summary::before {
  content: "▸";
  flex: 0 0 1rem;
  color: var(--c-muted);
  line-height: 1.5;
}
.help-section .faq[open] > summary::before { content: "▾"; color: var(--c-primary); }
.help-section .faq > summary h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  min-width: 0;
  overflow-wrap: anywhere;
}
.help-section .faq[open] > summary { border-bottom: 1px solid var(--c-border); }
.help-section .faq-body { padding: 0.25rem 0.75rem 0.5rem 2.25rem; overflow-wrap: anywhere; }
.help-section .faq-body > :first-child { margin-top: 0.5rem; }
.help-legend {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: grid;
  gap: 0.4rem;
}
.help-legend li {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
}
.help-legend .help-key { text-align: center; }
.help-legend .help-key .mx-key,
.help-legend .help-key .mx-tag { display: inline-block; min-width: 2.5rem; padding: 0.1rem 0.4rem; }
@media (max-width: 719px) {
  .help-section .faq-body { padding-left: 0.75rem; }
}

/* Leader grid uses the staffing grid's compact controls and full-width page. */
.lx-bar > h1 { flex: 1 1 100%; }
.lx-bar > .mx-filters { justify-content: flex-start; margin-left: 0; }
.lx-bar > .mx-topactions { margin-left: auto; }

/* Markets have no leader picker; keep the disabled status distinct from an error. */
select.mx-leader.mx-no-leader:disabled { background: #ffedd5; color: #9a3412; box-shadow: inset 0 0 0 2px #f97316; opacity: 1; }

/* REQ-149: lift only the three roster page headers towards the site navigation.
   Keep the DOM, form ownership and measured sticky offsets unchanged. At laptop
   widths filters retain their own row; a wide desktop can share the title row.
   Phones keep the existing wrapping and touch sizes. */
main.wrap.roster-compact { padding-top: 0.2rem; }
.roster-compact > .page-title { margin-bottom: 0.35rem; }
@media (min-width: 640px) {
  main.roster-compact:has(#mx_form) .mx-bar { padding-block: 0; }
}
@media (min-width: 1600px) {
  main.roster-compact > .page-title > h1,
  main.roster-compact:has(#mx_form) > .page-title > h1 { flex: 0 0 auto; }
  main.roster-compact > .page-title > .mx-filters { flex: 1 1 auto; }
  /* The staffing matrix filter row is wider than 派更(L): two ticks, a hint,
     and the previous/next links. Those two links were the only controls on a
     second 32px line, so the title bar measured about 67px at 1920. One line
     stays under the 55px bar. The closed sort label is short; the long option
     still opens in the menu. Date boxes do not need their full intrinsic width. */
  main.roster-compact:has(#mx_form) > .page-title > .mx-filters {
    flex-wrap: nowrap;
    gap: 0.15rem 0.2rem;
  }
  main.roster-compact:has(#mx_form) .mx-filters select[name="sort"] {
    width: 6.75rem;
    min-width: 0;
  }
  main.roster-compact:has(#mx_form) .mx-filters input[type="date"] {
    width: 7.6rem;
  }
}

/* Keep actions alongside wrapping filters instead of allocating a third row.
   Scope to the three roster pages; other page headings keep their spacing. */
@media (min-width: 640px) {
  main.roster-compact > .page-title { gap: .2rem .5rem; }
  main.roster-compact > .page-title > .mx-filters,
  main.roster-compact:has(#mx_form) > .page-title > .mx-filters { flex: 1 1 0; }
  main.roster-compact > .page-title > .mx-topactions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: .35rem;
  }
  .roster-compact .mx-topactions .btn,
  .roster-compact .sb-tools .btn {
    padding: .25rem .6rem;
    font-size: .85rem;
    min-height: 2rem;
  }
  .roster-compact .mx-filters .input,
  .roster-compact .mx-filters .btn { min-height: 2rem; }
  .roster-compact .mx-filters select.input { min-width: 7rem; }
  .roster-compact .mx-filters { gap: .2rem .35rem; }
}

/* Explanations stay available without large paragraph margins above the grid. */
.roster-compact > .lx-bar + p,
.roster-compact #lx_form > p.small { margin-block: .2rem; }

/* REQ-168: the office home leads with the exception list, inside the same
   shut FAQ disclosure as 常見問題 (.help-section .faq: ▸ shut, ▾ open).
   Secondary counts stay in the existing fold. */
.today-queue { margin-bottom: 0.75rem; }
.exception-list { list-style: none; margin: 0; padding: 0; }
.exception-list li { border-top: 1px solid var(--c-border); }
.exception-list a {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline;
  padding: 0.45rem 0.1rem; color: inherit; text-decoration: none;
}
.exception-list a:hover, .exception-list a:focus-visible { background: var(--c-info-bg); }
.exception-title { font-weight: 600; }
.exception-detail { flex: 1 1 12rem; }

/* REQ-170: digest hour and minute are a clock, not two full-width boxes.
   Recipients sit beside the clock and wrap underneath on a narrow screen.
   Field names, ranges and save behaviour are unchanged. */
.digest-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.75rem;
}
.digest-clock {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  max-width: 100%;
}
.digest-clock-title { margin: 0; font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.digest-clock-face {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.35rem 0.4rem;
}
.digest-time-cell { flex: 0 0 auto; width: 5.25rem; }
.digest-time-cell label {
  display: flex;
  flex-direction: column;
  width: 5.25rem;
  margin: 0 0 0.15rem;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
}
.digest-range { font-weight: 500; color: var(--c-muted); font-size: 0.75rem; }
.digest-settings input[type="number"] {
  width: 5.25rem;
  max-width: 5.25rem;
  text-align: center;
  padding-inline: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.digest-colon {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 0.8rem;
  height: var(--touch, 44px);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}
.digest-recipients {
  flex: 1 1 18rem;
  min-width: min(100%, 18rem);
  margin-bottom: 0;
}
.digest-recipients textarea { min-height: 5.5rem; height: 5.5rem; }
.digest-enabled label { display: inline; margin-right: 0.35rem; }
@media (min-width: 720px) {
  .digest-colon { height: 36px; }
  .digest-recipients textarea { min-height: 4.6rem; height: 4.6rem; }
}

/* Market-week Drive ledger: one row per date, markets in slot columns.
   Estate and new-machine pages do not use this table. */
table.drive-grid {
  width: 100%;
  max-width: 72rem;
  border-collapse: collapse;
}
table.drive-grid th,
table.drive-grid td {
  text-align: left;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--c-border);
  vertical-align: middle;
}
table.drive-grid th {
  background: var(--c-bg);
  font-size: 0.85rem;
  font-weight: 600;
}
table.drive-grid td.drive-day {
  white-space: nowrap;
  font-weight: 600;
}
table.drive-grid .drive-market-name { font-weight: 600; }
table.drive-grid .drive-market-meta { color: var(--c-muted); }
p.drive-week { font-weight: 600; }
