:root {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-wrap: anywhere;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #203439;
  background: #eef4f3;
  --accent: #145a61;
  --muted: #435d65;
  --line: #bdcfd2;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.top {
  min-height: 65px;
  padding: .8rem max(1.1rem, calc((100% - 860px) / 2));
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  background: #1e3b41;
  color: white;
}
.top > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
  gap: .45rem .7rem;
}
.brand { font-size: 1.38rem; white-space: nowrap; letter-spacing: -.025em; }
.brand span { color: #70dcce; }
.brand span:first-child { color: #8ed966; }
.test-label { font-size: .9rem; color: #e6f4f3; font-weight: 650; }
main {
  width: min(calc(100% - 2rem), 860px);
  margin: 0 auto;
  padding: 1.55rem env(safe-area-inset-right, 0px) 1.85rem env(safe-area-inset-left, 0px);
}
.page-title { margin-bottom: 1.15rem; }
h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.45rem); letter-spacing: -.033em; line-height: 1.16; }
h1 sup { font-size: .48em; color: var(--accent); margin-right: .25em; }
h2 { margin: 0; font-size: 1.16rem; }
h3 { font-size: 1rem; margin: .85rem 0 .25rem; }
p { margin: .35rem 0; }
.page-title p, .muted, .caption, .optional { color: var(--muted); }
.caption { display: block; font-size: .82rem; margin-bottom: .28rem; font-weight: 650; }
.optional { font-size: .79rem; font-weight: 500; margin-left: .25rem; }
.record {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: .8rem 1.25rem;
  border: 1px solid #a9c8c8;
  border-left: .3rem solid #257d81;
  background: #e5f1ef;
  padding: .95rem 1.1rem;
  border-radius: .75rem;
  margin-bottom: 1.1rem;
}
.record p { color: var(--muted); font-size: .93rem; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.card {
  padding: 1rem 1.1rem;
  margin-bottom: .82rem;
  background: white;
  border: 1px solid #ccdadd;
  border-radius: .75rem;
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .65rem; flex-wrap: wrap; }
.visit { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; margin: .81rem 0 .65rem; }
label { display: grid; gap: .27rem; font-size: .88rem; font-weight: 660; color: var(--muted); min-width: 0; }
input, textarea, button, select {
  font: inherit;
  max-width: 100%;
}
select { text-overflow: ellipsis; }
button { white-space: normal; }
.record > div, .section-head > *, .action-buttons, .quote77-row > *, dl > div {
  min-width: 0;
  max-width: 100%;
}
input:not([type=file]), textarea, select {
  width: 100%; min-width: 0; color: #203439;
  min-height: 44px; padding: .59rem .65rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: .43rem; background: white;
}
input[type="date"], input[type="time"] { display: block; min-inline-size: 0; }
input::-webkit-date-and-time-value { margin: 0; text-align: start; }
textarea { resize: vertical; }
button, .secondary.photo-picker {
  min-height: 44px; padding: .54rem .83rem; border-radius: .48rem;
  font-size: .94rem; font-weight: 670; cursor: pointer;
}
.primary { background: var(--accent); border: 1px solid var(--accent); color: white; }
.secondary { background: white; border: 1px solid var(--line); color: var(--accent); }
button:disabled { opacity: .58; cursor: default; }
:focus-visible { outline: 3px solid #2c8a93; outline-offset: 3px; }
.part { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2.8fr) minmax(0, .7fr) auto; gap: .5rem; align-items: end; padding-top: .55rem; }
.part input { padding-inline: .5rem; }
.photo-picker { display: inline-flex; align-items: center; position: relative; }
.photo-picker input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.photo-picker:focus-within { outline: 3px solid #2c8a93; outline-offset: 3px; }
.photo-preview { display: flex; align-items: flex-start; flex-wrap: wrap; min-width: 0; gap: .75rem; margin-top: .67rem; }
.photo-preview img { width: min(55%, 190px); border-radius: .43rem; }
canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: .45rem; background: #f7faf9; }
#signature { margin-top: .45rem; touch-action: none; cursor: crosshair; }
.actions {
  position: sticky; bottom: 0; padding: .75rem .85rem max(.78rem, env(safe-area-inset-bottom));
  background: #ebf4f2; border: 1px solid #b9d1cf; border-radius: .72rem;
  display: flex; align-items: center; justify-content: space-between; gap: .65rem; flex-wrap: wrap;
  box-shadow: 0 -3px 14px #1e3b410c;
}
#feedback { flex: 1 1 13rem; min-width: 0; font-size: .95rem; font-weight: 640; }
#feedback[data-kind="success"] { color: #176444; }
#feedback[data-kind="warning"] { color: #744507; }
#feedback[data-kind="error"] { color: #922f33; }
.action-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge { padding: .34rem .6rem; border-radius: .35rem; background: #e0f0e9; color: #146043; font-weight: 650; }
dl { display: flex; flex-wrap: wrap; gap: .5rem 1.15rem; margin: .8rem 0; }
dt { color: var(--muted); font-size: .82rem; font-weight: 650; }
dd { margin: .25rem 0 0; min-width: 0; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; }
.evidence { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .85rem; }
.evidence img { display: block; max-width: 100%; max-height: 260px; border-radius: .42rem; }
#status:empty { display: none; }
#status { margin: 0 0 .75rem; color: var(--muted); font-weight: 640; }
#pairing { display: grid; gap: .75rem; max-width: 30rem; margin-top: .75rem; }
#pairing button { justify-self: start; }
#order-card { overflow-wrap: anywhere; }
#receipt-status { color:#1e6650; font-weight:700; }
.email-choice { display:flex; flex-direction:row; align-items:center; gap:.55rem; }
.email-choice input { width:auto; min-width:1.15rem; min-height:1.15rem; }
#quote77 form { display:flex;flex-wrap:wrap;gap:.7rem;align-items:end;margin:.85rem 0; }
#quote77 form[hidden] { display:none; }
#quote77-search > label { flex: 1 1 10rem; }
#quote77-totals > div { width:100%; min-width:0; }
#quote77-results,.quote77-row { display:flex;flex-wrap:wrap;gap:.45rem;align-items:end; }
.quote77-row { margin:.6rem 0;padding:.6rem;background:#edf5f4;border-radius:.5rem; }
.quote77-row strong { margin-right:auto; }
.quote77-row label { max-width:9rem; }
#correction { grid-column: 1 / -1; color: #744507; }
#install summary { cursor: pointer; font-weight: 650; color: var(--accent); }
#photos { display: flex; flex-wrap: wrap; gap: .5rem; }
#photos .photo-preview { flex-direction: column; max-width: 180px; }
#photos .photo-preview img { width: 100%; }
.evidence [data-signature] { width: 100%; border: 1px solid var(--line); background: #f7faf9; }
.work-clock {
  margin: .8rem 0;
  padding: .7rem .8rem;
  background: #e5f1ef;
  border: 1px solid #b9d1cf;
  border-radius: .55rem;
}
.work-clock p { color: var(--muted); }
.work-buttons { display: flex; flex-wrap: wrap; gap: .45rem; }
#work-distance { margin: .85rem 0; }
#work-distance h3 { margin: 0 0 .45rem; font-size: 1.05rem; }
#work-distance input { max-width: 17rem; }
#distance-unavailable { color: var(--muted); }
.client-contact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: .6rem;
  margin: .7rem 0 1rem;
}
.signature-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .45rem; }
.signature-state { color: #176444; font-weight: 640; }
#signature.signature-locked, canvas.signature-locked { cursor: default; touch-action: auto; }
#add-trainee { margin-top: .8rem; }
#send-blocker { flex: 1 1 100%; margin: 0; color: #922f33; font-weight: 640; }
.training-person { margin-top: .75rem; }
.training-person + .training-person { padding-top: .75rem; border-top: 1px solid var(--line); }
.training-person canvas, .private76-signature-pad {
  display:block; width:100%; height:auto; border:1px solid var(--line); border-radius:.45rem;
  background:#fff; touch-action:none;
}
#store-proof-preview img, .store-proof-picture {
  display:block; width:min(100%, 42rem); height:auto; object-fit:contain; border:1px solid var(--line);
}
#store-proof-preview { margin-top:.65rem; }
#service-rates label, #travel-rate { grid-template-columns: minmax(0, 1fr); align-content: start; }
#service-rates select, #travel-rate select { overflow: hidden; min-height: 44px; }
#service-rates small, #travel-rate small { color: #155c61; overflow-wrap: anywhere; }
#protocol-preview {
  width: min(670px, calc(100% - 1.5rem));
  max-height: 90dvh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .75rem;
  color: #203439;
}
#protocol-preview::backdrop { background: #12282ea0; }
.preview-head {
  position: sticky; top: 0; z-index: 1;
  background: #eef4f3; border-bottom: 1px solid var(--line);
  padding: .8rem 1rem; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: .5rem;
}
.preview-body { padding: .9rem 1rem 1.1rem; }
#preview-check { padding: .6rem .75rem; border-radius: .5rem; margin-bottom: .95rem; }
#preview-check[data-kind="warning"] { background: #fff2db; color: #704207; }
#preview-check[data-kind="success"] { background: #e0f0e9; color: #146043; }
#preview-check ul { margin: .35rem 0 0; padding-inline-start: 1.3rem; }
.preview-body img { display: block; max-width: 100%; }
.preview-signature { background: #f7faf9; border: 1px solid var(--line); border-radius: .45rem; }
.beda76-address { display: block; color: var(--accent); }
#orders-overview { margin-top: .8rem; }
#orders-overview summary { cursor: pointer; color: var(--accent); font-weight: 650; }
#order-list { list-style: none; margin: .55rem 0 0; padding: 0; }
#order-list li {
  border: 1px solid var(--line); border-radius: .55rem;
  padding: .6rem .7rem; margin-top: .5rem;
}
#order-list button { width: 100%; text-align: left; }
#order-list .caption { margin-top: .4rem; }
.dispatch-layout {
  display: grid;
  grid-template-areas: "stops toolbar" "stops map";
  grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr);
  gap: .45rem .75rem; align-items: start;
}
.dispatch-map-toolbar { grid-area: toolbar; display: flex; justify-content: flex-end; gap: .55rem; }
#dispatch-map { grid-area: map; }
.dispatch-layout #dispatch-stops {
  grid-area: stops;
  max-height: max(20rem, min(50vh, 32rem));
  overflow: auto; align-content: start; padding: 3px;
}
#dispatch-stops .route-stop {
  min-width: 0; border: 1px solid #d5e4e6; border-radius: .55rem; background: #f0f6f6;
}
#dispatch-stops .selected-stop { border-color: #1c747a; background: #e3f2f1; }
.route-stop-summary {
  display: grid; grid-template-columns: minmax(0, 1fr) .55rem; align-items: center;
  min-height: 44px; padding: .38rem .63rem; gap: .12rem .52rem;
  cursor: pointer; list-style: none;
}
.route-stop-summary::-webkit-details-marker { display: none; }
.route-stop-summary::after {
  content: ""; grid-column: 2; grid-row: 1 / span 2;
  width: .44rem; height: .44rem; border: solid var(--accent); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.route-stop[open] .route-stop-summary::after { transform: rotate(225deg); }
.route-stop-summary > * { grid-column: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.route-stop[open] .route-stop-summary > * { white-space: normal; }
.route-stop-summary small { color: var(--muted); }
.route-stop-content { padding: .12rem .63rem .62rem; }
.beda76-pin.selected-stop { outline: 4px solid #f5bc47; outline-offset: 3px; }
body.route-expanded { overflow: hidden; }
#dispatch.route-expanded {
  position: fixed; inset: 0; z-index: 1000; overflow: hidden;
  margin: 0; padding: 0; border: 0; border-radius: 0;
}
#dispatch.route-expanded > summary { display: none; }
#dispatch.route-expanded .dispatch-content {
  position: absolute; inset: 0; display: flex; flex-direction: column;
}
#dispatch.route-expanded .dispatch-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .85rem;
  padding: max(.45rem, env(safe-area-inset-top)) max(.6rem, env(safe-area-inset-right)) 0 max(.6rem, env(safe-area-inset-left));
}
#dispatch.route-expanded .dispatch-meta label {
  display: flex; align-items: center; gap: .4rem; margin: 0; max-width: none;
}
#dispatch.route-expanded #map-day { width: auto; }
#dispatch.route-expanded .map-legend { margin: 0; }
#map-status:empty { display: none; }
#dispatch.route-expanded .dispatch-layout {
  grid-template-areas: "toolbar" "map";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0; flex: 1; min-height: 0;
}
#dispatch.route-expanded .dispatch-map-toolbar {
  justify-content: space-between;
  padding: .45rem max(.6rem, env(safe-area-inset-right)) .45rem max(.6rem, env(safe-area-inset-left));
}
#toggle-route-stops { width: 44px; height: 44px; padding: 0; font-size: 1.2rem; }
#toggle-route-stops[aria-expanded="true"] { background: var(--accent); color: white; }
#dispatch.route-expanded #dispatch-map {
  z-index: 0; align-self: stretch; width: 100%; height: auto; min-height: 0; border: 0; border-radius: 0;
}
#dispatch.route-expanded #dispatch-stops {
  grid-area: map; z-index: 1; align-self: stretch;
  width: min(23rem, 85%); min-height: 0; max-height: none;
  padding: .6rem; padding-left: max(.6rem, env(safe-area-inset-left));
  padding-bottom: max(.6rem, env(safe-area-inset-bottom));
  background: white; border-right: 1px solid var(--line); box-shadow: .2rem 0 1rem #19333a28;
  overscroll-behavior: contain;
}
#handoff-dialog { width:min(30rem, calc(100% - 2rem)); border:1px solid var(--line); border-radius:.8rem; }
#handoff-dialog::backdrop { background:#12282ea0; }
.beda76-pin .route-number {
  position: absolute; top: -9px; right: -9px; min-width: 20px; min-height: 20px;
  padding: 2px 4px; display: grid; place-items: center;
  color: #fff; background: #19333a; border: 2px solid #fff; border-radius: 12px;
  font: 700 11px/1 system-ui, sans-serif;
}
@media (max-width: 700px) {
  .dispatch-layout { grid-template-areas: "stops" "toolbar" "map"; grid-template-columns: minmax(0, 1fr); }
  .dispatch-layout #dispatch-stops { max-height: 15rem; }
}
@media (max-width: 640px) {
  main { width: calc(100% - 1.4rem); padding-top: 1rem; }
  .record, .evidence { grid-template-columns: minmax(0, 1fr); }
  .visit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visit label:first-child { grid-column: 1 / -1; }
  .part { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid #e4eeee; padding-bottom: .55rem; }
  .part label:nth-child(2) { grid-row: 2; grid-column: 1 / -1; }
  .remove-part { justify-self: start; grid-row: 3; }
  .action-buttons { width: 100%; }
  .action-buttons button { flex: 1 1 8rem; min-width: 0; }
}

.part-search-results { display:grid; gap:.35rem; margin:.4rem 0; }
.part-search-results button { text-align:left; overflow-wrap:anywhere; }
