/*
 * Seagull Ops shell stylesheet — mobile-first.
 *
 * Technical layout breakpoints (not operational policy; mirrored by
 * seagull_ops.web.presentation.RESPONSIVE_BREAKPOINTS):
 *   min-width: 48rem — navigation and forms may sit side by side
 *   min-width: 64rem — settings cards flow into two columns
 * No control relies on hover; focus is always visible.
 * Every colour and size named here comes from tokens.css, which every page links first.
 */

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

html { font-size: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.45;
  color: var(--ink);
  background: var(--wash);
  overflow-wrap: anywhere;
}

main { padding: var(--space); max-width: 72rem; margin: 0 auto; width: 100%; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.lead { font-size: 1.05rem; }

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Chromium tabs into a date input's shadow subfields, which do not match :focus-visible on the
   host. :focus-within does, on /today, /week and /admin/today, with the same indicator. */
input[type="date"]:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper);
  padding: 0.5rem;
  z-index: 30; /* above the fixed navigation (UX-8) */
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Header / navigation */
.shell-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem var(--space);
  padding: 0.75rem var(--space);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--accent); margin: 0; }
.central-time-notice { margin: 0; font-size: var(--text-small); color: var(--muted); }
.identity { margin: 0; flex: 1 1 12rem; }
.role-badge,
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--wash);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.badge[data-state="overridden"] { border-color: var(--warn); color: var(--warn); }
.badge[data-state="default"] { border-color: var(--ok); color: var(--ok); }

.primary-nav { flex: 1 1 12rem; }
.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.primary-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid transparent;
}
.primary-nav a[aria-current="page"] { border-color: var(--accent); background: var(--accent-wash); font-weight: 600; }
.logout { flex: 0 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.logout .status { margin: 0; }
.logout button.logout-all { min-height: var(--tap); padding: 0 0.25rem; border: 0; background: none; color: inherit; font-size: var(--text-small); text-decoration: underline; cursor: pointer; }

/* Cards and facts */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  padding: var(--space);
  margin: 0 0 var(--space);
  min-width: 0;
}
.card > :last-child { margin-bottom: 0; }
/* UX-51: the Operations card whose list is open below the cards. */
.operations-tiles > .tile[aria-current="true"] { border-color: var(--accent); background: var(--accent-wash); }
.page-intro { margin: 0 0 var(--space-large); }

/* Status chips (UX-2): always words, with the colour of one of the four states */
.chip {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: var(--text-small);
  font-weight: 600;
}
.chip[data-chip="on_track"] { color: var(--chip-on-track-ink); background: var(--chip-on-track-wash); }
.chip[data-chip="attention"] { color: var(--chip-attention-ink); background: var(--chip-attention-wash); }
.chip[data-chip="done"] { color: var(--chip-done-ink); background: var(--chip-done-wash); }
.chip[data-chip="updating"] { color: var(--chip-updating-ink); background: var(--chip-updating-wash); }

/* Dashboard counts (UX-2): one column on phones, as many as fit above that */
.tiles { list-style: none; margin: 0 0 var(--space-large); padding: 0; display: grid; gap: var(--space); grid-template-columns: minmax(0, 1fr); }
.tiles > .tile { margin: 0; display: grid; gap: var(--space-small); align-content: start; }
.tile p { margin: 0; }
.tile-label { font-weight: 600; }
.tile-value { font-size: var(--text-count); font-weight: 700; line-height: 1.1; }
.tile-note, .tile-reason { font-size: var(--text-small); }
.tile-breakdown, .tile-names { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.tile-breakdown li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-small); }

/* Empty states (UX-2): what is missing, and who can add it, before anything else on the page */
.not-set-up {
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius-large);
  padding: var(--space-large) var(--space);
  margin: 0 0 var(--space);
  text-align: center;
}
.not-set-up > :last-child { margin-bottom: 0; }

/* Module pages (UX-2): a page's forms sit in cards and flow into columns when there is room */
.module-body > form { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-large); box-shadow: var(--shadow); padding: var(--space); margin: 0 0 var(--space); }
.module-body > h2 { margin-top: var(--space-large); }
.form-cards { display: grid; gap: var(--space); grid-template-columns: minmax(0, 1fr); }
.form-cards > .card { margin: 0; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space); grid-template-columns: minmax(0, 1fr); }
.cards > .card { margin: 0; }
.facts { margin: 0 0 0.75rem; display: grid; gap: 0.35rem; }
.facts div { display: grid; gap: 0.15rem; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 0; }
.value { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.link-list { padding-left: 1.25rem; }

/* Forms */
form { display: grid; gap: 0.75rem; min-width: 0; }
.field, label { display: grid; gap: 0.25rem; }
label { font-size: 0.95rem; }
input, select, button { font: inherit; }
select { max-width: 100%; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"], input[type="date"], select {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: var(--tap);
}
button {
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  min-height: var(--tap);
}
button[disabled] { opacity: 0.6; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.actions form { flex: 1 1 14rem; }
.status { min-height: 1.4em; margin: 0; color: var(--warn); }
.status:empty { display: none; }
.login-card { max-width: 26rem; margin: 2rem auto; }
.login-card label.remember { display: flex; align-items: center; gap: 0.5rem; min-height: var(--tap); margin: 0.5rem 0; }
.login-card label.remember input { width: auto; }

/* Business-hours editor */
.windows { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; display: grid; gap: 0.5rem; min-width: 0; }
.windows legend { padding: 0 0.25rem; font-size: 0.9rem; }
.window { display: grid; gap: 0.35rem; }
.window label { display: flex; align-items: center; gap: 0.4rem; }
.window input[type="checkbox"] { width: auto; }

/* Scroll-contained wide data */
.scroll-x { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
/* Tables (UX-2): on a narrow screen each row is a card and each cell names its own column; a table from 48rem up */
table { display: block; width: 100%; border-collapse: collapse; }
caption { display: block; text-align: left; color: var(--muted); padding: 0.25rem 0; }
thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
tbody { display: grid; gap: var(--space-small); }
tbody tr { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-small); min-width: 0; }
tbody th, td { display: block; text-align: left; padding: 0.2rem 0; min-width: 0; }
[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-small); font-weight: 400; color: var(--muted); }

/* Status panel */
.shell-footer { padding: 0 var(--space) var(--space); max-width: 72rem; margin: 0 auto; }
.status-panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space); }
.status-grid { margin: 0 0 0.75rem; display: grid; gap: 0.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid dt { font-size: 0.85rem; color: var(--muted); }
.status-grid dd { margin: 0; }

/* Job Detail (P2-07): sections stack on phones; every status is words, never colour alone */
.job-grid { display: grid; gap: var(--space); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--space); }
.job-grid > .card { margin: 0; }
.section-status { font-weight: 600; }
[data-status]:not([data-status="TRUSTED"]) > .section-status { border-left: 4px solid var(--warn); padding-left: 0.5rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.timeline > li { border-left: 3px solid var(--line); padding: 0.25rem 0 0.25rem 0.75rem; min-width: 0; }
.timeline p { margin: 0 0 0.25rem; }
.explanation { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; max-width: 100%; }
details { margin: 0 0 0.5rem; min-width: 0; }
summary { cursor: pointer; min-height: var(--tap); padding: 0.6rem 0; }

/* Technician Today (P2-08): one column on phones, words for every status, long identities wrap */
.today-card h3 { overflow-wrap: anywhere; }
.today-card .facts dd { overflow-wrap: anywhere; word-break: break-word; }
.today-controls { max-width: 32rem; }
.day-heading { margin: 0 0 var(--space-small); }
.day-heading > :last-child { margin-bottom: 0; }
.hours-line { font-weight: 600; margin: 0 0 var(--space-small); }
/* Lets the pinned card stick for the whole page rather than only within this wrapper. */
[data-today-lead]:not([hidden]) { display: contents; }
.next-job-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-small); margin: 0 0 0.25rem; }
.next-job-head h2 { margin: 0; }
.next-job h3 { margin: 0 0 0.25rem; }
/* On a phone the short card stays in view. It has a fixed ceiling, and whatever is scrolled to stops below that ceiling. */
.next-job[data-pinned] { position: sticky; top: 0; z-index: 5; max-height: min(15rem, 40vh); overflow-y: auto; }
[data-technician-today] :is(h2, a, button, input, select, summary) { scroll-margin-top: 16rem; }
.map-link { display: flex; align-items: center; min-height: var(--tap); }
.job-notes { white-space: pre-wrap; }
.today-card > .chip { margin: 0 0 0.35rem; }
.current-job { margin: 0 0 var(--space-small); }
.current-job p { margin: 0; }
/* The link to a job is a thumb-sized target wherever it appears. */
.job-link { display: inline-flex; align-items: center; min-height: var(--tap); min-width: var(--tap); }
.next-job .job-link {
  justify-content: center;
  width: 100%;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.mode-switch { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; min-width: 0; max-width: 100%; }
.mode-switch legend { padding: 0 0.25rem; }
.mode-choices { display: grid; gap: 0.35rem; }
.mode-choices label { display: flex; align-items: center; gap: 0.45rem; min-width: 0; min-height: var(--tap); }
.mode-choices input { width: auto; flex: 0 0 auto; }
.rest-of-day { margin: 0; }
.lane-links { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Technician Week (P2-09): one day per block, stacking to one column on phones; long labels and identities wrap */
.week-day { border-top: 1px solid var(--line); padding: 0.5rem 0 0; margin: 0 0 0.75rem; min-width: 0; }
.week-day h3 { margin: 0 0 0.25rem; }
.week-day .link-list li { overflow-wrap: anywhere; word-break: break-word; }
.week-day .hours-line { margin: 0.25rem 0 0; }

/* Admin Today (P2-10): technician lanes reuse the day blocks; every finding, reference and identity wraps on phones */
[data-admin-today-result] .link-list li { overflow-wrap: anywhere; word-break: break-word; }
[data-admin-today-result] .card { min-width: 0; }

/* Admin Exceptions (P2-11): one filter column on phones; keys, identities, notes and counts wrap */
.queue-filters { display: grid; gap: 0.5rem; grid-template-columns: minmax(0, 1fr); }
.queue-filters input, .queue-filters select { max-width: 100%; }
[data-queue-result] .card, [data-queue-result] .timeline li { min-width: 0; }
[data-queue-result] .link-list li, [data-queue-result] h3, [data-queue-result] .note { overflow-wrap: anywhere; word-break: break-word; }

/* UX-6: a label read aloud but not drawn (the inline setting editor's "New value") */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.inline-label { display: block; flex: 1 1 8rem; min-width: 0; }
.inline-editor { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.setting-now { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; }
.tile-detail { font-weight: 600; }

/* UX-6: folding sections. The heading is the tap target; a folded section still says how many things it holds. */
.fold > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; }
.fold > summary h2 { display: inline; margin: 0; }
.fold-count { color: var(--muted); }
.pager .actions { margin: 0; }

/* UX-6: on a phone every link a technician taps on My day and My week is a thumb-sized target, and nothing is
   wider than the screen. */
:is([data-technician-today], [data-today-result], [data-technician-week], [data-week-result]) :is(a, button, summary) { min-height: var(--tap); }
:is([data-today-result], [data-week-result]) .link-list a { display: inline-flex; align-items: center; min-height: var(--tap); }
:is([data-today-result], [data-week-result]) :is(.card, .facts, .facts dd, h3, p) { min-width: 0; overflow-wrap: anywhere; }

/* UX-7: the Today board and the To-dos page get the same thumb-sized targets on a phone, and the labor rates read one
   row each: the value, then (for the owner) the box and Save on the same row. */
:is([data-admin-today], [data-admin-today-result], [data-queue-result]) :is(button, summary) { min-height: var(--tap); }
:is([data-admin-today-result], [data-queue-result]) :is(.link-list a, .lane-links a) { display: inline-flex; align-items: center; min-height: var(--tap); }
.rate-row { border-top: 1px solid var(--line); padding: 0.5rem 0; min-width: 0; }
.rate-row > p { margin: 0 0 0.35rem; }
.rate-row form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.rate-row label { flex: 1 1 12rem; min-width: 0; }

/* UX-8: every Dashboard card says its money under its count, and how the open invoices compare with Housecall Pro. */
.tile-money { font-weight: 600; }
.tile-parity { font-size: var(--text-small); }
.tile-parity[data-tile-parity="mismatch"] { color: var(--warn); font-weight: 600; }
.tile > p:last-child a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* UX-8: view tabs. Plain links, each a thumb-sized target with its count; they wrap rather than run off a phone. */
.view-tabs { margin: 0 0 var(--space); }
.view-tabs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-small); }
.view-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  text-decoration: none;
  font-weight: 600;
}
.view-tabs a[aria-current="page"], .view-tabs button[aria-selected="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.view-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  border-color: var(--line);
  background: var(--paper);
  color: var(--accent);
  font-weight: 600;
}
.tab-count { font-weight: 400; }
.view-tabs[role="tablist"] { display: flex; flex-wrap: wrap; gap: var(--space-small); }

/* UX-8: the Invoices and Jobs lists. The amount due is the column that matters, so it reads first and largest. */
.parity p { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-small); align-items: baseline; }
.parity[data-parity="mismatch"] { border-left: 4px solid var(--warn); }
.aging { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; grid-template-columns: minmax(0, 1fr); }
.aging li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-small); border-bottom: 1px solid var(--line); padding: 0.25rem 0; }
.amount-due { font-weight: 700; font-size: 1.1rem; }
.list-table tbody tr { display: grid; gap: 0.15rem; }
.button-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.list-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; min-height: var(--tap); }
.list-filter input { width: auto; min-width: var(--tap); min-height: var(--tap); }
.todo-total { font-size: 1.1rem; font-weight: 700; }
/* UX-10: a to-do is a compact row — its suggested group, the sentence, the suggested step and the links — and its job
   facts fold under "Job details". The facts sit two to a line once there is room; on a phone they stack. */
.todo-row { padding: 0.6rem 0.75rem; }
.todo-row :is(p, a, dd) { overflow-wrap: anywhere; }
.todo-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.3rem; }
.todo-suggested { margin: 0.2rem 0; font-weight: 600; }
/* UX-12: the deciding facts on the row itself; they wrap onto more lines at 375px, never past the card. */
.todo-facts { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; margin: 0 0 0.3rem; font-size: var(--text-small); }
.todo-facts > span { min-width: 0; overflow-wrap: anywhere; }
.todo-legend .badge { margin-right: 0.25rem; }
.todo-details { margin: 0.4rem 0 0; }
.todo-details > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
.todo-details .facts { margin: 0.35rem 0 0; }
.todo-details dd { white-space: pre-line; }
.todo-group-tabs button { font-size: var(--text-small); }
/* UX-14: the Collections working list. Aging chips wrap, the controls stack on a phone, and a row reads invoice,
   customer, amount (largest), then the dates; nothing is wider than a 375px screen. */
.collections-aging { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-small); }
.collections-aging-chip { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: var(--text-small); }
.collections-controls { display: flex; flex-wrap: wrap; gap: var(--space-small) var(--space); align-items: end; margin: var(--space) 0 var(--space-small); }
.collections-controls select { min-height: var(--tap); }
.collection-head { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: center; margin: 0 0 0.2rem; }
.collection-customer { margin: 0 0 0.2rem; font-weight: 600; }
.collection-money { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; align-items: baseline; margin: 0 0 0.3rem; }
/* UX-15: an aging chip is a button that narrows the tab (pressed: the chosen age); a late-fee line wraps on a phone. */
button.collections-aging-chip { color: var(--ink); cursor: pointer; min-height: var(--tap); text-align: left; max-width: 100%; }
button.collections-aging-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.collections-all-ages { margin-top: var(--space-small); background: var(--paper); color: var(--ink); border-color: var(--line); }
/* UX-21: Written off is a quiet link under the tabs, not a tab of its own; pressed while its list is shown. */
.collections-written-off button { min-height: var(--tap); padding: 0 0.25rem; border: 0; background: none; color: var(--muted, inherit); font-size: var(--text-small); text-decoration: underline; cursor: pointer; }
.collections-written-off button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.collections-all-ages[hidden] { display: none; }
/* UX-23: a written-off row's Housecall Pro status, invoice total and sent date: a line of their own, each a separate
   bordered field that wraps whole at 375px (a long value breaks inside its own field, never into the next). */
.collection-written-off { display: flex; flex-wrap: wrap; flex-basis: 100%; gap: 0.3rem 0.4rem; min-width: 0; font-size: var(--text-small); }
.collection-written-off > span { max-width: 100%; padding: 0.05rem 0.45rem; border: 1px solid var(--line); border-radius: 0.3rem; overflow-wrap: anywhere; }
.collection-late-fee { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; margin: 0 0 0.3rem; font-size: var(--text-small); color: var(--warn); }
/* UX-17: the automatic late-fee cutoff banner, and per row what stays manual and the next automatic period. */
.late-fee-auto { border-left: 4px solid var(--warn); padding: 0.4rem 0.75rem; margin: 0.5rem 0; overflow-wrap: anywhere; }
.late-fee-auto p { margin: 0.2rem 0; }
.collection-late-fee-auto { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; margin: 0 0 0.3rem; font-size: var(--text-small); overflow-wrap: anywhere; }
/* UX-18: the Seagull contact log inside a Collections row; at 375px the form's fields stack and long notes break. */
.collection-contacts { margin: 0.3rem 0; font-size: var(--text-small); overflow-wrap: anywhere; }
.collection-contacts p { margin: 0.2rem 0; }
.collection-contact-list { list-style: none; margin: 0.3rem 0; padding: 0; }
.collection-contact { display: flex; flex-wrap: wrap; gap: 0.15rem 0.75rem; padding: 0.3rem 0; border-top: 1px solid var(--line); }
.collection-contact-notes { flex-basis: 100%; white-space: pre-wrap; }
.collection-contact-form { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: flex-end; margin: 0.3rem 0; }
.collection-contact-form label { display: flex; flex-direction: column; gap: 0.15rem; }
.collection-contact-form textarea { min-width: min(100%, 18rem); }
/* UX-16: the late-fee preview and confirm sit inside the row; at 375px the buttons wrap and long words break. */
.late-fee-apply { margin: 0.3rem 0; min-width: 0; }
.late-fee-apply .actions button { flex: 1 1 8rem; min-height: 2.75rem; }
.late-fee-preview { margin-top: 0.4rem; overflow-wrap: anywhere; }
.late-fee-segment { padding: 0.5rem 0.75rem; }
.late-fee-fact { margin: 0.1rem 0; font-size: var(--text-small); }
.late-fee-outcomes { margin: 0.3rem 0; padding-left: 1.1rem; }
/* UX-25: Collections is a compact table (each row a short card on a phone) and one invoice's detail opens in a panel on
   the right (the whole screen on a phone). The filters sit in one tight bar. */
.collections-filters-heading { font-size: var(--text-small); font-weight: 600; margin: var(--space-small) 0 0.25rem; }
.collections-filters .collections-aging-chip { padding: 0.15rem 0.55rem; }
.collections-controls { margin: var(--space-small) 0; }
.collections-hint { font-size: var(--text-small); margin: 0 0 var(--space-small); }
.collections-table-wrap { max-width: 100%; overflow-x: auto; }
.collections-table { font-size: var(--text-small); }
.collections-table td, .collections-table th { overflow-wrap: anywhere; }
.collections-table .collection-balance { font-weight: 700; white-space: nowrap; }
.collection-row { cursor: pointer; }
.collection-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.collection-row[aria-current="true"] { box-shadow: inset 4px 0 0 var(--accent); }
.collections-sort { min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.collections-open { min-height: 2.25rem; padding: 0 0.75rem; }
.collections-detail { position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: var(--paper); padding: var(--space); overflow-wrap: anywhere; }
.collections-detail[hidden] { display: none; }
.collections-detail-head { display: flex; gap: var(--space-small); align-items: start; justify-content: space-between; position: sticky; top: calc(-1 * var(--space)); background: var(--paper); padding: var(--space-small) 0; }
.collections-detail-head h2 { margin: 0; font-size: 1.1rem; }
.collection-detail-section { border-top: 1px solid var(--line); margin-top: var(--space-small); padding-top: var(--space-small); }
.collection-detail-section > h3 { font-size: var(--text-small); margin: 0 0 0.25rem; }
/* UX-26: on Collections a closed form, section or panel stays closed whatever display another rule gives it (form,
   .collection-contact-form and .actions all set one, which would otherwise win over the hidden attribute). */
[data-collections] [hidden] { display: none !important; }
.collection-summary { margin: 0 0 var(--space-small); display: grid; gap: 0.2rem 0.75rem; grid-template-columns: max-content minmax(0, 1fr); font-size: var(--text-small); }
.collection-summary-fact { display: contents; }
.collection-summary dt { color: var(--muted); }
.collection-summary dd { margin: 0; }
.collection-actions { margin-top: var(--space-small); }
.collection-actions [aria-expanded="true"] { box-shadow: inset 0 -3px 0 var(--accent); }
@media (min-width: 48rem) {
  .collections-detail { inset: 0 0 0 auto; width: min(34rem, 100%); border-left: 1px solid var(--line); box-shadow: -0.5rem 0 1.5rem rgb(0 0 0 / 0.12); }
}
/* UX-20: the customer's statement inside a Collections row, and the printable statement sheet (actions never print). */
.collection-statement { margin: 0.3rem 0; font-size: var(--text-small); overflow-wrap: anywhere; }
.collection-statement p { margin: 0.2rem 0; }
.statement-sheet { max-width: 52rem; margin: 0 auto; padding: 1rem; overflow-wrap: anywhere; }
.statement-business { font-size: 1.4rem; font-weight: 700; margin: 0; }
.statement-header p { margin: 0.2rem 0; }
.statement-totals { display: grid; grid-template-columns: max-content max-content; gap: 0.2rem 1.5rem; margin: 0.75rem 0; }
.statement-totals dd { margin: 0; text-align: right; }
.statement-table { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
.statement-table th, .statement-table td { padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.statement-table .statement-amount { text-align: right; white-space: nowrap; }
.statement-past-due td { font-weight: 600; }
.statement-late-fee td:first-child { padding-left: 1.4rem; }
@media print {
  .statement-actions { display: none; }
  .statement-sheet { max-width: none; padding: 0; }
}

/* Breakpoint 48rem: side-by-side header, wider form layouts */
@media (min-width: 48rem) {
  .next-job[data-pinned] { position: static; max-height: none; overflow-y: visible; }
  [data-technician-today] :is(h2, a, button, input, select, summary) { scroll-margin-top: 0; }
  .primary-nav { flex: 1 1 auto; }
  .logout { flex: 0 0 auto; }
  .window { grid-template-columns: 9rem 1fr 1fr; align-items: end; }
  .history-controls { grid-template-columns: 1fr auto auto auto; align-items: end; }
  .status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .queue-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-filters .actions { grid-column: 1 / -1; }
  .todo-details .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-large); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table { display: table; }
  .list-table tbody tr { display: table-row; }
  .aging { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-large); }
  caption { display: table-caption; }
  thead { position: static; display: table-header-group; width: auto; height: auto; overflow: visible; clip-path: none; }
  tbody { display: table-row-group; }
  tbody tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; }
  th, td, tbody th { display: table-cell; text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
  td.value { max-width: 18rem; }
  [data-label]::before { content: none; }
}

/* Breakpoint 64rem: two-column setting and user cards, and (UX-8) the navigation fixed down the left side */
@media (min-width: 64rem) {
  body.with-nav { padding-left: 15rem; }
  body.with-nav .shell-header {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 15rem;
    z-index: 20;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--space);
    padding: var(--space);
    overflow-y: auto;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  body.with-nav .identity,
  body.with-nav .primary-nav,
  body.with-nav .logout { flex: 0 0 auto; }
  body.with-nav .primary-nav ul { flex-direction: column; flex-wrap: nowrap; gap: 0.2rem; }
  body.with-nav .primary-nav a { display: flex; width: 100%; }
  body.with-nav .logout { margin-top: auto; }
  .page-settings .cards,
  .page-users .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-grid > .job-wide,
  .job-grid > .rest-of-day { grid-column: 1 / -1; }
  .status-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
  .form-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
