:root {
  --bg: #f3f4f1; --panel: #fff; --text: #1d211b; --muted: #636a5f; --border: #d7dbd2;
  --accent: #2f6b34; --accent-dark: #1f4d24; --accent-bg: #e6f0e4;
  --red: #b3261e; --red-bg: #fbe3e1; --amber: #8a5a10; --amber-bg: #fbf1e0; --green-bg: #e3f2e4; --grey-bg: #ececea;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); }
button:hover { background: var(--accent-bg); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dark); }
button.link { border: 0; background: none; color: var(--accent-dark); text-decoration: underline; padding: 0; }
input, select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
a { color: var(--accent-dark); }

/* sign-in */
.login { max-width: 380px; margin: 8vh auto; padding: 28px 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login label { display: block; margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.login input { width: 100%; }
.login .actions { margin-top: 20px; }
.msg { color: var(--red); min-height: 20px; margin-top: 10px; }

/* page */
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 18px; flex: 1 1 auto; }
.topbar .who { color: var(--muted); font-size: 13px; }
.page { padding: 14px 20px 120px; max-width: 1500px; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.chip { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); border-left-width: 6px; cursor: pointer; text-align: left; }
.chip b { display: block; font-size: 20px; line-height: 1.1; }
.chip span { color: var(--muted); font-size: 12px; }
.chip.active { outline: 2px solid var(--accent); }
.chip.ready { border-left-color: #2e7d32; } .chip.todo { border-left-color: var(--red); } .chip.unsched { border-left-color: #c58a12; } .chip.done { border-left-color: #9aa097; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 9px 16px; }
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent-dark); font-weight: 700; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 6px 0 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.filters .f { display: flex; flex-direction: column; gap: 3px; }
.filters label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.filters input[type=search] { min-width: 200px; }

.wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid #ebede7; }
th { background: #eef0ea; position: sticky; top: 0; white-space: nowrap; cursor: pointer; user-select: none; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; z-index: 1; }
th.nosort { cursor: default; }
th .arrow { color: var(--accent-dark); margin-left: 4px; }
td.num, th.num { text-align: right; }
tr.group td { background: #e3e8de; font-weight: 700; padding: 7px 10px; }
tr.row-ready td { background: #f1f9f1; } tr.row-ready td:first-child { box-shadow: inset 5px 0 0 #2e7d32; }
tr.row-todo td:first-child { box-shadow: inset 5px 0 0 var(--red); }
tr.row-unsched td { background: #fffaf0; } tr.row-unsched td:first-child { box-shadow: inset 5px 0 0 #c58a12; }
tr.row-done td { color: #7a7f76; background: #f7f7f5; } tr.row-done td:first-child { box-shadow: inset 5px 0 0 #b5b9b2; }
tr.picked td { outline: none; background: #e6f0e4 !important; }
.stop { margin-bottom: 4px; } .stop:last-child { margin-bottom: 0; }
.stop .cust { font-weight: 600; } .stop .addr { color: #3b4137; } .stop .meta { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ready { background: var(--green-bg); color: #1f5e22; } .pill.todo { background: var(--red-bg); color: var(--red); }
.pill.unsched { background: var(--amber-bg); color: var(--amber); } .pill.done { background: var(--grey-bg); color: #5d625a; }
.pill.bulk { background: #e8eef7; color: #264b7d; } .pill.bagged { background: #f1e8f7; color: #5b2e7d; }
.today { background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.overdue { color: var(--red); font-weight: 700; }
.small { font-size: 12px; color: var(--muted); }
.docs a { display: block; white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* the planning bar */
.planner { position: fixed; left: 0; right: 0; bottom: 0; background: #1f4d24; color: #fff; padding: 10px 20px; z-index: 20; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; box-shadow: 0 -4px 16px rgba(0,0,0,.2); }
.planner b { font-size: 16px; }
.planner .warn { background: #ffd9a8; color: #5a3500; padding: 3px 10px; border-radius: 8px; font-size: 12.5px; }
.planner button, .planner a.btn { background: #fff; color: #1f4d24; border: 0; padding: 7px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.planner .cap { width: 72px; padding: 5px 8px; }
.planner .bar { flex: 1 1 160px; height: 10px; background: rgba(255,255,255,.25); border-radius: 6px; min-width: 120px; overflow: hidden; }
.planner .bar div { height: 100%; background: #9ed79f; } .planner .bar div.over { background: #ff8f85; }

#toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 40; }
#toast.show { opacity: 1; } #toast.error { background: var(--red); }

/* printing the run sheet */
#runsheet { display: none; }
@media print {
  body.printing > *:not(#runsheet) { display: none !important; }
  body.printing #runsheet { display: block; padding: 6mm; color: #000; }
  #runsheet h2 { margin: 0 0 4px; } #runsheet table { border: 1px solid #444; } #runsheet th, #runsheet td { border: 1px solid #888; padding: 5px 7px; position: static; cursor: default; background: #fff; }
  @page { size: A4 landscape; margin: 10mm; }
}
@media (max-width: 700px) { .page { padding: 10px 10px 140px; } .topbar { padding: 8px 12px; } }
