/* RouteManager: Southwest palette. Turquoise leads, obsidian grounds it, sunset orange accents. */
:root {
  --bg: #f6f1ea;
  --surface: #fff;
  --surface-2: #fbf8f3;
  --ink: #1a1614;
  --ink-2: #5f564f;
  --line: #e4dbcf;
  --line-2: #efe8de;
  --brand: #0b7f86;
  --brand-strong: #086369;
  --brand-soft: #dff3f2;
  --brand-ink: #fff;
  --accent: #e2622b;
  --accent-strong: #b8480f;
  --accent-soft: #fdeadd;
  --series: #0f9aa2;
  --side: #14110f;
  --side-2: #201b18;
  --side-ink: #cfc6bc;
  --good: #17663a;
  --good-bg: #e2f3e6;
  --warn: #8a5200;
  --warn-bg: #fdefd2;
  --bad: #a3261c;
  --bad-bg: #fce5e1;
  --info: #086369;
  --info-bg: #dff3f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(42, 30, 20, 0.05), 0 4px 14px rgba(42, 30, 20, 0.05);
  --shadow-lift: 0 2px 4px rgba(42, 30, 20, 0.06), 0 10px 24px rgba(42, 30, 20, 0.09);
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font:
    15px/1.55 'Segoe UI Variable Text',
    'Segoe UI',
    system-ui,
    -apple-system,
    Roboto,
    'Helvetica Neue',
    sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--brand-strong);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover {
  color: var(--accent-strong);
}
h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}
h2 {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  margin: 0 0 0.5rem;
}
p {
  margin: 0 0 0.75rem;
}
code {
  background: var(--line-2);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  font-size: 0.92em;
}
.secret {
  display: inline-block;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  word-break: break-all;
}
.muted,
.sub {
  color: var(--ink-2);
}
.sub {
  margin: 0.3rem 0 0;
}
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 8px;
  top: 8px;
  background: #fff;
  padding: 0.5rem;
  z-index: 10;
  border-radius: var(--radius-sm);
}

/* Shell */
body.app {
  display: flex;
  min-height: 100vh;
}
.side {
  width: 228px;
  flex: none;
  background: var(--side);
  color: var(--side-ink);
  padding: 1.1rem 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 3px solid var(--accent);
}
.side .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 750;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  padding: 0.2rem 0.55rem 1.2rem;
}
/* Brand mark: a turquoise stone set in sunset orange. */
.side .brand::before,
.portal-top .brand::before,
.login h1::before {
  content: '';
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  background: var(--series);
  border: 3px solid var(--accent);
  border-radius: 4px;
  transform: rotate(45deg);
}
.side nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side nav a {
  display: block;
  color: var(--side-ink);
  text-decoration: none;
  padding: 0.48rem 0.7rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  font-weight: 500;
  transition:
    background 0.12s,
    color 0.12s;
}
.side nav a:hover {
  background: var(--side-2);
  color: #fff;
}
.side nav a.on {
  background: rgba(15, 154, 162, 0.2);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 650;
}
.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.top .search {
  flex: 1;
  max-width: 460px;
}
.top .search input {
  width: 100%;
  border-radius: 999px;
  padding-left: 1rem;
  background: var(--surface-2);
}
.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}
.who small {
  color: var(--accent-strong);
  text-transform: capitalize;
  font-weight: 600;
  margin-left: 0.2rem;
}
.who a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
.menu-btn {
  display: none;
}
main {
  padding: 1.6rem 1.5rem 3rem;
  max-width: 1400px;
  width: 100%;
}
body.bare {
  background:
    radial-gradient(1100px 520px at 50% -8%, #cfeeed 0%, rgba(207, 238, 237, 0) 62%),
    linear-gradient(180deg, var(--bg) 0%, #f3e4d4 100%) fixed;
  min-height: 100vh;
}
body.bare main {
  margin: 0 auto;
  max-width: 980px;
}
.portal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.5rem;
  background: var(--side);
  border-bottom: 3px solid var(--accent);
}
.portal-top .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 750;
  font-size: 1.1rem;
  text-decoration: none;
}
.portal-top .btn-quiet {
  color: #fff;
}
.portal-top .btn-quiet:hover {
  background: var(--side-2);
}

/* Building blocks */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
a.card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.12s,
    box-shadow 0.12s,
    border-color 0.12s;
}
a.card:hover {
  border-color: var(--series);
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.65rem;
}
.narrow {
  max-width: 440px;
  margin: 8vh auto;
}
.login {
  padding: 2rem 1.9rem;
  border-top: 4px solid var(--series);
  box-shadow: var(--shadow-lift);
}
.login h1 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.login .btn-primary {
  padding: 0.6rem 0.9rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.grid-2 > .card {
  margin-bottom: 0;
}
/* Routes page: the stops table needs more room than the map (its reorder buttons sit at the end),
   and below laptop width the map moves under the table rather than squeezing it. */
.grid-routes {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}
@media (max-width: 1180px) {
  .grid-routes {
    grid-template-columns: minmax(0, 1fr);
  }
}
.report-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.report-list .card {
  margin: 0;
}
.empty {
  color: var(--ink-2);
  padding: 0.5rem 0;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.48rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(42, 30, 20, 0.04);
  transition:
    background 0.12s,
    border-color 0.12s,
    box-shadow 0.12s,
    transform 0.06s;
}
.btn:hover {
  border-color: var(--series);
  color: var(--brand-strong);
  background: #fff;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 1px 2px rgba(8, 99, 105, 0.35);
}
.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}
.btn-danger {
  color: var(--bad);
  border-color: #ebc0ba;
}
.btn-danger:hover {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.btn-quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.btn-quiet:hover {
  background: var(--line-2);
  border-color: transparent;
  color: var(--ink);
}
.btn-sm {
  padding: 0.22rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 6px;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid #d3c8ba;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  max-width: 100%;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--series);
  box-shadow: 0 0 0 3px rgba(15, 154, 162, 0.2);
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--brand);
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  box-shadow: none;
}
::placeholder {
  color: #9a8f84;
}
textarea {
  width: 100%;
  resize: vertical;
}
.input-sm {
  width: 7.5rem;
}
form.inline {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.95rem 1rem;
  align-items: start;
}
.form-grid .span,
.form-grid .field-wide {
  grid-column: 1 / -1;
}
.form-grid h2.span {
  margin: 0.5rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-2);
}
.form-grid h2.span:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
/* The address check under an address (public/app.js fills it in). Empty, it takes no room. */
.address-check:empty {
  display: none;
}
.address-check {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.address-check-good {
  background: var(--good-bg);
  color: var(--good);
}
.address-check-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.address-check-bad {
  background: var(--bad-bg);
  color: var(--bad);
}
.address-check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.field > span {
  font-weight: 600;
  font-size: 0.88rem;
}
.field em {
  color: var(--accent-strong);
  font-style: normal;
}
.field small {
  color: var(--ink-2);
}
.field input,
.field select {
  width: 100%;
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--bad);
}
.err {
  color: var(--bad) !important;
}
.check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding-top: 1.4rem;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.5rem;
}
.row > input:not(.input-sm) {
  flex: 1;
  min-width: 150px;
}
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.filters input[type='search'] {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}
.filters label {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--ink-2);
}
details.add {
  margin-top: 0.75rem;
}
details.add summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-weight: 650;
  margin-bottom: 0.75rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid;
  border-left-width: 4px;
}
.alert ul {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
}
.alert-success {
  background: var(--good-bg);
  border-color: #b6dcc2;
  border-left-color: var(--good);
  color: var(--good);
}
.alert-error {
  background: var(--bad-bg);
  border-color: #efc2bc;
  border-left-color: var(--bad);
  color: var(--bad);
}
.alert-warn {
  background: var(--warn-bg);
  border-color: #edd49b;
  border-left-color: var(--accent);
  color: var(--warn);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--line-2);
  color: var(--ink-2);
}
.badge-good {
  background: var(--good-bg);
  color: var(--good);
}
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge-bad {
  background: var(--bad-bg);
  color: var(--bad);
}
.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.35rem;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  border-bottom: 2px solid var(--line);
}
tbody tr {
  transition: background 0.1s;
}
tbody tr:hover {
  background: var(--surface-2);
}
tbody tr:last-child td {
  border-bottom: 0;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-actions {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
/* Phone numbers never break across lines. */
a[href^='tel:'] {
  white-space: nowrap;
}
.pager {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.dl {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: 0.45rem 1rem;
  margin: 0;
}
.dl dt {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.totals {
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 0.25rem 2rem;
  max-width: 320px;
  margin: 1rem 0 0 auto;
}
.totals dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.timeline {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
.timeline li {
  padding: 0.55rem 0 0.55rem 0.85rem;
  border-left: 2px solid var(--brand-soft);
  margin-left: 0.2rem;
  overflow-wrap: anywhere;
}
.timeline li + li {
  margin-top: 0.15rem;
}
.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}
.tabs a {
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  color: var(--ink-2);
  border-bottom: 3px solid transparent;
  font-weight: 500;
  margin-bottom: -1px;
}
.tabs a:hover {
  color: var(--brand-strong);
}
.tabs a.on {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 650;
}

/* Stat tiles and charts */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--series);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.stat:nth-child(3n + 2) {
  border-top-color: var(--accent);
}
.stat:nth-child(3n + 3) {
  border-top-color: var(--side);
}
a.stat:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
  color: var(--ink);
}
.stat-label {
  color: var(--ink-2);
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  color: var(--ink-2);
  font-size: 0.85rem;
}
.bars {
  margin: 0 0 1rem;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 170px) 1fr max-content;
  gap: 0.75rem;
  align-items: center;
  padding: 0.25rem 0;
}
.bar-row:hover .bar-fill {
  fill: var(--brand-strong);
}
.bar-label {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Bars are drawn as SVG (width is an attribute, not an inline style, so the strict CSP holds). */
.bar-track {
  display: block;
  width: 100%;
  height: 14px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  fill: var(--series);
}
.bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Schedule board */
.daynav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.85rem;
}
.weekstrip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.weekstrip a {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  transition:
    border-color 0.12s,
    background 0.12s;
}
.weekstrip a:hover {
  border-color: var(--series);
}
.weekstrip a.on {
  background: var(--side);
  border-color: var(--side);
  color: #fff;
  box-shadow: inset 0 -3px 0 var(--accent);
}
.weekstrip span {
  font-size: 0.78rem;
  color: var(--ink-2);
}
.weekstrip a.on span {
  color: var(--side-ink);
}
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.lane {
  background: #ece4d8;
  border-radius: var(--radius);
  padding: 0.7rem;
  min-height: 160px;
}
.lane.over {
  outline: 2px dashed var(--accent);
  background: var(--accent-soft);
}
.lane h2 {
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lane h2 small {
  color: var(--ink-2);
  font-weight: 650;
  background: var(--surface);
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.78rem;
}
.appt {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--series);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.appt[draggable='true'] {
  cursor: grab;
}
.appt[draggable='true']:hover {
  box-shadow: var(--shadow-lift);
}
.appt.dragging {
  opacity: 0.5;
}
.appt a {
  text-decoration: none;
  color: var(--ink);
}
.appt-completed {
  border-left-color: var(--good);
}
.appt-cancelled,
.appt-no_show {
  border-left-color: #c4b8aa;
  opacity: 0.75;
}
.pipeline .appt {
  border-left-color: var(--accent);
}

/* Maps */
.route-map {
  width: 100%;
  height: auto;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}
.route-map-wrap.live > svg {
  display: none;
}
.route-map-live {
  height: 440px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  z-index: 0;
}
.route-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.route-pin-office {
  border-radius: 5px;
  background: var(--side);
  border-color: var(--accent);
}
.route-popup strong {
  display: block;
}
.streetview {
  display: block;
  width: 100%;
  height: 380px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.loc-links {
  white-space: nowrap;
  font-size: 0.88em;
}
.loc-links a {
  font-weight: 600;
}
.loc-links a + a {
  margin-left: 0.6rem;
}
.nowrap {
  white-space: nowrap;
}

/* Technician view */
.stops {
  max-width: 680px;
}
.stop {
  display: flex;
  gap: 0.9rem;
}
.stop-num {
  flex: none;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.stop-body {
  flex: 1;
  min-width: 0;
}
.stop-body p {
  margin-bottom: 0.4rem;
}
.note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
}
.product-row select {
  flex: 1;
  min-width: 160px;
}

/* Agreements, photos, canvassing */
.agreement-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 1rem 0;
  line-height: 1.6;
}
.signature-block {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.signature-block img {
  border-bottom: 2px solid var(--ink);
  background: #fff;
}
.signature-pad {
  width: 100%;
  max-width: 500px;
  height: auto;
  aspect-ratio: 500 / 160;
  border: 1px dashed #c4b8aa;
  border-radius: var(--radius-sm);
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.gallery figure {
  margin: 0;
}
.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: block;
}
.gallery figcaption {
  font-size: 0.8rem;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  margin-top: 0.25rem;
}
.uploader {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.legend {
  list-style: none;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0;
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
}
.legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: -1px;
}
/* Canvassing outcome colours (must match COLORS in src/routes/canvass.js). */
.swatch-lead {
  background: #0b7f86;
}
.swatch-not_interested {
  background: #e2622b;
}
.swatch-callback {
  background: #7a4fb5;
}
.swatch-not_home {
  background: #8a8179;
}
.codes {
  columns: 2;
  max-width: 320px;
  padding-left: 1.2rem;
}
.branch-switch select {
  padding: 0.32rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
}
.invoice-doc {
  border-top: 4px solid var(--series);
}

@media (max-width: 820px) {
  body.app {
    display: block;
  }
  .side {
    display: none;
    width: auto;
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 3px solid var(--accent);
  }
  .side.open {
    display: block;
  }
  .menu-btn {
    display: inline-flex;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    font-weight: 600;
  }
  .top {
    padding: 0.6rem 0.9rem;
  }
  .who span {
    display: none;
  }
  main {
    padding: 1rem 0.9rem 2.5rem;
  }
  h1 {
    font-size: 1.4rem;
  }
  .weekstrip span {
    font-size: 0.7rem;
  }
  /* The top bar: menu, branch and sign-out on the first line, search full width underneath. */
  .top {
    flex-wrap: wrap;
    gap: 0.6rem;
  }
  .top .search {
    order: 10;
    flex: 1 1 100%;
    max-width: none;
  }
}

/* Phones: tables become a stack of cards, one per row, each value under its column name, so
   nothing hides off the right-hand edge. (The column names come from data-label, set by table()
   in src/views/ui.js.) */
@media (max-width: 640px) {
  .table-wrap {
    overflow-x: visible;
    margin: 0;
  }
  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }
  .table-wrap tr {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
  }
  .table-wrap tr:last-child {
    border-bottom: 0;
  }
  .table-wrap td {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: baseline;
    border: 0;
    padding: 0.2rem 0;
    text-align: right;
  }
  .table-wrap td.num {
    text-align: right;
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-2);
  }
  /* A cell with no column name (row buttons) sits on its own line. */
  .table-wrap td:not([data-label]) {
    justify-content: flex-start;
    text-align: left;
  }
  .table-wrap td:empty {
    display: none;
  }
}
/* Touch screens cannot drag cards, so the drag tip is only shown where a mouse is in use. */
@media (hover: none) {
  .drag-hint {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
@media print {
  .side,
  .top,
  .portal-top,
  .actions,
  .alert,
  .filters {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card {
    border: 0;
    padding: 0;
    box-shadow: none;
  }
  main {
    padding: 0;
  }
}
