/* Dewey & Sons Dispatch: mobile first. Big tap targets (48px), readable in a truck in sunlight. */
:root {
  --navy: #14294f; --deep: #0a1730; --blue: #1f417f; --blue2: #2f66c0; --red: #c62828; --red-d: #9f1d20;
  --bg: #eef1f7; --card: #fff; --ink: #16192a; --muted: #5a6480; --line: #d9deea; --ok: #1b7f3b; --warn: #b26a00;
  --ok-bg: #e3f4e8; --warn-bg: #fff1d6; --bad-bg: #fde4e4; --info-bg: #e3ecfb; --gray-bg: #e8ebf2;
  --radius: 14px; --shadow: 0 1px 2px rgba(10, 23, 48, .08), 0 4px 14px rgba(10, 23, 48, .06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1226; --card: #15203d; --ink: #eef2fb; --muted: #a9b5d3; --line: #2a3a63; --ok-bg: #12351f; --warn-bg: #3b2c0d; --bad-bg: #421a1d; --info-bg: #1a2c52; --gray-bg: #1f2c4e; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue2); }

/* top bar + bottom nav */
.top { position: sticky; top: 0; z-index: 20; background: var(--deep); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 3px solid var(--red); }
.top h1 { font-size: 1.05rem; margin: 0; flex: 1; line-height: 1.15; }
.top h1 small { display: block; font-weight: 500; opacity: .75; font-size: .75rem; }
.top .iconbtn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; min-width: 44px; height: 44px; font-weight: 700; cursor: pointer; }
main { max-width: 1200px; margin: 0 auto; padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; text-align: center; padding: 8px 2px 7px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; position: relative; min-height: 56px; }
.nav a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
.nav a.on { color: var(--blue2); }
.nav a.plus { color: #fff; }
.nav a.plus span.fab { display: grid; place-items: center; width: 52px; height: 52px; margin: -22px auto 2px; border-radius: 50%; background: var(--red); box-shadow: 0 3px 10px rgba(198,40,40,.5), 0 0 0 3px var(--card); }
.nav a.plus { color: var(--muted); }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--red); color: #fff; border-radius: 999px; font-size: .68rem; min-width: 18px; height: 18px; padding: 0 5px; line-height: 18px; }

/* cards, buttons, forms */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 0 0 12px; }
.card h2, .card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.sub { color: var(--muted); font-size: .88rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.blue { background: var(--blue2); border-color: var(--blue2); color: #fff; }
.btn.green { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; }
label.f { display: block; font-weight: 600; font-size: .88rem; margin: 10px 0 4px; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
textarea { min-height: 84px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid #f5b301; outline-offset: 1px; }
.chk { display: flex; gap: 10px; align-items: center; padding: 8px 0; min-height: 44px; }
.chk input { width: 22px; height: 22px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { min-width: 0; min-height: 48px; padding: 0 6px; white-space: nowrap; font-size: 1rem; border: 2px solid var(--line); background: var(--card); border-radius: 10px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.seg button.on.emg { background: var(--red); border-color: var(--red); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--gray-bg); color: var(--muted); white-space: nowrap; }
.pill.requested { background: var(--warn-bg); color: var(--warn); }
.pill.scheduled { background: var(--info-bg); color: var(--blue2); }
.pill.enroute { background: var(--warn-bg); color: var(--warn); }
.pill.working { background: var(--bad-bg); color: var(--red); }
.pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.emg { background: var(--red); color: #fff; }
.pill.qb { background: #2ca01c; color: #fff; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; background: var(--deep); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 520px; margin: 0 auto; }
.toast.err { background: var(--red-d); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); font-size: .9rem; margin: 8px 0; }
.note.warn { background: var(--warn-bg); }
.note.bad { background: var(--bad-bg); }
.note.ok { background: var(--ok-bg); }

/* schedule */
.datebar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.datebar .day { flex: 1; text-align: center; font-weight: 800; font-size: 1.05rem; }
.datebar .day small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }
.lanes { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .lanes { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.lane { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lane header { padding: 10px 12px; border-top: 5px solid var(--c, var(--blue2)); display: flex; flex-direction: column; gap: 6px; }
.lane h3 { margin: 0; font-size: 1.02rem; }
.load { height: 8px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.load i { display: block; height: 100%; background: var(--c, var(--blue2)); }
.drive { margin: 0 12px; padding: 5px 0 5px 14px; border-left: 3px dotted var(--line); color: var(--muted); font-size: .8rem; }
.job { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.job:first-of-type { border-top: 0; }
.job .t { font-weight: 800; font-variant-numeric: tabular-nums; }
.job .who { font-weight: 700; }
.empty { padding: 18px 12px; color: var(--muted); text-align: center; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { flex: 1; min-width: 90px; background: var(--card); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .8rem; }

/* suggestions */
.slot { display: block; width: 100%; text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; margin: 8px 0; cursor: pointer; }
.slot.on { border-color: var(--blue2); background: var(--info-bg); }
.slot .name { font-weight: 800; }
.slot ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* list rows */
.li { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); width: 100%; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }
.li:first-child { border-top: 0; }

/* chat */
.thread { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: var(--gray-bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--blue2); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.out.ai { background: #5b48b5; }
.msg small { display: block; opacity: .75; font-size: .7rem; margin-top: 2px; }
.composer { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--bg); padding-top: 8px; }
.composer textarea { min-height: 48px; height: 48px; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(5, 10, 25, .6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 760px) { .scrim { align-items: center; } .sheet { border-radius: 20px; } }

/* login */
.login { max-width: 380px; margin: 6vh auto 0; padding: 0 16px 32px; }
.login .brand { text-align: center; margin-bottom: 18px; }
.login .brand b { display: block; font-size: 1.5rem; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 8px; }
/* The logo artwork sits on a white rounded badge so it reads in light and dark mode. */
.logo-big { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 14px; padding: 10px 14px; background: #fff; border-radius: 20px; box-shadow: 0 6px 22px rgba(10,23,48,.18), 0 0 0 1px rgba(10,23,48,.06); box-sizing: border-box; }
.login .brand b { margin-top: 2px; }
.linkbtn { display: block; width: 100%; margin-top: 10px; background: none; border: 0; padding: 10px; color: var(--blue2); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.toplogo { height: 40px; width: auto; flex: none; background: #fff; border-radius: 10px; padding: 3px 6px; box-shadow: 0 0 0 2px rgba(255,255,255,.25); display: block; }
.morelogo { text-align: center; padding: 18px 14px 8px; }
.morelogo img { width: 100%; max-width: 240px; height: auto; background: #fff; border-radius: 18px; padding: 8px 12px; box-sizing: border-box; box-shadow: 0 0 0 1px var(--line); }

/* tech day */
.tjob { border-left: 6px solid var(--blue2); }
.tjob.now { border-left-color: var(--red); }
.tjob.done { opacity: .65; border-left-color: var(--ok); }
.tjob .big { font-size: 1.15rem; font-weight: 800; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.actions .wide { grid-column: 1 / -1; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
.ok { color: var(--ok); } .bad { color: var(--red); }
.spin { text-align: center; color: var(--muted); padding: 24px; }

/* on-call calendar */
.calrow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal { border: 2px solid var(--line); background: var(--card); border-radius: 10px; padding: 4px 2px; min-height: 68px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-size: .7rem; min-width: 0; }
.cal.wkend { background: var(--gray-bg); }
.cal.today { border-color: var(--blue2); }
.cal.prob { border-color: var(--red); }
.cal .dn { font-weight: 700; color: var(--muted); }
.cal .who { color: #fff; border-radius: 6px; padding: 1px 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.cal .who.none { background: transparent; color: var(--red); }
.cal .offc { color: var(--warn); font-weight: 700; }

/* live map */
#map { height: 340px; border-radius: 14px; position: relative; z-index: 0; isolation: isolate; margin-bottom: 12px; border: 1px solid var(--line); }
.mk { width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
.mk.stale { opacity: .55; filter: grayscale(.6); }
.jk { width: 16px; height: 16px; border-radius: 4px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); background: #2f66c0; }
.jk.enroute { background: #b26a00; } .jk.working { background: #c62828; } .jk.emg { outline: 2px solid #c62828; }
.live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
.live.off { background: var(--muted); }

/* work order number tag */
.wo { display: inline-block; font: 700 .72rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; padding: 0 6px; border-radius: 6px; background: var(--gray-bg, #e8ecf4); color: var(--ink); margin-right: 4px; vertical-align: 1px; }
.hide { display: none !important; }

/* billable time + photos */
.bill { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--info-bg); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; display: block; background: var(--gray-bg); }
.photos figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.linkbtn.inline { display: inline; width: auto; margin: 0; padding: 0 2px; font-size: inherit; color: var(--red); }

/* next-job helper */
.choice { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.choice.rec { border: 2px solid var(--red); }
.choice .pill { margin-left: 4px; }
.sub.ok { color: var(--ok); }
.sub.bad { color: var(--red); }
@media (prefers-color-scheme: dark) { .sub.ok { color: #6fcf8f; } .sub.bad { color: #ff8a80; } }

/* plumber: My day */
h2.sect { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 4px 6px; }
.steps { display: flex; gap: 6px; margin-bottom: 8px; font-size: .74rem; font-weight: 700; }
.steps span { flex: 1; text-align: center; padding: 5px 2px; border-radius: 8px; background: var(--gray-bg); color: var(--muted); }
.steps span.on { background: var(--ink); color: var(--card); }
.steps span.past { background: var(--ok-bg); color: var(--ok); }
.stepbtn { min-height: 58px; font-size: 1.15rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.15; }
.stepbtn small { display: block; font-size: .78rem; font-weight: 600; opacity: .9; }
/* phones: urgency buttons in two rows of two so "Emergency" always fits */
@media (max-width: 560px) { .seg { grid-template-columns: 1fr 1fr; } }
.demobar { background: #fff3c4; color: #5a4300; border: 1px solid #e6c24a; border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: .9rem; font-weight: 600; text-align: center; }
.card.demobar { font-weight: 500; line-height: 1.6; }
