/* HaulerEdge — built for one-handed use in a truck cab, in daylight. */

:root {
  --navy: #0f1b2d;
  --ink: #111827;
  --muted: #5b6474;
  --line: #dde2ea;
  --bg: #f3f5f8;
  --card: #fff;
  --brand: #f59e0b;
  --blue: #1d4ed8;
  --green: #15803d;
  --red: #b91c1c;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
#app:has(#d-map:not([hidden])) { padding-bottom: 0; }
#app { max-width: 760px; margin: 0 auto; padding-bottom: calc(24px + var(--safe-bottom)); }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.1rem; }
h2 { font-size: 1.25rem; }
p { margin: .4rem 0; }
small { display: block; color: var(--muted); }
a { color: var(--blue); }
.muted { color: var(--muted); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); list-style: none; }

/* ---------- controls ---------- */

button, .button, input, select {
  font: inherit; min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
}
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: 0 1rem; background: var(--card); color: var(--ink); font-weight: 600;
  text-decoration: none; cursor: pointer; flex: 1; white-space: nowrap;
}
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.success { background: var(--green); border-color: var(--green); color: #fff; }
.danger { background: var(--red); border-color: var(--red); color: #fff; }
.danger-text { color: var(--red); }
.ghost { background: transparent; border-color: transparent; }
.link { width: 100%; margin-top: .4rem; color: var(--blue); font-weight: 600; }
.big { min-height: 56px; font-size: 1.1rem; }
.icon { flex: 0 0 44px; padding: 0; background: transparent; border: 0; color: #fff; font-size: 1.4rem; }
input, select { width: 100%; padding: 0 .75rem; background: #fff; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.file { display: inline-flex; align-items: center; min-height: 44px; margin-top: .6rem; padding: 0 1.2rem; border-radius: 10px;
  background: var(--blue); color: #fff; cursor: pointer; }
.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file:focus-within { outline: 3px solid #93c5fd; }
.bar .text { flex: 0 0 auto; min-height: 36px; background: transparent; color: #fff; border-color: #3b4a61; }
.card h2 + select, .row.between select { width: auto; max-width: 16rem; }
.row.between input[type=date] { width: auto; }

.row { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.row.between { justify-content: space-between; }
.row.between > * { flex: 0 1 auto; }
.row.end { justify-content: flex-end; }
.row.end > button { flex: 0 0 auto; }
.row .left { margin-right: auto; }
.stack { display: grid; gap: .9rem; }

/* ---------- layout ---------- */

.bar {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + var(--safe-top)) 1rem .6rem; background: var(--navy); color: #fff;
}
.tabs { display: flex; background: var(--navy); padding: 0 .5rem; }
.tabs button { background: transparent; border: 0; border-radius: 0; color: #b9c3d3; border-bottom: 3px solid transparent; }
.tabs button.on { color: #fff; border-bottom-color: var(--brand); }
.page, #d-list { padding: .75rem; }

.progress { position: relative; height: 26px; background: #e5e9f0; overflow: hidden; }
.card .progress { border-radius: 8px; margin: .6rem 0; }
.progress span { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width .3s; }
.progress em { position: relative; display: block; text-align: center; font: 600 .85rem/26px system-ui; color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card.current { border: 2px solid var(--navy); box-shadow: 0 4px 14px rgb(15 27 45 / .12); }
.card.dump { border-color: var(--brand); }
.card h2 { margin-top: .5rem; }
.address { font-size: 1.05rem; }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; background: var(--navy); color: #fff; font-size: .8rem; font-weight: 600; }
.dump .badge { background: var(--brand); color: var(--navy); }
.note { padding: .5rem .7rem; border-left: 4px solid var(--brand); background: #fff7e6; font-weight: 600; }
.warn { color: #92400e; font-size: .9rem; }

.status { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.status.done { color: var(--green); }
.status.blocked, .status.not_out { color: var(--red); }
p.status { font-size: 1.1rem; }

.segmented { display: flex; gap: 4px; padding: 4px; margin: .5rem 0; background: #e5e9f0; border-radius: 12px; }
.segmented button { border: 0; background: transparent; }
.segmented button.on { background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.stops { list-style: none; margin: 0; padding: 0; }
.stop {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .6rem .75rem; margin-bottom: 6px;
  text-align: left; font-weight: 400; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.stop.static { margin-bottom: 6px; }
.stop.selected { border-color: var(--blue); box-shadow: inset 4px 0 0 var(--blue); }
.stop .grow { flex: 1; min-width: 0; }
.stop strong, .stop small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { flex: 0 0 2.2rem; text-align: center; font-weight: 700; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.divider { margin: .75rem 0 .5rem; padding: .4rem; text-align: center; font-weight: 700; font-size: .85rem; color: var(--navy); background: #fff1d6; border-radius: 8px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.grid select { min-width: 9rem; }

/* ---------- map ---------- */

.map-view { position: relative; height: calc(100dvh - 128px - var(--safe-top)); }
#d-map #map { position: absolute; inset: 0; }
.map-box { height: 55vh; border-radius: var(--radius); margin: .6rem 0; }
.sheet {
  position: absolute; left: .5rem; right: .5rem; bottom: calc(.5rem + var(--safe-bottom)); z-index: 900;
  padding: .8rem; background: var(--card); border-radius: var(--radius); box-shadow: 0 6px 24px rgb(0 0 0 / .2);
}
.sheet:empty { display: none; }
.pin {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .35);
  color: #fff; font: 700 12px/1 system-ui;
}
.pin.done { background: var(--green); }
.pin.problem { background: var(--red); }
.pin.unpinned { background: #6b7280; }
.pin.current { background: var(--brand); color: var(--navy); transform: scale(1.25); }

/* ---------- sign-in, dialog, toast ---------- */

.auth { max-width: 360px; margin: 12vh auto 0; padding: 0 1.25rem; text-align: center; }
.auth img { border-radius: 16px; }
.auth h1 { font-size: 1.6rem; margin: .6rem 0 .2rem; }
.auth form { margin-top: 1.25rem; text-align: left; }

dialog { width: min(92vw, 420px); border: 0; border-radius: 16px; padding: 1.25rem; box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(15 27 45 / .55); }
dialog form { display: grid; gap: .8rem; }

#toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + var(--safe-bottom)); transform: translateX(-50%); z-index: 2000;
  max-width: 90vw; padding: .75rem 1.1rem; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}
#toast.ok { background: var(--green); }
#toast.error { background: var(--red); }
