/* Mobile-first. Brand colours live in these variables only. */
:root {
  --brand: #15803d; --brand-dark: #14532d; --brand-soft: #dcfce7; --accent: #f59e0b;
  --bg: #f6f7f5; --card: #fff; --text: #1c1f1d; --muted: #66706a; --line: #e2e6e3;
  --ok: #15803d; --warn: #b45309; --danger: #b91c1c; --info: #1d4ed8;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 16px; }
a { color: var(--brand-dark); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.inline { display: inline; }
.hide-sm { display: none; }
.warn { color: var(--warn); font-weight: 600; }
.container { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.container.narrow { max-width: 680px; }

/* Brand partial */
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: -.01em; color: inherit; }
.brand-mark { width: 28px; height: 28px; }
.brand-mark-bg { fill: var(--brand); }
.brand-mark-fg { fill: #fff; }
.brand-lg .brand-mark { width: 36px; height: 36px; } .brand-lg .brand-name { font-size: 1.35rem; }
.brand-sm .brand-mark { width: 24px; height: 24px; }
.topbar-brand { text-decoration: none; color: inherit; }

/* Top bars */
.topbar, .pubbar, .crewbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--brand-dark); color: #fff; flex-wrap: wrap; }
.topbar .brand-mark-bg, .pubbar .brand-mark-bg, .crewbar .brand-mark-bg { fill: #fff; }
.topbar .brand-mark-fg, .pubbar .brand-mark-fg, .crewbar .brand-mark-fg { fill: var(--brand-dark); }
.pubbar { justify-content: space-between; background: #fff; color: var(--text); border-bottom: 1px solid var(--line); }
.pubbar .brand-mark-bg { fill: var(--brand); } .pubbar .brand-mark-fg { fill: #fff; }
.crewbar { position: sticky; top: 0; z-index: 10; }
.crewbar .lang { margin-left: auto; }
.topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.who { font-size: .9rem; display: none; } .who small { opacity: .75; }
.lang { display: inline-flex; border: 1px solid currentColor; border-radius: 999px; overflow: hidden; font-size: .8rem; }
.lang a { color: inherit; text-decoration: none; padding: .2rem .55rem; opacity: .75; }
.lang a.is-active { background: currentColor; opacity: 1; }
.topbar .lang a.is-active, .crewbar .lang a.is-active { color: var(--brand-dark); background: #fff; }
.pubbar .lang a.is-active { color: #fff; background: var(--brand-dark); }
.nav-toggle { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 8px; padding: .3rem .7rem; font: inherit; font-size: .9rem; }
.mainnav { display: none; flex-direction: column; background: #fff; border-bottom: 1px solid var(--line); }
.mainnav.is-open { display: flex; }
.mainnav a { padding: .7rem 1rem; text-decoration: none; color: var(--text); border-top: 1px solid var(--line); }
.mainnav a.is-active { color: var(--brand-dark); font-weight: 700; background: var(--brand-soft); }

/* Layout pieces */
.pagehead { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin: .25rem 0 1rem; }
.actions, .btnrow { display: flex; flex-wrap: wrap; gap: .5rem; }
.btnrow { margin: .75rem 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.flush { padding: 0; overflow-x: auto; }
.card .pad { padding: 1rem 1rem 0; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--brand); }
.cards { display: grid; gap: .75rem; }
.cards .card { margin: 0; }
.grid2, .grid3 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid2 > .card, .grid3 > .card { margin: 0; }
.grid2 + .grid2, .grid2 + .grid3 { margin-top: 1rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack > .card { margin: 0; }
.row2, .row3 { display: grid; gap: .75rem; grid-template-columns: 1fr; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bottom { display: flex; align-items: flex-end; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: .4rem 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.center.card { max-width: 520px; margin: 2rem auto; }

/* Forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; padding: .6rem .7rem; border: 1px solid #cdd3cf; border-radius: 9px; background: #fff; width: 100%; min-height: 44px; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
input[readonly] { background: #f3f4f3; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin: 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
label.check { flex-direction: row; align-items: center; gap: .55rem; font-weight: 400; padding: .3rem 0; }
label.check.big { font-size: 1.05rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.checkgrid { display: grid; grid-template-columns: 1fr; gap: .1rem .75rem; }
.err { color: var(--danger); font-weight: 500; font-size: .85rem; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.inline-form { display: flex; gap: .5rem; }
.datenav { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.datenav input { width: auto; }
.hint-box { display: flex; align-items: flex-end; padding-bottom: .6rem; font-weight: 600; color: var(--brand-dark); }
.loadpick { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { flex-direction: row; font-weight: 500; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-block; padding: .5rem .85rem; border: 1px solid #cdd3cf; border-radius: 999px; background: #fff; cursor: pointer; }
.pill input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill input:focus-visible + span { outline: 2px solid var(--brand-dark); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; padding: .55rem 1rem; min-height: 44px; border-radius: 10px; border: 1px solid #cdd3cf; background: #fff; color: var(--text); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #f0c5c5; }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.45); }
.btn-sm { min-height: 34px; padding: .3rem .65rem; font-size: .85rem; }
.btn-lg { min-height: 54px; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* Flash + badges */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash-ok { background: var(--brand-soft); color: var(--brand-dark); }
.flash-error { background: #fee2e2; color: var(--danger); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .15rem .5rem; border-radius: 999px; background: #eef0ee; color: #4b5550; white-space: nowrap; vertical-align: middle; }
.badge-new, .badge-scheduled, .badge-open, .badge-sent { background: #dbeafe; color: var(--info); }
.badge-en_route, .badge-on_site, .badge-quoted, .badge-out { background: #fef3c7; color: var(--warn); }
.badge-completed, .badge-paid, .badge-booked, .badge-accepted, .badge-approved, .badge-available { background: var(--brand-soft); color: var(--brand-dark); }
.badge-cancelled, .badge-lost, .badge-declined, .badge-void { background: #fee2e2; color: var(--danger); }

/* Tables + lists */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfa; }
.table.compact td { padding: .4rem .25rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; align-items: center; }
.list li:last-child .list-row, .list li.list-row:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .75rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.is-active { color: var(--brand-dark); border-color: var(--brand); font-weight: 700; }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; text-decoration: none; color: inherit; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile-v { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-l { font-size: .82rem; color: var(--muted); }
.tile-warn .tile-v { color: var(--warn); }

/* Lines editor + totals */
.lines-head { display: none; }
.line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.line input[name="line_desc[]"] { grid-column: 1 / -1; }
.line-total { align-self: center; font-weight: 600; }
.line-add { display: flex; gap: .5rem; margin-top: .6rem; }
.qty-sm { max-width: 80px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; margin: .5rem 0 0; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); text-align: right; } .totals dd { margin: 0; text-align: right; }
.totals .grand { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.price-in { max-width: 120px; margin-left: auto; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .5rem 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: #eee; }
.photos figure { margin: 0; } .photos figcaption { font-size: .75rem; color: var(--muted); }
.photo-cols { display: grid; gap: 1rem; }
.sig-img { max-width: 100%; height: 90px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* Dispatch board */
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; }
.board-col { flex: 0 0 86%; background: #eef1ee; border-radius: var(--radius); padding: .6rem; scroll-snap-align: start; }
.board-unassigned { background: #fdf6e7; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; padding: .2rem .25rem .6rem; }
.jobcard { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .6rem; display: flex; flex-direction: column; gap: .2rem; }
.jobcard.status-en_route, .jobcard.status-on_site { border-left-color: var(--accent); }
.jobcard.status-completed { border-left-color: var(--ok); opacity: .8; }
.jobcard-title { font-weight: 700; text-decoration: none; color: var(--text); }
.jobcard-actions { display: flex; gap: .35rem; margin-top: .35rem; align-items: center; flex-wrap: wrap; }
.jobcard-actions select { min-height: 34px; padding: .2rem .4rem; font-size: .85rem; width: auto; flex: 1; }
.assign-form { flex: 1; display: flex; }
.stopno { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-dark); color: #fff; font-weight: 700; font-size: .85rem; align-items: center; justify-content: center; flex: none; }

/* Week calendar */
.week { display: grid; gap: .6rem; grid-template-columns: 1fr; }
.day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; min-height: 60px; }
.day.is-today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.day header { font-weight: 700; margin-bottom: .4rem; text-transform: capitalize; }
.day header a { text-decoration: none; color: var(--text); }
.calitem { display: flex; flex-direction: column; text-decoration: none; color: var(--text); background: #f1f5ff; border-left: 3px solid var(--info); border-radius: 6px; padding: .35rem .5rem; margin-bottom: .35rem; font-size: .9rem; }
.calitem.status-completed { background: var(--brand-soft); border-left-color: var(--ok); }

/* Disposal stream bar */
.streambar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; margin: 0 0 1rem; font-size: .75rem; font-weight: 700; color: #fff; }
.seg { display: flex; align-items: center; padding: 0 .5rem; white-space: nowrap; overflow: hidden; }
.seg-landfill { background: #6b7280; } .seg-recycled { background: var(--info); } .seg-donated { background: var(--brand); }
.w-0{flex:0 0 0}.w-5{flex:0 0 5%}.w-10{flex:0 0 10%}.w-15{flex:0 0 15%}.w-20{flex:0 0 20%}.w-25{flex:0 0 25%}.w-30{flex:0 0 30%}.w-35{flex:0 0 35%}.w-40{flex:0 0 40%}.w-45{flex:0 0 45%}.w-50{flex:0 0 50%}.w-55{flex:0 0 55%}.w-60{flex:0 0 60%}.w-65{flex:0 0 65%}.w-70{flex:0 0 70%}.w-75{flex:0 0 75%}.w-80{flex:0 0 80%}.w-85{flex:0 0 85%}.w-90{flex:0 0 90%}.w-95{flex:0 0 95%}.w-100{flex:0 0 100%}

/* Crew mobile */
.crew-main { max-width: 640px; padding-bottom: 3rem; }
.crew-head { margin: .25rem 0 1rem; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; }
.stops { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.stop { display: flex; gap: .75rem; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--info); border-radius: var(--radius); padding: .8rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.stop.status-en_route, .stop.status-on_site { border-left-color: var(--accent); }
.stop.status-completed { border-left-color: var(--ok); opacity: .75; }
.stop-body { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.note { background: #fff7e6; border-radius: 8px; padding: .35rem .55rem; color: #7a4b00; display: block; }
.addr { font-size: 1.1rem; font-weight: 700; margin: 0 0 .4rem; }
.sigpad { border: 2px dashed #b8c1bb; border-radius: 10px; background: #fff; touch-action: none; }
.sigpad canvas { width: 100%; height: 180px; display: block; }

/* Public */
.hero { padding: 1rem 0 .5rem; }
.hero h1 { font-size: 1.7rem; }
.pubfoot { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
.auth { max-width: 420px; margin: 2rem auto; }
.errcode { font-size: 3rem; color: var(--muted); }
.sandbox { background: #fff7e6; border: 1px solid #f5d18b; color: #7a4b00; border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }
.cardfields { display: flex; flex-direction: column; gap: .5rem; }
.cf { border: 1px solid #cdd3cf; border-radius: 9px; padding: .45rem .7rem; font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; }
.cf span { font-size: 1rem; color: var(--text); letter-spacing: .05em; }

@media (min-width: 640px) {
  .row2 { grid-template-columns: 1fr 1fr; }
  .row3 { grid-template-columns: 2fr 1fr 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .checkgrid { grid-template-columns: 1fr 1fr; }
  .photos { grid-template-columns: repeat(4, 1fr); }
  .photos.sm { grid-template-columns: repeat(3, 1fr); }
  .photo-cols { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: table-cell; }
  .board-col { flex-basis: 300px; }
  .lines-head { display: grid; grid-template-columns: 1fr 80px 100px 100px; gap: .5rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .line { grid-template-columns: 1fr 80px 100px 100px; }
  .line input[name="line_desc[]"] { grid-column: auto; }
}
@media (min-width: 960px) {
  .container { padding: 1.5rem 2rem; }
  .nav-toggle { display: none; }
  .who { display: inline; }
  .mainnav { display: flex; flex-direction: row; flex-wrap: wrap; padding: 0 1.5rem; }
  .mainnav a { border-top: 0; padding: .7rem .8rem; border-bottom: 2px solid transparent; }
  .mainnav a.is-active { background: transparent; border-bottom-color: var(--brand); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2.wide-left { grid-template-columns: 1.6fr 1fr; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .week { grid-template-columns: repeat(7, 1fr); }
  .board-col { flex: 1 0 260px; }
  h1 { font-size: 1.65rem; }
}
