:root {
  /* This app only has a light theme -- without this, a phone/browser set
     to dark mode leaves color-scheme at its default "light dark", and
     Google's PlaceAutocompleteElement widget (the haul address field)
     picks up on that and renders itself with a black background instead
     of matching the rest of the (always-light) form. */
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e4e9;
  --text: #1c1f26;
  --muted: #6b7280;
  --brand: #1f6f50;
  --brand-dark: #16553c;
  --accent: #2563eb;
  --danger: #b91c1c;
  --warn: #b45309;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--brand);
  color: white;
  padding: 10px 20px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.navlink {
  color: rgba(255,255,255,0.85);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.navlink:hover { background: rgba(255,255,255,0.12); text-decoration: none; color: white; }
.navlink.active { background: rgba(255,255,255,0.22); color: white; font-weight: 600; }

/* Grouped nav dropdowns -- plain <details>/<summary> so the menu works with
   no JS: click to open, click elsewhere (or another summary) to close. */
.navgroup { position: relative; }
.navgroup > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.navgroup > summary::-webkit-details-marker { display: none; }
.navgroup > summary::after { content: '▾'; font-size: 0.7em; opacity: 0.8; }
.navgroup[open] > summary { background: rgba(255,255,255,0.12); }
.navdropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.navdropdown a {
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.92rem;
}
.navdropdown a:hover { background: #f0f2f5; text-decoration: none; }
.navdropdown a.active { background: #eaf3ee; color: var(--brand-dark); font-weight: 600; }

/* Same <details>/<summary> pattern as the nav dropdowns above, but for a
   row of actions (e.g. Edit/Delete on a table row) sitting on a light
   background instead of the dark topbar -- own styling, same behavior. */
.actions-menu { position: relative; display: inline-block; }
.actions-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.actions-menu > summary::-webkit-details-marker { display: none; }
.actions-menu > summary::after { content: '▾'; font-size: 0.7em; opacity: 0.7; }
.actions-dropdown {
  /* Fixed, not absolute -- these open inside scrollable cards (see .card's
     overflow-x:auto, which per the CSS overflow spec forces overflow-y to
     auto too), and an absolutely-positioned menu would get clipped by that.
     Position is computed and kept in sync by app.js on open/scroll. */
  position: fixed;
  z-index: 30;
  min-width: 130px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.actions-dropdown a,
.actions-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}
.actions-dropdown a:hover,
.actions-dropdown button:hover { background: #f0f2f5; text-decoration: none; }
.actions-dropdown button.danger-item { color: var(--danger); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.userbox small { opacity: 0.75; }

.container { max-width: 1150px; margin: 0 auto; padding: 22px 20px 60px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.92rem; }
.flash.success { background: #e6f4ea; color: #1e6b3c; border: 1px solid #b7e0c4; }
.flash.error { background: #fdecec; color: var(--danger); border: 1px solid #f3bcbc; }

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  overflow-x: auto;
}

dialog.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  max-width: 420px;
  width: 90%;
}
dialog.modal::backdrop { background: rgba(17, 20, 26, 0.45); }
dialog.modal h3 { margin: 0 0 4px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 800px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
}

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:hover td { background: #fafbfc; }

/* The Dispatch Board packs a lot of columns (several with their own
   select/input) into one row -- shrink everything in it so the whole table
   fits at page width instead of needing horizontal scroll. */
.dispatch-table { font-size: 0.78rem; }
.dispatch-table th, .dispatch-table td { padding: 6px 7px; }
.dispatch-table th { font-size: 0.68rem; }
.dispatch-table select, .dispatch-table input { font-size: 0.78rem; padding: 3px 5px; }
.dispatch-table .btn.small { padding: 3px 7px; font-size: 0.72rem; }
.dispatch-table .badge, .dispatch-table .type-badge { font-size: 0.66rem; padding: 2px 6px; }
.dispatch-table .helptext { font-size: 0.7rem; }

/* Below the phone breakpoint, the table (however shrunk) still needs
   horizontal scrolling to be usable -- swap it for the same card layout
   the driver app uses instead. Cards are hidden on desktop, where the
   table already fits. */
.dispatch-cards { display: none; flex-direction: column; gap: 14px; margin-bottom: 18px; }
@media (max-width: 800px) {
  .dispatch-table-wrap { display: none; }
  .dispatch-cards { display: flex; }

  /* The Dispatch Board's toolbar (day-nav, billed filter, half a dozen
     "+ Add X" links) is a wide row meant for a mouse -- on a phone it was
     wrapping into a ragged mix of button widths. Stacking everything to
     full width (the .toolbar .right > * rule) turns that into one clean,
     evenly-sized column; the day-nav's own three buttons get an even
     three-way split instead of stacking inside their own row. Scoped to
     .dispatch-page so this doesn't touch .toolbar on any other page. */
  .dispatch-page .toolbar .right > * { width: 100%; }
  .dispatch-page .day-nav .btn { flex: 1; text-align: center; }
  /* Same fix for the two multi-column .field-row forms on this page (the
     date-range picker, and Re-order a driver's stops) -- side-by-side
     inputs/selects were squeezing to fit; stacked, each gets full width
     and its own tap target. */
  .dispatch-page .field-row { flex-direction: column; }
  .dispatch-page .field-row .btn { width: 100%; text-align: center; }
}

.btn {
  display: inline-block;
  background: var(--brand);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f2f3f5; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 0.8rem; }
.linklike { background: none; border: none; color: rgba(255,255,255,0.85); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { text-decoration: underline; }

form.inline { display: inline; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: white;
}
textarea { min-height: 70px; resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-row > div { flex: 1; }

/* A row of same-size buttons sitting side by side (e.g. Mark complete +
   Undo Haul) -- everything in it shares the row equally instead of sizing
   to its own label. */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; text-align: center; }

/* A label + compact input/select on one line (e.g. "Dumped: [Yes/No]"),
   instead of the full-width stacked label-then-input that plain <label>
   produces. */
.inline-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-field label { margin: 0; font-weight: 600; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.inline-field select, .inline-field input { width: auto; flex: 1; min-width: 130px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.requested { background: #fef3c7; color: #92400e; }
.badge.scheduled { background: #dbeafe; color: #1e40af; }
.badge.in_progress { background: #ede9fe; color: #5b21b6; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.canceled { background: #f3f4f6; color: #6b7280; }
.badge.yard { background: #f3f4f6; color: #374151; }
.badge.at_site { background: #dbeafe; color: #1e40af; }
.badge.in_transit { background: #fef3c7; color: #92400e; }
.badge.needs_repair { background: #fdecec; color: var(--danger); }
.badge.sold { background: #f3f4f6; color: #6b7280; }
.badge.new { background: #fef3c7; color: #92400e; }
.badge.converted { background: #dcfce7; color: #166534; }
.badge.rejected { background: #f3f4f6; color: #6b7280; }
.badge.draft { background: #f3f4f6; color: #374151; }
.badge.sent { background: #dbeafe; color: #1e40af; }
.badge.paid { background: #dcfce7; color: #166534; }

/* Job type badges -- distinct hues from status badges so the two scan separately */
.type-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.type-badge.delivery { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.type-badge.swap { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.type-badge.final_pickup { background: #fce7f3; color: #9d174d; border-color: #fbcfe8; }
.type-badge.relocate { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }

/* Whole dispatch-board row tinted by job type -- light enough that badges/text stay readable */
tr.job-row.delivery { background: #eef1ff; }
tr.job-row.swap { background: #ecfdf8; }
tr.job-row.final_pickup { background: #fdf1f7; }
tr.job-row.relocate { background: #fff8f0; }
tr.job-row.delivery:hover td { background: #e2e7ff; }
tr.job-row.swap:hover td { background: #dcfbf3; }
tr.job-row.final_pickup:hover td { background: #fbe4ee; }
tr.job-row.relocate:hover td { background: #ffefdc; }

/* Same tints, applied to a card (Driver Dashboard) instead of a table row */
.card.job-row.delivery { background: #eef1ff; }
.card.job-row.swap { background: #ecfdf8; }
.card.job-row.final_pickup { background: #fdf1f7; }
.card.job-row.relocate { background: #fff8f0; }

/* Dumpster inventory row tinted by status -- same idea as the dispatch board rows above */
tr.dumpster-row.yard { background: #f6f7f8; }
tr.dumpster-row.at_site { background: #eaf2fe; }
tr.dumpster-row.in_transit { background: #fef6e7; }
tr.dumpster-row.needs_repair { background: #fdecec; }
tr.dumpster-row.sold { background: #f0f0f1; }
tr.dumpster-row.yard:hover td { background: #ecedef; }
tr.dumpster-row.at_site:hover td { background: #dbe9fd; }
tr.dumpster-row.in_transit:hover td { background: #fdedcd; }
tr.dumpster-row.needs_repair:hover td { background: #fbdcdc; }
tr.dumpster-row.sold:hover td { background: #e4e4e6; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.stat { text-align: left; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.82rem; }
.stat .num.negative { color: var(--danger); }
.stat .num.positive { color: #166534; }

.empty { color: var(--muted); font-style: italic; padding: 20px 0; }

/* --- Driver mobile view --- */
.driver-page { max-width: 480px; margin: 0 auto; padding: 16px; }
/* The shared .toolbar spaces its buttons apart (see base rule above), which
   looks sparse at phone width -- same-width buttons filling the row reads
   more like a native app's button bar. */
.driver-page .toolbar .btn { flex: 1; text-align: center; }
.driver-header { background: var(--brand); color: white; padding: 16px; border-radius: var(--radius); margin-bottom: 16px; }
.driver-header h1 { margin: 0; font-size: 1.3rem; }
.stop-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.stop-card.delivery { background: #eef1ff; }
.stop-card.swap { background: #ecfdf8; }
.stop-card.final_pickup { background: #fdf1f7; }
.stop-card.relocate { background: #fff8f0; }
/* Completed stops fade to gray (overriding the type tints above via source
   order) so active/upcoming stops stand out; a completed swap/pickup that
   hasn't been dumped yet gets a lighter shade than a fully wrapped-up
   stop, as a visual reminder there's still a step left. */
.stop-card.not-dumped-yet { background: #e9eaec; }
.stop-card.done-gray { background: #d3d5d9; }
/* Top row of a stop card: stop number, type badge, status badge -- all on
   one flex baseline so a circular badge next to two pill badges lines up
   cleanly instead of relying on inline-element default alignment. */
.stop-card .stop-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stop-card .stop-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.stop-card .addr { font-weight: 600; margin: 10px 0 2px; }
.stop-card .meta { color: var(--muted); font-size: 0.88rem; margin-top: 3px; }
.stop-card .meta:first-of-type { margin-top: 0; }
/* Sections below the meta block (dumpster picker, change-type, actions) all
   get the same top gap, so the card reads as one consistent rhythm instead
   of each block picking its own margin. */
.stop-card > .inline-field,
.stop-card > .actions-menu,
.stop-card > .btn-row,
.stop-card > form.stop-form {
  margin-top: 12px;
}
.stop-form label { margin-top: 10px; }
.stop-form label:first-child { margin-top: 0; }
/* The "Change type" trigger is a .btn elsewhere (Dispatch Board row
   actions) sized to its label -- full width here so it lines up with the
   rest of a stop card's buttons instead of sitting short on its own. */
.stop-card .actions-menu > summary { width: 100%; justify-content: center; }
.actions-dropdown.wide { min-width: 220px; }
.type-change-form label { margin-top: 8px; }
.type-change-form label:first-child { margin-top: 0; }
.type-change-form select { font-size: 0.85rem; padding: 6px 8px; }
.type-change-form .btn { margin-top: 10px; width: 100%; }

/* --- Public request form --- */
.public-page { max-width: 560px; margin: 40px auto; padding: 0 16px; }
.public-page .card { padding: 28px; }
.logo-row { text-align: center; margin-bottom: 18px; }
.logo-row h1 { margin: 0; }

.login-page { max-width: 380px; margin: 80px auto; padding: 0 16px; }

.helptext { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.helptext.danger { color: var(--danger); }

.day-nav { display: flex; align-items: center; gap: 10px; }
.day-nav .btn.secondary { padding: 7px 12px; }
