:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #e7e1d5;
  --card: #f6f3ec;
  --line: #d4cdc0;
  --green: #0f6e56;
  --green-ink: #e7f6f1;
  --amber: #8a5a12;
  --amber-bg: #f4e6cf;
  --red: #8f2d2d;
  --red-bg: #f6e4e1;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Candara, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  /* Clear the fixed multi-row bottom bar (Back/Next or Power / IS / Register / Master register). */
  padding: 16px 16px calc(430px + env(safe-area-inset-bottom, 0px));
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}
h1 { margin: 0; font-size: 28px; line-height: 1.1; }
.chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.3;
  background: var(--amber-bg);
  color: var(--amber);
  max-width: 150px;
  text-align: right;
}
.chip.ready { background: var(--green-ink); color: var(--green); }
.chip.bad { background: var(--red-bg); color: var(--red); }

.steps {
  display: flex;
  gap: 6px;
  margin: 8px 0 16px;
}
.steps span {
  height: 4px;
  flex: 1;
  border-radius: 99px;
  background: var(--line);
}
.steps span.on { background: var(--green); }

.card.need { border-color: var(--red); }
.jb-exe {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line, #e4ddd3);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 18px; }
.hint, .quiet { color: var(--muted); font-size: 14px; line-height: 1.4; }
label.field { display: block; margin-top: 12px; }
label.field span, .ask {
  display: block;
  font-weight: 650;
  margin-bottom: 6px;
}
.note {
  margin-top: 6px;
  font-size: 13px;
  color: var(--amber);
}
input[type="text"], input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 12px;
  min-height: 48px;
}
select { text-overflow: ellipsis; }
.prebuild-lead { margin: 2px 0 10px; }
.prebuild-lead .hint { margin: 0 0 6px; }
.prebuild-select {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}
.free-material { margin-top: 12px; }
.free-material-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.free-material-row input { flex: 1 1 auto; min-width: 0; }
.free-material-row button { flex: 0 0 auto; }
.matches { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.matches button.match {
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  line-height: 1.3;
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #6b6560; opacity: 1; }
canvas.signature {
  width: 100%;
  height: 140px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  touch-action: none;
  display: block;
  margin-top: 8px;
}

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button, .pair button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 44px;
}
.choices button.on, .pair button.on {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair.three { grid-template-columns: 1fr 1fr 1fr; }
.pair button.fail.on { background: var(--red); border-color: var(--red); }

.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(246, 243, 236, 0.96);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.bar-inner,
.home-actions {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
}
.home-actions {
  margin-bottom: 12px;
}
.bar-inner > button,
.home-actions > button {
  flex: 1 1 calc(50% - 6px);
  min-width: min(100%, 148px);
  min-height: 48px;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 0;
  border: 0;
}
.primary,
.bar .next,
.bar .back {
  background: var(--green);
  color: white;
  font-weight: 700;
  border: 0;
}
.ghost,
.home-actions .back {
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
}
.job {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  min-height: 48px;
}
.job strong { display: block; }
.job small { color: var(--muted); display: block; }
.job-reopen {
  background: #fff2cc !important;
  border-color: #ffc000 !important;
  box-shadow: inset 0 0 0 1px rgba(255, 192, 0, 0.45);
}
.job-reopen-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #ffc000;
  color: #1c1915;
  font-size: 12px;
  font-weight: 700;
}
.quote-saved-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #335693;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.empty { padding: 8px 0 16px; color: var(--muted); }
.warn {
  background: var(--amber-bg);
  color: var(--amber);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.okbox {
  background: var(--green-ink);
  color: var(--green);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.photo {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 8px;
}
.file {
  display: block;
  margin-top: 8px;
}
ul.missing { margin: 8px 0 0; padding-left: 18px; }
ul.missing li { margin: 4px 0; }
@page { size: A4 portrait; margin: 8mm; }
@media print {
  .bar, .no-print, .home-actions, .file { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  html.ac005-printing #app,
  html.ac005-printing body > *:not(#ac005-print-root) { display: none !important; }
  html.ac005-printing #ac005-print-root {
    display: block !important;
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
.card.readonly input,
.card.readonly textarea,
.card.readonly select,
.card.readonly button {
  opacity: 1;
}
.card.readonly button:disabled {
  color: inherit;
}
.card.readonly button.on:disabled {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.card.readonly button.fail.on:disabled {
  background: var(--red);
  border-color: var(--red);
  color: white;
}
.browse-banner .home-actions {
  margin-top: 8px;
  margin-bottom: 0;
}
.materials-block { margin-top: 10px; }
.consumable-pick { margin: 10px 0 4px; }
.consumable-pick .hint { margin: 0 0 6px; }
.material-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--line, #d8d0c4);
  border-radius: 10px;
}
.material-line .quiet { margin: 0; flex: 1 1 140px; min-width: 0; }
.qty-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}
.qty-field input[type="number"] {
  width: 72px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}
.fault-exports { margin-top: 8px; }
.material-line.quote-stack {
  flex-direction: column;
  align-items: stretch;
}
.quote-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #335693;
}
.quote-calc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  width: 100%;
}
.quote-calc .rate,
.quote-calc .cost {
  font-size: 14px;
  font-weight: 650;
}
.quote-calc .cost { margin-left: auto; }
.quote-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 10px;
  font-weight: 700;
  border-radius: 8px;
}
.quote-total.gold { background: #FFC000; color: #1c1915; }
.quote-total.blue { background: #335693; color: #fff; }
.quote-calc .back {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 40px;
  padding: 6px 10px;
}

/* Phone chrome follows the signed-in role. Pass/Fail/N/A, reopen rows, and print sheets are left alone. */
body.role-inspector #app .top,
body.role-manager #app .top {
  margin: -16px -16px 16px;
  padding: 16px 16px 14px;
  border-radius: 0;
}
body.role-inspector #app .top {
  background: #FFC000;
  color: #1a1a1a;
}
body.role-manager #app .top {
  background: #335693;
  color: #fff;
}
body.role-inspector #app .top .eyebrow,
body.role-inspector #app .top h1 {
  color: #1a1a1a;
}
body.role-manager #app .top .eyebrow,
body.role-manager #app .top h1 {
  color: #fff;
}
body.role-inspector #app .top .chip,
body.role-manager #app .top .chip {
  background: var(--amber-bg);
  color: var(--amber);
}
body.role-inspector #app .top .chip.ready,
body.role-manager #app .top .chip.ready {
  background: var(--green-ink);
  color: var(--green);
}
body.role-inspector #app .top .chip.bad,
body.role-manager #app .top .chip.bad {
  background: var(--red-bg);
  color: var(--red);
}
body.role-inspector #app .bar {
  background: #FFC000;
  border-top: 1px solid #1a1a1a;
  color: #1a1a1a;
}
body.role-manager #app .bar {
  background: #335693;
  border-top: 1px solid #1a1a1a;
  color: #fff;
}
body.role-inspector #app .primary,
body.role-inspector #app .bar .next,
body.role-inspector #app .bar .back,
body.role-inspector #app .home-actions > button.role-pick-inspector {
  background: #FFC000;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
}
body.role-manager #app .primary {
  background: #335693;
  color: #fff;
  border: 2px solid #1a1a1a;
}
body.role-manager #app .bar .next,
body.role-manager #app .bar .back {
  background: #335693;
  color: #fff;
  border: 2px solid #fff;
}
#app .home-actions > button.role-pick-inspector {
  background: #FFC000;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
}
#app .home-actions > button.role-pick-manager {
  background: #335693;
  color: #fff;
  border: 2px solid #1a1a1a;
}
.table-wrap { overflow-x: auto; max-width: 100%; margin: 0 0 16px; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 720px; font-size: 13px; background: var(--card); }
.table-wrap th, .table-wrap td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap td.wrap { white-space: normal; max-width: 180px; }
.table-wrap td.history { white-space: normal; min-width: 150px; }
.table-wrap .history-btn, .table-wrap .history-open {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  text-align: left;
}
body.role-inspector #app .primary:disabled,
body.role-inspector #app .bar .next:disabled,
body.role-inspector #app .bar .back:disabled,
body.role-manager #app .primary:disabled,
body.role-manager #app .bar .next:disabled,
body.role-manager #app .bar .back:disabled {
  opacity: 0.55;
}
@media print {
  body.role-inspector #app .top,
  body.role-manager #app .top,
  body.role-inspector #app .top .eyebrow,
  body.role-inspector #app .top h1,
  body.role-manager #app .top .eyebrow,
  body.role-manager #app .top h1 {
    background: none;
    color: #1c1915;
  }
}

