/* Prevet - mobile first. Big touch targets, high contrast, works in sunlight. */
:root {
  --brand: #e01810; --brand-dark: #b8120c; --brand-soft: #fdecea;
  --ink: #1d2127; --muted: #5d6673; --line: #d5d9df; --bg: #f2f3f5; --card: #fff;
  --ok: #17803d; --ok-soft: #e4f5ea; --warn: #8a5a00; --warn-soft: #fff1d6; --err: #b3261e; --err-soft: #fdeceb;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,24,30,.08), 0 2px 8px rgba(20,24,30,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef0f3; --muted: #a3acb8; --line: #3a414b; --bg: #15181c; --card: #1e2329;
    --brand-soft: #3a1a18; --ok-soft: #12301d; --warn-soft: #3a2c0c; --err-soft: #3a1917;
    --ok: #5cd08a; --warn: #f0c065; --err: #ff8a80;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; scroll-padding-bottom: 110px; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
img { max-width: 100%; }
a { color: var(--brand-dark); }
@media (prefers-color-scheme: dark) { a { color: #ff8f88; } }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; word-break: break-all; }
.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 16px; padding-bottom: 40px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 8px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--brand); }

/* top bar */
.topbar { background: #22262b; color: #fff; position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 12px; }
.brand { display: flex; align-items: center; background: #fff; padding: 4px 8px; border-radius: 6px; }
.brand img { display: block; height: 28px; width: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link { color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.nav-link:hover { background: rgba(255,255,255,.12); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: 6px; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; }
.usermenu-pop { position: absolute; right: 0; top: 100%; min-width: 210px; background: var(--card); color: var(--ink);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 12px; display: grid; gap: 8px; }
.usermenu-pop a, .linkbtn { color: var(--ink); text-decoration: none; padding: 10px 8px; border-radius: 8px; background: none; border: 0;
  font: inherit; text-align: left; cursor: pointer; width: 100%; display: block; }
.usermenu-pop a:hover, .linkbtn:hover { background: var(--bg); }

/* layout bits */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.form-section h2 { padding-bottom: 8px; border-bottom: 2px solid var(--brand); display: inline-block; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: grid; gap: 8px; }
.inline { display: inline; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid-3 > :first-child { grid-column: 1 / -1; }
.grid-form { display: grid; gap: 10px; align-items: end; margin-bottom: 12px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-3 > :first-child { grid-column: auto; }
}
.kv { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; margin-top: 10px; } .kv dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 720px) { .kv { grid-template-columns: 180px 1fr; } .kv dt { margin-top: 0; padding: 6px 0; } .kv dd { padding: 6px 0; } }
.plain { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.pdi-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* alerts */
.flashes { display: grid; gap: 8px; margin-bottom: 12px; }
.alert { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); margin-bottom: 12px; }
.flashes .alert { margin: 0; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.alert-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert-error { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.alert-error a, .alert-error code { color: inherit; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px;
  border-radius: 10px; border: 2px solid transparent; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  background: var(--card); color: var(--ink); line-height: 1.2; text-align: center; }
.btn-primary { background: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); } .btn-ghost:hover { border-color: var(--ink); }
.btn-danger-ghost { background: transparent; border-color: var(--err); color: var(--err); }
.btn-sm { min-height: 38px; padding: 4px 12px; font-size: .9rem; }
.btn-big { min-height: 52px; font-size: 1.05rem; padding: 10px 20px; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid #2a6df4; outline-offset: 2px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; font-size: 0; }

/* fields */
.field { display: grid; gap: 4px; margin: 0 0 12px; } .field > span, .mini-label { font-weight: 600; font-size: .9rem; }
.mini-label { margin: 6px 0 4px; color: var(--muted); }
.inline-field { margin: 0; display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 46px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(42,109,244,.35); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input:disabled { background: var(--bg); color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; }
.w3w-row { display: flex; align-items: stretch; } .w3w-row input { border-radius: 0 10px 10px 0; }
.w3w-prefix { display: grid; place-items: center; padding: 0 12px; background: var(--brand); color: #fff; font-weight: 800; border-radius: 10px 0 0 10px; }

/* chips (radio / checkbox as big tappable pills) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip > span { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card); font-weight: 600; user-select: none; }
.chips.small .chip > span { min-height: 40px; padding: 6px 12px; }
.chip-tight > span { padding: 6px 10px; min-width: 44px; justify-content: center; }
.chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.chip input:checked + span::before { content: "✓"; font-weight: 800; }
.chip input:focus-visible + span { outline: 3px solid #2a6df4; outline-offset: 2px; }
.chip-wide { display: flex; } .chip-wide > span { border-radius: var(--radius); width: 100%; justify-content: flex-start; }
@media (prefers-color-scheme: dark) { .chip input:checked + span { color: #ffb3ad; } }

/* expandable panels */
.panel { border: 2px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; background: var(--card); }
.panel > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; min-height: 52px; font-weight: 700; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "▾"; margin-left: 8px; color: var(--muted); transition: transform .15s; }
.panel[open] > summary::after { transform: rotate(180deg); }
.panel[open] { border-color: var(--ink); }
.panel .count { margin-left: auto; font-weight: 600; font-size: .85rem; color: var(--muted); background: var(--bg); padding: 2px 10px; border-radius: 999px; }
.panel .count.has { color: var(--brand-dark); background: var(--brand-soft); }
.panel-body { padding: 4px 12px 12px; display: grid; gap: 8px; }
.eq-extra { display: none; margin: 6px 0 4px 10px; padding: 8px 10px; border-left: 4px solid var(--brand); background: var(--bg); border-radius: 0 10px 10px 0; }
.eq.on .eq-extra, .eq:has(.eq-sel:checked) .eq-extra { display: block; }
.eq-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: stretch; flex: none; }
.stepper input { width: 64px; text-align: center; border-radius: 0; border-left: 0; border-right: 0; padding: 6px 4px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step { width: 46px; min-height: 46px; font-size: 1.4rem; font-weight: 700; background: var(--card); color: var(--ink);
  border: 2px solid var(--line); cursor: pointer; }
.step:first-child { border-radius: 10px 0 0 10px; } .step:last-child { border-radius: 0 10px 10px 0; }
.step:active { background: var(--brand-soft); }

/* sticky action bar */
.has-actionbar main.wrap { padding-bottom: 110px; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0,0,0,.08); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
.actionbar-in { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actionbar .btn { flex: 1 1 auto; } @media (min-width: 720px) { .actionbar .btn { flex: 0 0 auto; } }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 2px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
  text-decoration: none; color: var(--ink); display: grid; gap: 2px; }
.tile strong { font-size: 1.6rem; line-height: 1; } .tile span { font-size: .82rem; color: var(--muted); }
.tile.on { border-color: var(--brand); } .tile:hover { border-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .field { margin: 0; } .filters .grow { flex: 1 1 220px; }
.more-filters { flex: 1 1 100%; } .more-filters summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.filter-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin: 8px 0 12px; }
@media (min-width: 720px) { .filter-grid { grid-template-columns: repeat(4, 1fr); } }
.list-tools { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.joblist { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.job-row { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 4px 12px;
  grid-template-columns: 36px 1fr auto; align-items: center; padding: 10px 12px; }
.job-pick { grid-row: 1 / span 3; display: grid; place-items: center; min-height: 44px; cursor: pointer; }
.job-pick input { width: 22px; height: 22px; }
.job-main { grid-column: 2 / 4; text-decoration: none; color: var(--ink); display: grid; gap: 2px; }
.job-sub { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-date { grid-column: 2; font-weight: 600; } .job-date small { display: block; font-weight: 400; color: var(--muted); }
.job-net { grid-column: 3; color: var(--muted); text-align: right; }
.job-flags { grid-column: 2 / 4; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.job-row.is-past { opacity: .8; }
@media (min-width: 820px) {
  .job-row { grid-template-columns: 36px minmax(0, 1fr) 110px 90px 230px; }
  .job-pick { grid-row: auto; } .job-main { grid-column: auto; } .job-date { grid-column: auto; } .job-net { grid-column: auto; text-align: left; }
  .job-flags { grid-column: auto; justify-content: flex-end; }
}
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.empty { text-align: center; }

/* pills / tags */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill-draft { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-submitted { background: #e3edff; color: #1d4fb8; border-color: transparent; }
.pill-picked { background: #efe6ff; color: #5b30b0; border-color: transparent; }
.pill-delivered { background: #dff3f5; color: #0b6470; border-color: transparent; }
.pill-complete { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-archived { background: var(--bg); color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font-size: .82rem; font-weight: 600; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table .num { text-align: right; }
.actions { display: grid; gap: 12px; }
.status-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-form select { width: auto; min-height: 40px; }

/* photos */
.photo-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
.photo { display: grid; gap: 6px; align-content: start; min-width: 0; }
.photo-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--bg); border-radius: 10px; overflow: hidden;
  text-decoration: none; color: var(--ink); text-align: center; padding: 6px; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.doc-icon { font-size: 2rem; display: block; } .doc-name { font-size: .8rem; overflow-wrap: anywhere; }
.photo-meta { display: grid; gap: 2px; font-size: .9rem; min-width: 0; } .photo-meta .cap { font-weight: 600; overflow-wrap: anywhere; }
.photo-edit summary { cursor: pointer; color: var(--muted); font-size: .85rem; padding: 4px 0; }
.photo-edit form { margin-top: 6px; }
.queue { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.q-item { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: start; border: 2px solid var(--line); border-radius: var(--radius); padding: 8px; }
.q-item img, .q-item .q-doc { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 1.6rem; }
.q-body { display: grid; gap: 6px; min-width: 0; } .q-name { font-size: .85rem; overflow-wrap: anywhere; }
.q-body .grid-2 { gap: 6px; } .q-body select, .q-body input { min-height: 40px; padding: 6px 10px; }
.q-status { font-size: .85rem; font-weight: 600; } .q-item.done { border-color: var(--ok); } .q-item.fail { border-color: var(--err); }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; } .bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

/* PDI */
.pdi-lines { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.pdi-line { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; }
/* PDI quantities: one row each on phones (label left, stepper right) so nothing overflows; 3 across on wider screens */
.qty3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.qty3 .field { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qty3 .field > span { flex: 1 1 auto; }
.qty3 .stepper input { width: 64px; }
@media (min-width: 640px) {
  .qty3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .qty3 .field { display: block; }
}
.sig h3 { margin-top: 4px; }
.sig-canvas { width: 100%; height: 150px; background: #fff; border: 2px dashed var(--line); border-radius: 10px; touch-action: none; display: block; }
.sig-img { max-height: 70px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.sig-existing { display: grid; gap: 6px; margin-bottom: 8px; }

/* admin */
.subnav { display: flex; gap: 6px; margin: 0 0 14px; flex-wrap: wrap; }
.subnav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; background: var(--card); border: 2px solid var(--line); color: var(--ink); font-weight: 600; }
.subnav a.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.userlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.user > details { border: 2px solid var(--line); border-radius: var(--radius); }
.user summary { cursor: pointer; padding: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user.inactive { opacity: .7 } .user-actions { padding: 0 12px 12px; display: grid; gap: 10px; }
.optlist { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 6px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.opt.inactive { opacity: .55; } .opt-rename { display: flex; gap: 6px; flex: 1 1 240px; } .opt-rename input { min-height: 38px; padding: 4px 10px; }
.inline-details summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }

.login-card { max-width: 420px; margin: 24px auto; }
@media print { .topbar, .actionbar, .btn, .nav { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
