/* Portal-only layout. Tokens, buttons, and form type come from style.css —
   this file adds the authenticated shell, record lists, and inline charts.
   Clinical white, emerald primary, mono labels. No new font. */

/* ---------- shell ---------- */
.portal-body { min-height: 100vh; display: flex; flex-direction: column; }

.portal-top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 250, 250, .96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.portal-top-inner {
  max-width: 1080px; margin: 0 auto; padding: .85rem var(--pad);
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
}
.portal-tag {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  border-left: 1px solid var(--border-strong); padding-left: .8rem;
}
.portal-nav {
  margin-left: auto; display: flex; align-items: center; gap: 1rem;
  font-size: .88rem; font-weight: 500;
}
.portal-nav a { color: var(--text); text-decoration: none; }
.portal-nav a:hover { color: var(--primary); }
.portal-nav a[aria-current="page"] { color: var(--primary); }
.portal-nav .linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.portal-nav .linkish:hover { color: var(--primary); }
.portal-nav .linkish[hidden] { display: none; }

.portal-main {
  width: 100%; max-width: 1080px; margin: 0 auto;
  padding: clamp(1.75rem, 4vw, 2.75rem) var(--pad) 3.5rem;
  display: grid; gap: 1.1rem; align-content: start;
  flex: 1 0 auto;
}
/* A grid item's automatic minimum is its min-content width, so one wide table
   would push the whole page sideways instead of scrolling inside .table-scroll. */
.portal-main > * { min-width: 0; }
.portal-center { max-width: 600px; padding-top: clamp(2rem, 6vw, 4.25rem); }
.portal-narrow { max-width: 780px; }

.portal-kicker {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--primary); margin-bottom: .5rem;
}
.portal-main h1 { font-size: clamp(1.65rem, 3.4vw, 2.25rem); }
.portal-lede { color: var(--muted); margin-top: .5rem; max-width: 44rem; }
.portal-lede .mono { font-size: .92em; color: var(--text); }
.portal-help { color: var(--muted); font-size: .88rem; margin-top: 1rem; }
.portal-help a { color: var(--primary); font-weight: 600; text-underline-offset: 2px; }

/* ---------- card / panel ---------- */
.portal-card,
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.25rem;
}
.portal-card {
  border-radius: 10px; padding: clamp(1.35rem, 3vw, 2rem);
  box-shadow: 0 1px 0 rgba(26, 31, 28, .04), 0 18px 40px -34px rgba(20, 83, 45, .45);
}
.panel h2 { font-size: 1.05rem; margin-bottom: .9rem; }
.panel h2 .mono { color: var(--muted); font-weight: 500; font-size: .8rem; margin-left: .4rem; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.panel-head h2 { margin-bottom: 0; }
.panel-note { color: var(--muted); font-size: .86rem; margin: -.4rem 0 .9rem; }

/* ---------- forms ---------- */
.portal-form .field { margin-bottom: .85rem; }
.portal-form .field:last-of-type { margin-bottom: 1rem; }
.portal-form label {
  display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem;
}
.portal-form input,
.portal-form select,
.portal-form textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem;
  transition: border-color .15s ease;
}
.portal-form input:hover,
.portal-form select:hover,
.portal-form textarea:hover { border-color: var(--border-strong); }
.portal-form textarea { min-height: 96px; resize: vertical; }
.portal-card .portal-form .btn { width: 100%; }
.portal-form .btn { min-width: 9rem; }
.portal-form .hint { color: var(--muted); font-size: .78rem; margin-top: .3rem; }
.portal-form .label-note {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  margin-left: .3rem;
}
.portal-form input[type="file"] { padding: .45rem .5rem; font-size: .86rem; }
.portal-form input[type="file"]:focus-visible { outline-offset: 2px; }
.portal-form .field-error {
  color: #9f1239; font-size: .78rem; font-weight: 600;
  margin-top: .3rem; overflow-wrap: anywhere;
}
.portal-form input[aria-invalid="true"],
.portal-form select[aria-invalid="true"],
.portal-form textarea[aria-invalid="true"] {
  border-color: #9f1239;
  background: #fdf2f6;
}
/* The focused invalid field must not wear the green focus ring — a green ring
   over a red border reads as "this one is fine". */
.portal-form input[aria-invalid="true"]:focus-visible,
.portal-form select[aria-invalid="true"]:focus-visible,
.portal-form textarea[aria-invalid="true"]:focus-visible {
  outline-color: #9f1239;
}
.portal-form button[disabled] { opacity: .55; cursor: not-allowed; }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 .85rem;
}
.form-status { min-height: 1.3rem; margin-top: .5rem; font-size: .9rem; }
.form-status.ok { color: var(--primary); font-weight: 600; }
.form-status.err { color: #9f1239; font-weight: 600; }

/* A collapsed log form: one 44 px summary bar in the house mono, opened in
   place. Not a modal — the record it writes to stays on screen behind it. */
.log-form {
  margin-top: 1rem; padding: 0 .95rem .3rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg);
}
.log-form > summary {
  display: flex; align-items: center; gap: .5rem; min-height: 44px;
  cursor: pointer; list-style: none;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 600; color: var(--primary);
}
.log-form > summary::-webkit-details-marker { display: none; }
.log-form > summary::before {
  content: "+"; font-size: 1rem; line-height: 1; color: var(--muted);
}
.log-form[open] > summary::before { content: "–"; }
.log-form > summary:hover { color: var(--primary-dark); }
.log-form > summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px;
}
.log-form .portal-form { padding: .15rem 0 .5rem; }
/* 44 px minimum on every control: the crews log this on a phone, one-handed. */
.log-form .portal-form input,
.log-form .portal-form select { min-height: 44px; }
.log-form .portal-form .btn { width: auto; }
.log-form .portal-form .form-status { margin-bottom: .2rem; }

/* ---------- notices ---------- */
.notice {
  border: 1px solid var(--border-strong); border-left: 3px solid var(--muted);
  background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
  padding: .7rem .9rem; font-size: .92rem;
}
.notice[hidden] { display: none; }
.notice p + p { margin-top: .35rem; }
.notice a { color: var(--primary); font-weight: 600; text-underline-offset: 2px; }
.notice.err { border-left-color: #9f1239; }
.notice.err p { color: #9f1239; }
.notice.ok { border-left-color: var(--primary); background: var(--primary-tint); }
.notice.ok p { color: var(--primary-dark); }

/* ---------- record lists ---------- */
.record-list { list-style: none; display: grid; }
.record-list li {
  display: grid; grid-template-columns: 8.5rem 6.5rem 1fr;
  gap: .75rem; align-items: baseline;
  padding: .6rem 0; border-top: 1px solid var(--border);
  font-size: .92rem;
}
.record-list li:first-child { border-top: 0; padding-top: .15rem; }
.record-date {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .02em;
  color: var(--muted); white-space: nowrap;
}
.record-kind {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--primary);
}
.record-title { color: var(--text); overflow-wrap: anywhere; }

/* Provenance tag: "Specialist" for an operator-logged row, "Crew" for a
   client-logged one. One muted pill, no colour claim about either. */
.badge-role {
  display: inline-block; font-family: var(--font-mono); font-size: .6rem;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: .05rem .45rem; white-space: nowrap; vertical-align: .12em;
}
.record-title .badge-role { margin-left: .45rem; }

/* ---------- files: preview + download ---------- */
.record-list.file-list li {
  display: block; padding: .9rem 0 1rem; font-size: .92rem;
}
.file-record-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
}
.file-record-head .record-kind { text-align: right; }
.file-preview {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 34rem; aspect-ratio: 4 / 3;
  margin: .7rem 0 .65rem; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg);
}
.file-preview-frame {
  display: block; width: 100%; height: 100%;
  border: 0; background: #fff;
}
.file-preview-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.file-preview-note {
  margin: 0; padding: .7rem .8rem; color: var(--muted); font-size: .82rem;
}
.file-record-actions { display: flex; align-items: center; gap: .9rem; }
.file-download {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .07em;
  text-transform: uppercase; font-weight: 600; color: var(--primary);
  text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 1px;
}
.file-download:hover, .file-download:focus-visible { color: var(--primary-dark); }
.empty { color: var(--muted); font-size: .9rem; }
.empty[hidden] { display: none; }

/* Baseline facts and the readings table both live in the record-lists section:
   a label/value pair and a scrollable grid, no new visual language. */
.baseline-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .9rem 1.25rem; margin: 0;
}
.baseline-item { min-width: 0; }
.baseline-grid dt {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .25rem;
}
.baseline-grid dd {
  margin: 0; font-size: 1rem; font-weight: 600; color: var(--text);
  overflow-wrap: anywhere;
}

.readings-scroll { margin-top: 1rem; }
.readings-table {
  width: 100%; min-width: 34rem; border-collapse: collapse;
  font-size: .86rem;
}
.readings-table th {
  text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  background: var(--bg);
  padding: .6rem .75rem; border-bottom: 1px solid var(--border-strong);
}
.readings-table td {
  padding: .55rem .75rem; border-top: 1px solid var(--border);
  vertical-align: top; overflow-wrap: anywhere;
}
.readings-table tbody tr:first-child td { border-top: 0; }
.readings-table tbody tr:hover { background: var(--bg); }
.readings-table .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.readings-table td.zone { color: var(--text); min-width: 6.5rem; }
.readings-table td.date { white-space: nowrap; color: var(--muted); }
.readings-table td.role { white-space: nowrap; }

/* Applications and the action list reuse the readings table's chrome so the
   three panels read as one record. Both carry far fewer columns than the
   readings table, so they fit a phone instead of forcing a sideways scroll. */
.readings-table.applications-table,
.readings-table.action-table { min-width: 0; }
/* The client action list is four narrow columns: 17rem fits a 375 px phone
   without scrolling sideways and without breaking words in half. */
.readings-table.action-table { min-width: 17rem; }
.applications-scroll { margin-top: .35rem; }
.applications-table td.kind {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--primary); white-space: nowrap;
}
.applications-table td.record-title { color: var(--text); }
.action-table td.action { color: var(--text); min-width: 0; overflow-wrap: break-word; }
.action-table td.severity { white-space: nowrap; }
.action-table td.status { white-space: nowrap; }
.action-table td.zone { min-width: 0; }
.action-table td { overflow-wrap: break-word; }
/* On a phone the status cell wraps on its space instead of pushing the table
   sideways: "In progress" under "In" is readable, a clipped column is not. */
@media (max-width: 560px) {
  .readings-table.action-table { min-width: 0; }
  .action-table td.status { white-space: normal; }
  .action-table th { font-size: .58rem; padding: .5rem .3rem; }
  .action-table td { padding: .5rem .3rem; }
  .action-table .tag-severity { padding: .1rem .35rem; font-size: .58rem; }
}
.action-table td.action-remove { text-align: right; white-space: nowrap; }

/* Severity is a text tag, not a colour bar: the word is the signal, the tone
   only reinforces it. Same tokens as the status badges — no new palette. */
.tag-severity {
  display: inline-block; font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .09em; text-transform: uppercase;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: .1rem .5rem; color: var(--muted);
}
.tag-severity.critical { color: #9f1239; border-color: #e6c9d0; }
.tag-severity.high { color: var(--amber); border-color: #eed6b4; }
.tag-severity.moderate { color: var(--muted); border-color: var(--border-strong); }

/* Inline editors inside the admin action table: small, but never under the
   44 px tap target the rest of the portal holds itself to. */
.action-select {
  font: inherit; font-size: .82rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: .35rem .45rem; min-height: 36px; max-width: 9.5rem;
}
.action-select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.action-remove-btn {
  min-height: 36px; padding: .3rem .6rem; font-size: .78rem;
}
.action-remove-btn.is-armed { background: #fdf3f5; }

/* The bench-sheet control sits under the lede, not in a panel: it acts on the
   whole page. Hidden on paper by .no-print. */
.portal-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.portal-tools .btn { min-height: 44px; padding: .5rem .9rem; font-size: .86rem; }

/* ---------- charts ---------- */
.zone-filter {
  display: flex; align-items: center; gap: .5rem;
  font-size: .82rem; font-weight: 600;
}
.zone-filter[hidden] { display: none; }
.zone-filter label { margin: 0; }
.zone-filter select {
  font: inherit; font-weight: 500; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: .4rem .55rem; max-width: 14rem;
}
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.chart {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem .9rem .55rem;
}
.chart figcaption {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .6rem; margin-bottom: .45rem;
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.chart figcaption b { color: var(--text); font-weight: 600; }
.chart-svg { display: block; width: 100%; height: 210px; }
.chart-svg text { font-family: var(--font-mono); fill: var(--muted); font-size: 10px; }
.chart-band { pointer-events: none; }
.chart-band-edge { pointer-events: none; }
.chart-legend {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  margin: .45rem 0 0; font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.legend-key { display: inline-flex; align-items: center; gap: .4rem; }
.legend-key::before {
  content: ""; display: inline-block; width: 1.15rem; height: 0;
  border-top: 2px solid var(--primary);
}
.legend-key.legend-input::before { border-top: 1.5px dashed #6b7280; }
.chart-empty {
  color: var(--muted); font-size: .86rem; text-align: center;
  padding: 4.1rem 0;
}

/* ---------- thread ---------- */
.thread { list-style: none; display: grid; gap: .65rem; margin-bottom: 1.1rem; }
.thread li { border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem .85rem; background: var(--bg); max-width: 46rem; min-width: 0; }
.thread li.admin { background: var(--primary-tint); border-color: #d7e4da; margin-left: auto; }
.msg-meta {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .25rem;
}
.msg-body { white-space: pre-wrap; font-size: .92rem; overflow-wrap: anywhere; }
.thread-empty { margin-bottom: 1.1rem; }

/* Photos on a message: one 96 px cover-cropped frame each, wrapped rather than
   rowed, so two thumbnails still fit a 375 px thread without a sideways scroll.
   The <img> is only given a src by the observer in portal.js. */
.msg-attachments {
  display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .55rem;
  max-width: 100%;
}
.msg-attachment {
  position: relative; flex: 0 0 auto; display: block;
  width: 96px; height: 96px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s ease;
}
.msg-attachment:hover { border-color: var(--primary); }
.msg-attachment:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.msg-thumb { display: block; width: 96px; height: 96px; object-fit: cover; }
.msg-attachment.is-broken img { display: none; }
.msg-thumb-note {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; height: 100%; padding: .35rem;
  font-family: var(--font-mono); font-size: .58rem; line-height: 1.3;
  color: var(--muted); overflow-wrap: anywhere;
}

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.1rem; align-items: start; }
.admin-wide { grid-column: 1 / -1; }

/* The reading form's two pairs read as one set each: pour-through on top, the
   optional feed-water pair under it. A group label spans the whole grid row. */
.form-grid > .form-group-label,
.form-grid > .hint { grid-column: 1 / -1; }
.form-group-label {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--primary); margin-bottom: .5rem;
}
.form-group-label .mono {
  color: var(--muted); font-weight: 500; letter-spacing: .06em; margin-left: .35rem;
}
.client-row {
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
  padding: .55rem 0; border-top: 1px solid var(--border); font-size: .92rem;
}
.client-row:first-child { border-top: 0; padding-top: .1rem; }
.client-name { font-weight: 600; }
.client-meta { color: var(--muted); font-size: .8rem; font-family: var(--font-mono); }
.badge-status {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .09em;
  text-transform: uppercase; border: 1px solid var(--border-strong);
  color: var(--muted); border-radius: 999px; padding: .1rem .5rem;
}
.badge-status.approved { color: var(--primary); border-color: #bcd3c2; background: var(--primary-tint); }
.badge-status.pending { color: var(--amber); border-color: #eed6b4; }
.client-row .btn { padding: .4rem .7rem; font-size: .82rem; }
.client-actions {
  margin-left: auto; display: flex; align-items: center;
  gap: .45rem; flex-wrap: wrap;
}
.client-actions .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .45rem .8rem; font-size: .82rem;
}
.btn-danger { background: transparent; border-color: #e6c9d0; color: #9f1239; }
.btn-danger:hover { background: #fdf3f5; border-color: #9f1239; color: #9f1239; transform: none; }
.btn-danger.is-armed { background: #9f1239; border-color: #9f1239; color: #fff; }
.btn-danger.is-armed:hover { background: #84102f; border-color: #84102f; color: #fff; }

/* ---------- admin: zones ---------- */
.zone-list { list-style: none; display: grid; margin-bottom: .35rem; }
.zone-list[hidden] { display: none; }
.zone-row {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .5rem 0; border-top: 1px solid var(--border); font-size: .92rem;
}
.zone-row:first-child { border-top: 0; padding-top: .1rem; }
.zone-row.is-editing { display: block; }
.zone-name { font-weight: 600; overflow-wrap: anywhere; }
.zone-actions { margin-left: auto; display: flex; gap: .45rem; flex-wrap: wrap; }
.zone-actions .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: .4rem .75rem; font-size: .82rem;
}
.zone-rename { margin: .25rem 0 .15rem; }
.zone-rename .field { margin-bottom: .6rem; }

/* The four target bounds: one row under the name, save button on its right.
   Wraps to two columns on a phone rather than scrolling sideways. */
.zone-targets {
  flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: flex-start;
  gap: .5rem .6rem;
}
.zone-targets-grid {
  flex: 1 1 21rem; min-width: 0;
  display: grid; grid-template-columns: repeat(4, minmax(4.5rem, 1fr));
  gap: 0 .5rem;
}
.zone-targets .field { margin-bottom: 0; min-width: 0; }
.zone-targets label {
  display: block; font-size: .68rem; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); margin-bottom: .2rem;
}
.zone-targets input {
  display: block; width: 100%; padding: .5rem .5rem; min-height: 40px; font-size: .88rem;
}
.zone-targets-save {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .45rem .8rem; font-size: .82rem; flex: 0 0 auto;
  align-self: flex-start;
  /* Clears the bound label so the button tops out level with the inputs, not
     with the error text a tall field may carry underneath. */
  margin-top: 1.05rem;
}
.zone-targets-status { flex: 1 1 100%; margin-top: 0; }
.zone-targets-status:empty { display: none; }
@media (max-width: 560px) {
  .zone-targets-grid { flex: 1 1 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .5rem; }
  .zone-targets-save { width: 100%; }
}
.inline-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }
.inline-row input { flex: 1 1 12rem; min-width: 0; }
.zone-add .inline-row { align-items: center; }
.zone-add .inline-row .btn { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
@media (max-width: 560px) {
  .zone-add .inline-row .btn { width: 100%; }
}

/* The message signal on a client row: one line of mono facts, then the first
   120 characters of the last body. */
.client-msg {
  flex: 1 1 100%; display: flex; gap: .5rem; flex-wrap: wrap;
  align-items: baseline; min-width: 0;
  font-size: .82rem; color: var(--muted);
}
.client-msg-meta {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--primary); white-space: nowrap;
}
.client-msg-body { overflow-wrap: anywhere; }

/* ---------- admin: settings ---------- */
.panel-sub {
  font-size: .9rem; font-weight: 600; color: var(--text);
  margin-bottom: .35rem;
}
.panel h2 + .panel-sub { margin-top: -.35rem; }

/* ---------- admin: leads ---------- */
.leads-controls,
.leads-import {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: .6rem; margin-bottom: .75rem;
}
.leads-controls .field,
.leads-import .field { margin: 0; }
.leads-controls .field-grow,
.leads-import .field-grow { flex: 1 1 15rem; min-width: 0; }
.leads-controls .field-action,
.leads-import .field-action { flex: 0 0 auto; }
.leads-controls label,
.leads-import label {
  display: block; font-size: .78rem; font-weight: 600; margin-bottom: .3rem;
}
.leads-controls input,
.leads-controls select,
.leads-import input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; min-height: 44px; width: 100%;
}
.leads-controls input:hover,
.leads-controls select:hover { border-color: var(--border-strong); }
.leads-controls select { padding-right: 1.6rem; }
.leads-import input[type="file"] { padding: .5rem .6rem; font-size: .86rem; }
.leads-controls .btn,
.leads-import .btn,
.leads-pager .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .55rem .9rem; font-size: .86rem; white-space: nowrap;
}

.table-scroll {
  overflow-x: auto; max-width: 100%;
  /* Positioned so an absolutely positioned descendant (the .sr-only header
     label) is clipped by this box instead of escaping it and widening the
     document at 375 px. */
  position: relative;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.table-scroll[hidden] { display: none; }
.table-scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.leads-table {
  width: 100%; min-width: 44rem; border-collapse: collapse;
  font-size: .88rem;
}
.leads-table th {
  text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  background: var(--bg);
  padding: .6rem .75rem; border-bottom: 1px solid var(--border-strong);
}
.leads-table td {
  padding: .55rem .75rem; border-top: 1px solid var(--border);
  vertical-align: top; overflow-wrap: anywhere;
}
.leads-table tbody tr:first-child td { border-top: 0; }
.leads-table tbody tr:hover { background: var(--bg); }
.lead-name { font-weight: 600; }
.lead-miles { font-family: var(--font-mono); font-size: .78rem; white-space: nowrap; color: var(--muted); }
.lead-priority {
  display: inline-block; min-width: 1.4rem; text-align: center;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em;
  border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--muted); padding: .05rem .4rem;
}
.lead-priority.p3 { color: var(--primary); border-color: #bcd3c2; background: var(--primary-tint); }
.cell-none { color: var(--muted); font-family: var(--font-mono); }
.leads-table a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.leads-table a:hover { color: var(--primary-dark); }
.leads-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-top: .8rem;
}
.leads-count { color: var(--muted); font-size: .86rem; font-family: var(--font-mono); }
.leads-pager { display: flex; gap: .5rem; }
.leads-pager .btn[disabled] { opacity: .5; cursor: not-allowed; }
.leads-pager .btn[disabled]:hover { border-color: var(--border-strong); color: var(--text); transform: none; }
@media (max-width: 560px) {
  .leads-controls .field,
  .leads-import .field { flex: 1 1 100%; }
  .leads-controls .field-action .btn,
  .leads-import .field-action .btn { width: 100%; }
  .leads-foot { align-items: stretch; }
  .leads-pager .btn { flex: 1 1 0; }
}
.copy-row { display: flex; gap: .5rem; margin: .5rem 0 .35rem; flex-wrap: wrap; }
.copy-row input { flex: 1 1 18rem; font-family: var(--font-mono); font-size: .8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .65rem; color: var(--text); }
.copy-row .btn { width: auto; padding: .55rem .8rem; font-size: .85rem; }
.file-row { display: grid; grid-template-columns: 1fr 7rem; gap: .75rem; font-size: .9rem; padding: .45rem 0; border-top: 1px solid var(--border); }
.file-row:first-child { border-top: 0; }
.file-row .record-kind { text-align: right; }

/* ---------- footer ---------- */
.portal-foot {
  border-top: 1px solid var(--border); color: var(--muted);
  font-size: .82rem; padding: 1.4rem var(--pad) 1.6rem; text-align: center;
}
.portal-foot a { color: var(--text); text-decoration: none; }
.portal-foot a:hover { color: var(--primary); }
.portal-foot .sep { margin: 0 .5rem; color: var(--border-strong); }

@media (max-width: 720px) {
  .record-list li { grid-template-columns: 7rem 1fr; }
  .record-list li .record-title { grid-column: 1 / -1; }
  .chart-svg { height: 180px; }
  .portal-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-form input { transition: none; }
}

/* ---------- print: the bench sheet ----------
   /dashboard is the page a grower prints and walks to the bench with: what is
   booked, what still has to be done, and the readings behind both. Everything
   that needs a session, a pointer or a chart rasteriser is hidden; the three
   tables are forced to black on white with real rules so a mono laser keeps
   every column readable. No background colour is painted, so no
   print-color-adjust hint is needed. */
@media print {
  @page { margin: 12mm; }

  body[data-page="dashboard"] { background: #fff; color: #000; }
  body[data-page="dashboard"] .portal-main {
    display: block; max-width: none; padding: 0; gap: 0;
  }

  body[data-page="dashboard"] .portal-top,
  body[data-page="dashboard"] .portal-foot,
  body[data-page="dashboard"] .skip,
  body[data-page="dashboard"] .notice,
  body[data-page="dashboard"] .no-print,
  body[data-page="dashboard"] .portal-tools,
  body[data-page="dashboard"] .portal-kicker,
  body[data-page="dashboard"] .zone-filter,
  body[data-page="dashboard"] .charts,
  body[data-page="dashboard"] #signout,
  body[data-page="dashboard"] form,
  body[data-page="dashboard"] details.log-form,
  body[data-page="dashboard"] .thread,
  body[data-page="dashboard"] .panel-note,
  body[data-page="dashboard"] button,
  body[data-page="dashboard"] section[aria-labelledby="h-baseline"],
  body[data-page="dashboard"] section[aria-labelledby="h-files"],
  body[data-page="dashboard"] section[aria-labelledby="h-messages"],
  body[data-page="dashboard"] #payment-panel {
    display: none !important;
  }

  body[data-page="dashboard"] .panel {
    background: #fff; border: 0; border-radius: 0; box-shadow: none;
    padding: 0; margin: 0 0 14pt;
  }
  body[data-page="dashboard"] h1 { font-size: 16pt; line-height: 1.2; color: #000; margin: 0 0 2pt; }
  body[data-page="dashboard"] .panel h2 {
    font-size: 13pt; line-height: 1.25; color: #000; margin: 0 0 6pt;
    break-after: avoid;
  }
  body[data-page="dashboard"] .portal-lede { color: #000; font-size: 10pt; margin: 0 0 12pt; max-width: none; }
  body[data-page="dashboard"] .empty { color: #000; font-size: 10pt; }

  body[data-page="dashboard"] .table-scroll {
    overflow: visible; max-width: none; border: 0; border-radius: 0; background: #fff;
  }
  body[data-page="dashboard"] .readings-table {
    width: 100%; min-width: 0; border-collapse: collapse;
    font-size: 10pt; color: #000;
  }
  /* Repeats the header on every page the table spans. */
  body[data-page="dashboard"] .readings-table thead { display: table-header-group; }
  body[data-page="dashboard"] .readings-table tfoot { display: table-footer-group; }
  body[data-page="dashboard"] .readings-table tr { break-inside: avoid; }
  body[data-page="dashboard"] .readings-table th,
  body[data-page="dashboard"] .readings-table td {
    border: 1px solid #000; padding: 3pt 5pt;
    color: #000; background: #fff;
    font-family: var(--font-body); font-size: 10pt; line-height: 1.3;
  }
  body[data-page="dashboard"] .readings-table th {
    font-weight: 700; text-transform: none; letter-spacing: 0; white-space: normal;
  }
  body[data-page="dashboard"] .readings-table td.num,
  body[data-page="dashboard"] .readings-table td.date,
  body[data-page="dashboard"] .readings-table td.zone { color: #000; }
  body[data-page="dashboard"] .tag-severity,
  body[data-page="dashboard"] .badge-role {
    color: #000; border: 1px solid #000; background: transparent;
    border-radius: 0; padding: 0 .2rem; font-size: 9pt;
  }
}


/* ---------- client calendar ---------- */

/* Month navigation and the filter toggles sit above the grid; both are
   ordinary buttons so the keyboard path is the same as the mouse path. */
.cal-nav { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.cal-nav .btn,
.cal-step {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .45rem .8rem; font-size: .82rem; white-space: nowrap;
}
.cal-month {
  margin: 0; min-width: 9.5rem; text-align: center;
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text);
}

.cal-filter {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin-bottom: .8rem;
}
.cal-filter-label {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin-right: .15rem;
}
.cal-toggle {
  min-height: 44px; padding: .5rem .9rem; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 999px;
}
.cal-toggle:hover { border-color: var(--primary); color: var(--primary-dark); }
.cal-toggle[aria-pressed="true"],
.cal-toggle[aria-pressed="true"]:hover {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.cal-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* table-layout: fixed is what keeps a long title from widening a day cell and
   pushing the page sideways at 375 px — every column is exactly 1/7. */
.cal-grid-wrap { max-width: 100%; }
.cal-grid {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  font-size: .78rem;
}
.cal-grid th {
  text-align: left; padding: .45rem .35rem;
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--border-strong);
}
.cal-grid td {
  border: 1px solid var(--border); vertical-align: top;
  padding: .35rem .3rem; height: 5.6rem;
}
.cal-grid td.cal-blank { background: var(--bg-alt); border-color: var(--border); }
.cal-day {
  display: block; margin-bottom: .2rem;
  font-family: var(--font-mono); font-size: .66rem; color: var(--muted);
}
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell.is-today .cal-day { color: var(--primary-dark); font-weight: 700; }

.cal-chips { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
/* The kind word is printed on every chip, so a colour-blind reader (or a
   black-and-white print) still knows what the entry is. */
.cal-chip {
  display: block; padding: .15rem .3rem; border: 1px solid;
  border-radius: 6px; font-size: .66rem; line-height: 1.25;
  overflow-wrap: anywhere;
}
.cal-chip .chip-kind { display: block; font-weight: 700; font-size: .6rem; }
.cal-chip .chip-short { display: none; font-weight: 700; }
.cal-chip .chip-title { display: block; color: var(--text); }
.cal-chip.feed { background: var(--primary-tint); border-color: #bcd3c2; }
.cal-chip.feed .chip-kind { color: var(--primary-dark); }
/* Amber's own 4.5:1 partner: #d97706 on white is 3.1:1, too light for text. */
.cal-chip.spray { background: #fdf6ec; border-color: #eed6b4; }
.cal-chip.spray .chip-kind { color: #92400e; }
.cal-chip.other { background: var(--bg); border-color: var(--border-strong); }
.cal-chip.other .chip-kind { color: var(--muted); }

.cal-agenda-title {
  margin: 1.5rem 0 .6rem;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.cal-agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.cal-agenda li {
  display: flex; flex-wrap: wrap; gap: .1rem .35rem; align-items: baseline;
  padding: .5rem .65rem; font-size: .9rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.cal-agenda .agenda-date {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap;
}
.cal-agenda .agenda-sep { color: var(--muted); }
.cal-agenda .agenda-kind { font-weight: 700; color: var(--primary-dark); }
.cal-agenda .agenda-kind.spray { color: #92400e; }
.cal-agenda .agenda-title { color: var(--text); overflow-wrap: anywhere; }
.cal-agenda .tag-unscheduled { color: var(--muted); font-size: .78rem; }

@media (max-width: 560px) {
  .cal-month { min-width: 0; width: 100%; order: -1; text-align: left; }
  .cal-grid th { padding: .4rem .1rem; font-size: .55rem; text-align: center; }
  .cal-grid td { padding: .25rem .18rem; height: 5.2rem; }
  .cal-day { font-size: .62rem; }
  .cal-chip { padding: .1rem .15rem; border-radius: 4px; font-size: .56rem; }
  .cal-chip .chip-kind { display: none; }
  /* A whole word, never "Amen / d": the short label is kept on one line and
     the cell is wide enough for five characters at this size. */
  .cal-chip .chip-short { display: block; font-size: .54rem; white-space: nowrap; }
  /* Seven 42 px columns cannot carry a sentence. The agenda below is the
     readable view; the cell keeps the kind word so the tile is never colour
     alone. */
  .cal-chip .chip-title { display: none; }
  .cal-agenda li { padding: .45rem .5rem; font-size: .86rem; }
}

/* ---------- admin: scheduled applications ---------- */

.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-actions .btn { min-height: 44px; }
.form-actions .btn[hidden] { display: none; }

.readings-table.scheduled-apps-table { min-width: 0; }
.scheduled-apps-table td.kind {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--primary); white-space: nowrap;
}
.scheduled-apps-table td.app-actions { text-align: right; white-space: nowrap; }
.scheduled-apps-table td.app-actions .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: .3rem .65rem; font-size: .78rem;
}
.scheduled-apps-table td.app-actions .btn + .btn { margin-left: .35rem; }
.scheduled-apps-table td.date-null { color: var(--muted); font-family: var(--font-mono); font-size: .74rem; }

/* A row that belongs to a repeat set: the badge is the fact, the shape is read
   back from the series' own dates. Both stay inside the title cell so the
   table keeps four columns. */
.scheduled-apps-table td.record-title .series-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .25rem;
}
.scheduled-apps-table .series-badge {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--primary);
  background: var(--primary-tint, #ecfdf5); border-radius: 4px;
  padding: .1rem .35rem;
}
.scheduled-apps-table .series-shape { color: var(--muted); font-size: .74rem; }

