/* CDC Telecom brand: blue #4374AC (primary) and red #BD3934 (accent), Roboto.
   Two motifs from the logo: the red layer offset behind the blue letters (used as a hard
   offset shadow on primary actions) and the "data bars" inside the D (header stripe, headings). */
:root {
  --blue: #4374ac;
  --blue-600: #375f8e;
  --blue-700: #2b4b71;
  --blue-100: #dbe6f3;
  --blue-50: #eef3f9;
  --red: #bd3934;
  --red-600: #9d2e2a;
  --red-50: #fbeceb;
  --ink: #1d2838;
  --ink-2: #3a4658;
  --muted: #637083;
  --line: #e2e7ee;
  --bg: #f3f6fa;
  --card: #ffffff;
  --warn: #b25e09;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 40, 56, .06), 0 1px 3px rgba(29, 40, 56, .08);
  --shadow-lift: 0 4px 14px rgba(29, 40, 56, .12);
  --offset: 3px 3px 0 var(--red);
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  /* status colours: brand blue for assigned, clear distinct hues for live work */
  --s-unassigned: #8a96a8;
  --s-assigned: var(--blue);
  --s-driving_to: #c77a12;
  --s-on_site: #23874f;
  --s-driving_from: #6a5acd;
  --s-done: #56637a;
  --s-cancelled: #a3adbb;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); }
a:hover { color: var(--blue-700); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; color: var(--ink); }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* "data bars" – the stripes inside the D of the logo */
.bars {
  height: 4px;
  background: repeating-linear-gradient(90deg,
    var(--blue) 0 28px, transparent 28px 34px, var(--red) 34px 52px, transparent 52px 58px);
}
.sec-title, .day-head, .section h3, .col h3 {
  display: flex; align-items: center; gap: 8px;
}
.sec-title::before, .day-head::before, .section h3::before {
  content: ""; width: 14px; height: 8px; flex: none;
  background: linear-gradient(var(--blue) 0 3px, transparent 3px 5px, var(--red) 5px 8px);
  border-radius: 1px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card); color: var(--ink);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; min-height: 58px;
  box-shadow: 0 1px 0 var(--line);
}
.topbar-wrap { position: sticky; top: 0; z-index: 20; }
.topbar-wrap .topbar { position: static; }
.brandmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brandmark img { height: 30px; width: auto; display: block; }
.brandmark .app {
  font-weight: 500; font-size: 15px; color: var(--blue); letter-spacing: .3px;
  padding-left: 10px; border-left: 1px solid var(--line); line-height: 1.1;
}
.topbar .who { font-size: 13px; color: var(--muted); }
.icon-btn {
  background: var(--blue-50); border: 0; color: var(--blue-700); border-radius: 10px;
  height: 38px; min-width: 38px; padding: 0 10px; cursor: pointer; position: relative; font-size: 16px;
}
.icon-btn:hover { background: var(--blue-100); }
.badge {
  position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 10px; min-width: 18px; height: 18px;
  display: grid; place-items: center; padding: 0 4px; box-shadow: 0 0 0 2px var(--card);
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; text-decoration: none; color: var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s, border-color .15s;
}
.btn:hover { border-color: #c5cfdc; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--offset);
}
.btn.primary:hover:not(:disabled) { background: var(--blue-600); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--red); color: #fff; }
.btn.primary:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--red); }
.btn.outline { border-color: var(--blue); color: var(--blue); }
.btn.outline:hover { background: var(--blue-50); color: var(--blue-700); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-50); color: var(--red-600); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big {
  width: 100%; padding: 17px; font-size: 18px; border-radius: 14px; border-width: 2px; font-weight: 700;
}
.btn.big.primary { box-shadow: 4px 4px 0 var(--red); }
.btn.go-driving_to { background: var(--s-driving_to); border-color: var(--s-driving_to); color: #fff; }
.btn.go-on_site { background: var(--s-on_site); border-color: var(--s-on_site); color: #fff; }
.btn.go-driving_from { background: var(--s-driving_from); border-color: var(--s-driving_from); color: #fff; }
.btn.go-done { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.go-nav { background: var(--card); border-color: var(--blue); color: var(--blue); }
.btn[class*="go-"]:hover { filter: brightness(1.06); color: #fff; }
.btn.go-nav:hover { color: var(--blue-700); background: var(--blue-50); filter: none; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--ink-2); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd7e2; border-radius: 10px; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--blue-100); border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px; background: var(--blue-50); color: var(--blue-700); white-space: nowrap;
}
label.chip { cursor: pointer; user-select: none; padding: 6px 11px; font-size: 13px; background: #f1f4f8; color: var(--ink-2); border: 1px solid transparent; }
label.chip input { margin: 0; accent-color: var(--blue); }
label.chip:has(input:checked) { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.unassigned { background: #eceff3; color: #4c5869; }
.pill.assigned { background: var(--blue-50); color: var(--blue-700); }
.pill.driving_to { background: #fdf0d9; color: #8a4b05; }
.pill.on_site { background: #dcf3e5; color: #155c35; }
.pill.driving_from { background: #ebe8fb; color: #47399e; }
.pill.done { background: #eceff3; color: var(--ink-2); }
.pill.cancelled { background: #f2f4f7; color: #8e98a6; text-decoration: line-through; }
.prio { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.prio.urgent { color: #fff; background: var(--red); padding: 2px 7px; border-radius: 5px; box-shadow: 2px 2px 0 var(--blue); }
.prio.high { color: var(--red); }
.prio.low { color: var(--muted); }

/* ---------- cards & lists ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.job-card {
  display: block; cursor: pointer; border-left: 4px solid var(--s-assigned); color: inherit; text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
.job-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); color: inherit; }
.job-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.job-card .ref { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .2px; }
.job-card .title { font-weight: 700; margin: 4px 0 2px; }
.job-card .meta { font-size: 13px; color: var(--muted); }
.job-card.st-unassigned { border-left-color: var(--s-unassigned); }
.job-card.st-driving_to { border-left-color: var(--s-driving_to); }
.job-card.st-on_site { border-left-color: var(--s-on_site); }
.job-card.st-driving_from { border-left-color: var(--s-driving_from); }
.job-card.st-done, .job-card.st-cancelled { border-left-color: var(--s-done); opacity: .72; }
.list { display: grid; gap: 10px; }
.day-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 16px 2px 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue-700); }
.timeline .dur { margin-left: 6px; font-size: 12px; font-weight: 500; background: var(--blue-50); color: var(--blue-700); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0 2px; color: var(--blue); font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: underline; }
.timeline .ev-note { background: #fff8e8; border-left: 3px solid #e9b949; border-radius: 6px; padding: 6px 9px; margin-top: 4px; white-space: pre-wrap; }
.time-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.time-sum div { background: var(--blue-50); border-radius: 10px; padding: 9px 4px; }
.time-sum b { display: block; font-size: 18px; color: var(--blue-700); }
.time-sum span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.time-sum div:last-child { background: var(--blue); }
.time-sum div:last-child b, .time-sum div:last-child span { color: #fff; }

/* ---------- toast & modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lift);
  max-width: calc(100% - 32px); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--red); }
.modal-back {
  position: fixed; inset: 0; background: rgba(29, 40, 56, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 16px 24px;
  max-height: 92vh; overflow: auto; border-top: 4px solid var(--blue);
}
.modal h3 { margin-bottom: 6px; font-size: 19px; }
.modal .actions { display: grid; gap: 10px; margin-top: 16px; }
@media (min-width: 700px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 16px; padding: 24px; }
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--blue-50), transparent 70%),
    var(--bg);
}
.login { width: 100%; max-width: 380px; }
.login .brand { text-align: center; margin-bottom: 22px; }
.login .brand img { width: 230px; max-width: 80%; height: auto; }
.login .brand .app { margin-top: 6px; color: var(--ink-2); font-weight: 500; letter-spacing: .3px; }
.login .card { padding: 22px 20px 18px; box-shadow: 6px 6px 0 var(--red), var(--shadow); border: 1px solid var(--line); border-top: 4px solid var(--blue); }
.login .hint { background: var(--blue-50); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); margin-top: 14px; }
.login .hint code { color: var(--blue-700); font-weight: 500; }
.login .foot { text-align: center; margin-top: 18px; }

/* steps discarded by an office override: kept in history, not timed */
.timeline li.void { opacity: .55; }

/* job type tag (install has none) */
.type-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: .2px; }
.type-tag.survey { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); }
.type-tag.fault { background: var(--red-50); color: var(--red-600); }
.type-tag.maintenance { background: #eef1f4; color: var(--ink-2); }

/* offline taps: saved on the phone until there's signal */
#sync-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: none; padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; font-size: 14px;
  font-weight: 500; text-align: center; }
#sync-bar.show { display: block; }
.timeline li .pending { color: var(--warn); }
body:has(#sync-bar.show) #toast { bottom: 76px; }   /* keep messages clear of the no-signal bar */

/* materials & equipment */
.mat-list { list-style: none; margin: 0; padding: 0; }
.mat-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.mat-list li:last-child { border-bottom: 0; }
.mat-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.mat-row input[type=number] { width: 72px; padding: 6px 8px; }
.mat-other { margin-bottom: 6px; }
.bring { display: flex; flex-wrap: wrap; gap: 6px; }
.bring .chip { background: #fff4e5; color: #6b3a00; font-size: 13px; padding: 5px 10px; }
.clash { background: #fff4e5; border: 1px solid #f5c98a; color: #6b3a00; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }

/* crews & multi-day jobs */
.pill.in_progress { background: #dcf3e5; color: #155c35; }
.pill.ongoing { background: #fdf6e3; color: #7a5a00; }
.job-card.st-in_progress { border-left-color: var(--s-on_site); }
.job-card.st-ongoing { border-left-color: #d4a514; }
.crew-list { list-style: none; margin: 8px 0 0; padding: 0; }
.crew-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.crew-list li:last-child { border-bottom: 0; }
.chip.lead { background: var(--blue); color: #fff; font-size: 11px; padding: 1px 7px; }
.chip.overdue { background: #fdecea; color: #8c2a20; font-size: 11px; }
.btn.go-complete { background: #fff; border: 2px solid var(--s-on_site); color: var(--s-on_site); }
.btn.go-complete:hover { background: #dcf3e5; }
details.more-box { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
details.more-box summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--blue-700); }
details.more-box[open] summary { margin-bottom: 8px; }
.person-times { width: 100%; font-size: 13px; border-collapse: collapse; margin-top: 8px; }
.person-times td, .person-times th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.person-times td:first-child, .person-times th:first-child { text-align: left; }
label.chip { white-space: normal; }   /* long options (e.g. the office address) wrap */
.qty-step { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.qty-step input { width: 52px; text-align: center; padding: 5px 4px; }
.small.short { color: var(--red); font-weight: 600; }

/* "Load the van" */
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plan-list li:last-child { border-bottom: 0; }
.plan-list li.loaded .grow { color: var(--muted, #6b7685); }
.plan-list input[type=checkbox] { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--s-on_site); flex: none; }
.plan-row { display: grid; grid-template-columns: minmax(0, 2.2fr) 72px 84px minmax(0, 1.4fr) 24px; gap: 6px; align-items: center; margin-bottom: 6px; }
.plan-row input, .plan-row select { padding: 6px 8px; min-width: 0; }
@media (max-width: 640px) { .plan-row { grid-template-columns: minmax(0, 1fr) 64px 24px; } .plan-row [name=p-unit], .plan-row [name=p-note] { display: none; } }

/* 🧠 Memory */
.memory { max-width: 860px; }
.rules { margin: 0; padding-left: 22px; }
.rules li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rules li::marker { color: var(--muted); }
.rules li .rule-btns { display: flex; gap: 8px; flex: none; }
.rules li textarea { min-height: 70px; }
.rule-text.new { background: #e3f4e9; border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }

/* 📦 Stock */
.seg { display: inline-flex; background: var(--blue-50); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--blue-700); font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }
table.inv-grid td, table.inv-grid th { padding: 4px 8px; }
table.inv-grid td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; white-space: normal; min-width: 220px; }
table.inv-grid tr.grp td { background: #f3f6fa; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.qty-cell { width: 72px; text-align: right; padding: 4px 6px; border: 1px solid transparent; background: transparent; font-variant-numeric: tabular-nums; }
.qty-cell:hover, .qty-cell:focus { border-color: var(--line); background: #fff; }
td.low .qty-cell { color: var(--red); font-weight: 700; background: #fdecea; }
.low-box { background: #fff4e5; border: 1px solid #f5c98a; margin-bottom: 12px; color: #6b3a00; }
.inv-row { display: grid; grid-template-columns: minmax(0, 2fr) 80px minmax(0, 2fr) 24px; gap: 6px; margin-bottom: 6px; align-items: center; }
.mat-sn { padding: 0 0 8px 28px; }
.mat-sn input { font-size: 13px; padding: 6px 8px; }
.van-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.van-row input { width: 76px; text-align: right; }
.van-row.low input { color: var(--red); font-weight: 700; background: #fdecea; }
