/* WTC Job Board — mobile-first */

:root {
  --navy: #0f2f4a;
  --navy-700: #1a4468;
  --teal: #0e7c86;
  --ink: #16202b;
  --muted: #5d6b7a;
  --line: #e3e8ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --high: #c0392b;
  --high-bg: #fdecea;
  --med: #b26a00;
  --med-bg: #fdf3e2;
  --low: #4a6572;
  --low-bg: #eef2f5;
  --ok: #17694a;
  --ok-bg: #e6f4ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 14px rgba(16, 32, 48, .05);
}

* { box-sizing: border-box; }

/* our .modal / .chip rules set display, which would otherwise beat [hidden] */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--teal);
  font-weight: 700;
  font-size: 15px;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .01em; }
.brand-text small { font-size: 11px; opacity: .72; letter-spacing: .06em; text-transform: uppercase; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 10px;
  max-width: 1100px;
  margin: 0 auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  flex: none;
  padding: 9px 12px 11px;
  font-size: 14px;
  color: rgba(255,255,255,.7);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs a.active { color: #fff; border-bottom-color: var(--teal); font-weight: 600; }

body:not(.is-admin) .admin-only { display: none !important; }
body:not(.is-mgmt) .mgmt-only { display: none !important; }

/* ---------- lock screen ---------- */

.lock { display: grid; place-items: center; min-height: 55vh; padding: 24px 8px; }
.lock-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
  max-width: 380px;
  text-align: center;
}
.lock-card h1 { margin: 0 0 8px; font-size: 20px; }
.lock-card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

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

.view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px 64px;
}

.loading, .empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}
.empty-row { padding: 16px 14px; color: var(--muted); font-size: 14px; list-style: none; }

.page-head { margin: 4px 2px 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- completion notices ---------- */

.news-card {
  background: var(--ok-bg);
  border: 1px solid #bfe0d1;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.news-head { font-weight: 700; color: var(--ok); margin-bottom: 8px; font-size: 14px; }
.news-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.news-list li { font-size: 14px; }
.news-list li span { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.news-more { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

/* ---------- summary strip ---------- */

.summary {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.summary h2 { margin: 0 0 2px; font-size: 18px; font-weight: 600; }
.summary .sub { font-size: 13px; opacity: .8; margin-bottom: 12px; }
.summary-stats { display: flex; gap: 8px; flex-wrap: wrap; }

.stat {
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
}
.stat.danger { background: rgba(255,120,100,.26); }
.stat.warn { background: rgba(255,196,90,.24); }

.summary-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

.picker {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 13px;
  outline: none;
}
.picker option { color: var(--ink); }

/* ---------- stage cards ---------- */

.stage-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}
.stage-head .spacer { flex: 1; }
.stage-name { font-weight: 650; font-size: 15px; }
.stage-blurb { font-size: 12px; color: var(--muted); }

/* a coloured spine per stage, so the eye finds the pile it wants */
.stage-card.s-new   { border-top: 3px solid #c0392b; }
.stage-card.s-doc   { border-top: 3px solid #b26a00; }
.stage-card.s-ready { border-top: 3px solid #2f6fa8; }
.stage-card.s-out   { border-top: 3px solid #0e7c86; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex: none;
}

/* ---------- job rows ---------- */

.job-list { list-style: none; margin: 0; padding: 0; }

.job {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f3f6;
  border-left: 4px solid transparent;
  align-items: flex-start;
}
.job:last-child { border-bottom: 0; }
.job.is-late { border-left-color: var(--high); background: #fffbfb; }
.job.is-stuck:not(.is-late) { border-left-color: #e3a33a; }

.job-main { flex: 1; min-width: 0; }
.job-title { font-size: 15px; font-weight: 550; word-wrap: break-word; }

.job-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.job-items .item {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: #f2f5f8;
  border: 1px solid #e6ebf0;
  border-radius: 6px;
  padding: 1px 7px;
  color: #2c3a48;
}
.job-items .item em { font-style: normal; color: var(--med); }

.job-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  align-items: center;
}

.job-actions { display: flex; gap: 6px; flex: none; align-items: center; }

/* ---------- chips ---------- */

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.chip-High { background: var(--high-bg); color: var(--high); }
.chip-count { background: #eef2f5; color: var(--muted); font-weight: 600; }
.chip-due { background: #eef2f5; color: var(--muted); font-weight: 500; }
.chip-due.overdue { background: var(--high-bg); color: var(--high); font-weight: 700; }
.chip-due.today { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip-warn { background: #fdf3e2; color: var(--med); }
.chip-team { background: #e8f1f5; color: #0b5c65; }
.chip-cust { background: #ecf0fa; color: #33487e; }
.chip-who { background: #eef7f2; color: var(--ok); }
.chip-stuck { background: var(--med-bg); color: var(--med); }
/* DC / invoice number, once the barcode builder has written it back */
.chip-doc {
  background: #e8f1f5; color: #0b5c65;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.chip-type { color: #fff; }
.chip-type.t-supply  { background: #2f6fa8; }
.chip-type.t-invoice { background: #8a5a9e; }
.chip-type.t-collect { background: #17694a; }
.chip-type.t-pickup  { background: #b26a00; }
.chip-type.t-other   { background: #4a6572; }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f4f7fa; }
.btn:active { transform: translateY(1px); }

.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: #0c6b74; }
/* opens the barcode builder — deliberately not the same colour as the
   "move this job on" button, because it leaves the board */
.btn-scan {
  background: #fff; border-color: #0e7c86; color: #0b5c65;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn-scan:hover { background: #eaf4f5; }
.btn-danger { color: var(--high); border-color: #f0cdc8; background: #fff; }
.btn-danger:hover { background: var(--high-bg); }
.btn-ghost {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.24);
  color: #fff;
}
.btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-block { width: 100%; }

/* ---------- forms ---------- */

.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.field input[type=text],
.field input[type=date],
.field input[type=time],
.field input[type=number],
.field input[type=email],
.field input[type=password],
.field input[type=file],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,134,.12);
}
.field textarea { min-height: 76px; resize: vertical; }

.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; min-width: 0; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  flex: 1;
  border: 0;
  background: #fff;
  padding: 9px 6px;
  cursor: pointer;
  font-size: 14px;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; font-weight: 600; }

/* product rows on the confirm screen */
.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row .i-code { flex: 3; min-width: 0; }
.item-row .i-qty  { flex: 1; min-width: 58px; }
.item-row .i-note { flex: 2; min-width: 0; }
.item-row input {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  width: 100%;
}
.item-row .i-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: uppercase; }
.item-row input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,124,134,.12); }

.raw-quote {
  background: #f7f9fb;
  border-left: 3px solid var(--line);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 13.5px;
  color: #34424f;
  white-space: pre-wrap;
  margin-bottom: 14px;
}

/* ---------- filters ---------- */

.filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: var(--shadow);
}
.filters select, .filters input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  font-size: 14px;
}
.filters input[type=search] { flex: 1; min-width: 150px; }
.filters .count { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- table ---------- */

.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f0f3f6; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fbfcfd; }
td.wrap { white-space: normal; min-width: 220px; }
tr:last-child td { border-bottom: 0; }

/* ---------- modal / toast ---------- */

.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(16,32,48,.45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(16,32,48,.28);
}
.modal-card h2 { margin: 0 0 12px; font-size: 18px; padding-right: 24px; }
.modal-card h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.modal-close {
  position: absolute; top: 8px; right: 10px;
  border: 0; background: none; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer;
}

.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-items { margin: 0; padding-left: 18px; font-size: 14px; }
.detail-items b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.detail-items em { font-style: normal; color: var(--med); }
.detail-batch {
  display: block; font-size: 12px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detail-log { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--muted); }
.detail-log li { padding: 5px 0; border-bottom: 1px solid #f2f5f8; }
.detail-log li span { display: inline-block; min-width: 78px; color: var(--ink); font-weight: 600; }

.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-strip img {
  width: 78px; height: 78px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 95;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  max-width: 90vw;
  text-align: center;
}

.banner {
  background: #fdf3e2;
  border: 1px solid #f0dcb6;
  color: #7a5410;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

/* ---------- desktop ---------- */

@media (min-width: 760px) {
  .view { padding: 22px 20px 80px; }
  .page-head h1 { font-size: 26px; }
  .summary { padding: 20px 22px; }
  .summary h2 { font-size: 21px; }
  .job { padding: 13px 16px; }
}

@media (max-width: 620px) {
  .job { flex-wrap: wrap; }
  .job-actions { width: 100%; padding-left: 0; }
  .field-row { flex-direction: column; gap: 0; }
  .item-row { flex-wrap: wrap; }
  .item-row .i-code { flex: 1 1 100%; }
}
