/*
 * Design tokens and component classes for Operator's Shoebox, ported from
 * docs/design-reference.html (the CPMO-approved clickable prototype) --
 * kraft/tool-tone palette, safety-orange accent used sparingly, tabular
 * numerals for money, big touch targets. The prototype framed everything
 * inside a fixed 390px phone mockup for a desktop preview; this file
 * drops that frame and lays out full-viewport, since the real app opens
 * on an actual phone (and, less importantly, a desktop browser during
 * development).
 */
:root {
  --kraft: #EFE7DA; --paper: #FBF8F2; --card: #FFFFFF; --ink: #221E17; --mut: #6E6759;
  --line: #DCD2C0; --line2: #E9E1D2;
  --orange: #D95B12; --orange-s: #FBE8DC;
  --ok: #2E6B4F; --ok-s: #E3EFE8;
  --dim: #8A8272;
  --danger: #B23B2E; --danger-s: #F8E3DF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --kraft: #191713; --paper: #211E19; --card: #2A261F; --ink: #EDE8DE; --mut: #A69D8B;
    --line: #3B362C; --line2: #322E25;
    --orange: #F07B33; --orange-s: #3A2517;
    --ok: #7CC4A0; --ok-s: #1B2C23;
    --dim: #7E7666;
    --danger: #E37060; --danger-s: #3A1F1A;
  }
}
:root[data-theme="dark"] {
  --kraft: #191713; --paper: #211E19; --card: #2A261F; --ink: #EDE8DE; --mut: #A69D8B;
  --line: #3B362C; --line2: #322E25;
  --orange: #F07B33; --orange-s: #3A2517;
  --ok: #7CC4A0; --ok-s: #1B2C23;
  --dim: #7E7666;
  --danger: #E37060; --danger-s: #3A1F1A;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--kraft); color: var(--ink);
  font-family: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5;
}
.money, .tabular { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

#app-shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 560px; margin: 0 auto; background: var(--paper); }

.appbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line2); background: var(--paper); position: sticky; top: 0; z-index: 5;
}
.appbar .name { font-weight: 800; letter-spacing: .01em; font-size: 18px; }
.appbar .spacer { flex: 1; }
.appbar .chip { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--ok); }

.screen { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding-bottom: 24px; }
.screen.on { display: flex; }
.padded { padding: 16px; }

.tabs {
  display: flex; border-top: 1px solid var(--line2); background: var(--paper);
  position: sticky; bottom: 0; z-index: 5; padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 4px 12px; font: inherit;
  font-size: 12px; color: var(--mut); cursor: pointer; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px;
}
.tabs button .ic { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--orange); }
.tabs button .badge {
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; background: var(--orange);
  color: #fff; border-radius: 8px; padding: 1px 5px; margin-left: 2px;
}

/* Capture */
.viewfinder {
  flex: 1; background: repeating-linear-gradient(45deg, #2b2b2b 0 12px, #262626 12px 24px);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  position: relative; min-height: 340px; color: #cfc9bd;
}
.vf-note { position: absolute; top: 16px; left: 0; right: 0; text-align: center; font-size: 13px; font-family: "IBM Plex Mono", monospace; padding: 0 20px; }
.shutterwrap { padding: 22px 0 30px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: var(--orange);
  cursor: pointer; box-shadow: 0 3px 14px rgba(0,0,0,.4); appearance: none;
}
.shutter:active { transform: scale(.94); }
.shutter:disabled { opacity: .5; }
.offline-chip {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; color: #e8e2d5;
  background: rgba(0,0,0,.5); border-radius: 12px; padding: 4px 12px;
}
.gotit {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(20,18,14,.85); color: #fff; font-size: 30px; font-weight: 800; text-align: center; padding: 0 24px;
}
.gotit.on { display: flex; }

/* Cards / lists */
.rcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; margin-bottom: 10px; }
.rcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rcard .m { font-weight: 700; font-size: 15.5px; }
.rcard .amt { font-weight: 600; }
.rcard .pred { font-size: 13.2px; color: var(--mut); margin-top: 3px; }
.rcard .conf { font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.rcard .row { display: flex; gap: 8px; margin-top: 10px; }
.rcard.err { border-left: 3px solid var(--orange); }

.btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 9px;
  padding: 11px 14px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--ink);
  min-height: 44px;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.warn, .btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.wide { flex: 1; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.empty { margin: 40px 16px; text-align: center; }
.empty .big { font-size: 20px; font-weight: 800; }
.empty .sub { color: var(--mut); font-size: 13.5px; margin-top: 8px; }
.empty .sub.ok { color: var(--ok); font-family: "IBM Plex Mono", monospace; }
.empty .cta { margin-top: 16px; }

.section-title { font-size: 20px; font-weight: 800; margin: 2px 0 2px; }
.section-count { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--ok); margin: 2px 0 12px; }
.sect-label {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .1em; color: var(--dim);
  margin: 18px 0 6px; text-transform: uppercase;
}

/* Receipt / document detail */
.dgrid { display: grid; grid-template-columns: 110px 1fr; gap: 14px; }
.thumb-link { display: block; }
.thumb-link img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; }
/* Phase 4, A1: job detail's photo gallery -- a small grid of tap-to-full-image thumbnails. */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.photo-grid .thumb-link img { aspect-ratio: 1 / 1; object-fit: cover; }
.photo-grid .thumb-link.voided img { opacity: .45; }
.fields { display: flex; flex-direction: column; gap: 8px; }
.frow { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; border-bottom: 1px dashed var(--line); padding-bottom: 7px; cursor: default; }
.frow.clickable { cursor: pointer; }
.frow .k { color: var(--mut); font-size: 12.5px; }
.frow .v { font-weight: 600; text-align: right; }
.frow .v small { display: block; font-size: 9.5px; color: var(--dim); font-weight: 400; }
.evtrail { margin: 16px 0 4px; background: var(--kraft); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: var(--mut); }
.evtrail b { color: var(--ink); }

/* Job sheet (bottom sheet) */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,18,14,.5); display: none; align-items: flex-end; justify-content: center; z-index: 20;
}
.sheet-backdrop.on { display: flex; }
.sheet {
  background: var(--card); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.2); width: 100%; max-width: 560px; max-height: 80vh; overflow-y: auto;
}
.sheet h4 { margin: 0 0 12px; font-size: 16px; }
.jbtn {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 14px; font: inherit; cursor: pointer; margin-bottom: 8px; color: var(--ink); min-height: 44px;
}
.jbtn.pred { border-color: var(--ink); font-weight: 800; font-size: 16px; }
.jbtn .sub { display: block; font-size: 11.5px; color: var(--mut); font-weight: 400; margin-top: 2px; }
.newrow { display: flex; gap: 8px; margin-top: 6px; }
input[type="text"], input[type="tel"], input[type="email"] {
  flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
  font: inherit; font-size: 15px; background: var(--paper); color: var(--ink); min-height: 44px;
}

/* Brief (Home) */
.brief-day { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--mut); }
.brief h2 { font-size: 22px; margin: 4px 0 14px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 9px 2px; font-size: 14.5px; }
.noticed { background: var(--orange-s); border: 1px solid var(--orange); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-top: 6px; }
.safe-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 14px; }
.safe-card .label { font-size: 12px; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; }
.safe-card .value { font-size: 15px; margin-top: 4px; }

.toast {
  position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 10px 18px; font-size: 13.5px; display: none; white-space: nowrap; z-index: 30; max-width: 90vw; text-overflow: ellipsis; overflow: hidden;
}
.toast.on { display: block; }

.banner {
  background: var(--orange-s); border: 1px solid var(--orange); border-radius: 9px; padding: 11px 14px;
  font-size: 13px; margin: 0 16px 14px;
}

.doc-thumb-row { display: flex; align-items: center; gap: 12px; }
.doc-thumb-row img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.doc-type-tag {
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--dim); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px;
}
.status-tag.ok { color: var(--ok); }
.status-tag.warn { color: var(--orange); }
.status-tag.danger { color: var(--danger); }

a.plain { color: var(--ink); }
.linklike { background: none; border: 0; color: var(--mut); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 6px 0; }

/* WP-22: Reports. Tabular numerals throughout (via .tabular, already used
   everywhere money appears) and a plain table for print, per the WP's own
   "tabular numerals, print-friendly" line. */
.rtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rtable th, .rtable td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.rtable td.num, .rtable th.num { text-align: right; }
@media print {
  .tabs, .appbar, .btn, #toast { display: none !important; }
  body, .screen { background: #fff !important; color: #000 !important; }
  .rcard, .rtable { border-color: #999 !important; }
}

/* Phase 3: forms the pilot did not have yet -- textarea/select/number/date
   inputs, styled to match the existing text/tel/email rule above so a form
   with several field types never looks like two different apps stitched
   together. */
textarea, select, input[type="number"], input[type="date"] {
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
  font: inherit; font-size: 15px; background: var(--paper); color: var(--ink); min-height: 44px;
}
textarea { width: 100%; min-height: 72px; resize: vertical; font-family: inherit; }
.field-label { font-size: 12px; color: var(--mut); margin: 10px 0 4px; display: block; font-weight: 600; }
.field-stack { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }

/* Line-item editor (Phase 3, Sellable DoD item 2) */
.li-row { display: grid; grid-template-columns: 1fr 52px 78px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.li-row input { min-height: 40px; padding: 8px 9px; font-size: 14px; }
.li-row .li-remove { border: none; background: none; color: var(--danger); font-size: 20px; cursor: pointer; padding: 4px; min-height: 40px; }
.li-total-row { display: flex; justify-content: space-between; font-weight: 800; font-size: 17px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }

/* Archived / voided tags -- never hidden, always named plainly where a user would look. */
.status-tag.void, .status-tag.archived { color: var(--dim); border-color: var(--dim); text-decoration: line-through; }

/* Search box, added to every list screen the DoD asks for (Sellable DoD
   item 5: "every list searches"). Plain client-side filter at pilot
   scale -- no server round trip needed for lists this small. */
.search-box { margin-bottom: 12px; }
.search-box input { width: 100%; }

/* Offline banner (Sellable DoD item 5): honest, not alarming -- the kraft/
   orange tone already used for `.banner`, pinned above the tab bar so it
   is never missed but never blocks a screen either. */
.offline-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--orange-s); border-top: 1px solid var(--orange); color: var(--ink);
  font-size: 12.5px; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  text-align: center; max-width: 560px; margin: 0 auto;
}

/* Settings screen cards (company profile / category / vendor rows) */
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.settings-row .actions { display: flex; gap: 6px; }
.settings-row .actions button { padding: 6px 10px; font-size: 12.5px; min-height: 32px; }
