/* WORQ Ops Audit - mobile first, comfortable on a laptop.
 *
 * An audit is done walking round a site with a phone in one hand:
 *  - tap targets 44px and up, scores as one row of big buttons;
 *  - system fonts only, nothing waits on a webfont over hotel wifi;
 *  - no inline styles anywhere: the Content-Security-Policy forbids them.
 * The report and dashboard widen out on a bigger screen and print cleanly.
 */

:root {
  color-scheme: light;
  --page: #f7f7f5;
  --card: #ffffff;
  --soft: #f1f0ec;
  --ink: #111111;
  --ink-2: #55534e;
  --ink-3: #8a877f;
  --line: rgba(0, 0, 0, 0.10);
  --brand: #f6a000;          /* WORQ orange */
  --brand-ink: #111111;
  --s0: #c0362c; --s0-bg: #fbe5e2;
  --s1: #d4602a; --s1-bg: #fdebdf;
  --s2: #a87400; --s2-bg: #fff3d6;
  --s3: #3f8f3a; --s3-bg: #e8f4e5;
  --s4: #13703a; --s4-bg: #d9f0e0;
  --wait: #8a5a00; --wait-bg: #fff3d6;
  --crit: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0e0e0d;
    --card: #1c1c1a;
    --soft: #262623;
    --ink: #f4f3ef;
    --ink-2: #c4c2b9;
    --ink-3: #8a877f;
    --line: rgba(255, 255, 255, 0.12);
    --s0: #ef6b60; --s0-bg: #3a1714;
    --s1: #f08a55; --s1-bg: #3a2014;
    --s2: #f6c34a; --s2-bg: #33280e;
    --s3: #7fcf73; --s3-bg: #1a2e18;
    --s4: #4cc46e; --s4-bg: #13301b;
    --wait: #f6c34a; --wait-bg: #33280e;
    --crit: #ef6b60;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--page); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 0 8px; }
.brand-mark { height: 24px; width: auto; display: block; }
.brand-name { font-weight: 700; }
.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a {
  padding: 12px 10px 12px; font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--ink-2); border-bottom: 3px solid transparent;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
/* Settings cog: administrators only. Sits at the right of the bar; on a phone
   the tabs drop to their own row and the cog stays up beside the logo. */
.settings-cog {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: 0 0 4px; border-radius: 12px;
  font-size: 22px; line-height: 1; text-decoration: none; color: var(--ink-2);
}
.settings-cog:hover, .settings-cog.on { background: var(--soft); color: var(--ink); }
.settings-section { margin-top: 4px; }
@media (max-width: 420px) {
  .settings-cog { order: 1; margin-left: auto; }
  .tabs { order: 2; margin-left: 0; width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 10px 4px; }
}

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 14px;
  background: var(--wait-bg); color: var(--wait); border-bottom: 1px solid var(--line);
}
.banner-btn {
  margin-left: auto; flex-shrink: 0; border: 1px solid currentColor; border-radius: 10px;
  background: transparent; padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------- Layout ---------- */
.page {
  max-width: 760px; margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}
.page.wide { max-width: 1240px; }
.loading { color: var(--ink-3); text-align: center; padding: 40px 0; }
h1 { font-size: 22px; margin: 4px 0 6px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.lede { color: var(--ink-2); margin: 0 0 16px; line-height: 1.45; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin: 0 0 12px;
}
.empty { text-align: center; color: var(--ink-3); padding: 24px 12px; }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 12px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.textarea { min-height: 76px; resize: vertical; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 700; text-decoration: none;
}
.btn-block { display: flex; width: 100%; margin: 0 0 10px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--soft); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn-danger { background: var(--s0-bg); color: var(--s0); }
.btn-sm { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 10px; }

/* ---------- Chips and badges ---------- */
.chip {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--soft); color: var(--ink-2);
  white-space: nowrap;
}
.risk-Critical { background: var(--s0-bg); color: var(--s0); }
.risk-High { background: var(--s1-bg); color: var(--s1); }
.risk-Medium { background: var(--s2-bg); color: var(--s2); }
.risk-Low { background: var(--soft); color: var(--ink-2); }

.band { font-weight: 700; }
.band-Outstanding, .band-Good { color: var(--s4); }
.band-Improvement { color: var(--s2); }
.band-Poor { color: var(--s1); }
.band-Critical, .band-CRITICAL { color: var(--crit); }
.pill-band {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.pill-band.band-Outstanding { background: var(--s4-bg); }
.pill-band.band-Good { background: var(--s3-bg); color: var(--s3); }
.pill-band.band-Improvement { background: var(--s2-bg); }
.pill-band.band-Poor { background: var(--s1-bg); }
.pill-band.band-Critical, .pill-band.band-CRITICAL { background: var(--s0-bg); }
.pill-band.band-Incomplete, .pill-band.band-draft { background: var(--soft); color: var(--ink-2); }

/* ---------- Home: audit list ---------- */
.audit-item {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 0 0 8px;
}
.audit-item .meta { min-width: 0; flex: 1; }
.audit-item .title { font-weight: 700; }
.audit-item .sub { font-size: 13px; color: var(--ink-2); }
.audit-item .score { font-size: 20px; font-weight: 800; text-align: right; }
progress {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border: 0; border-radius: 999px; background: var(--soft); overflow: hidden; display: block;
}
progress::-webkit-progress-bar { background: var(--soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }

/* ---------- Audit: header ---------- */
.audit-head { position: relative; }
.audit-head .where { font-size: 13px; color: var(--ink-2); }
.scorebox { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 6px; flex-wrap: wrap; }
.scorebox .big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.critical-banner {
  background: var(--crit); color: #fff; border-radius: 12px; padding: 10px 12px;
  margin: 10px 0 0; font-size: 14px; line-height: 1.4;
}
.critical-banner strong { display: block; font-size: 15px; }
.locked-note {
  background: var(--soft); border-radius: 12px; padding: 10px 12px; margin: 10px 0 0; font-size: 14px;
}

/* ---------- Audit: categories ---------- */
.cat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 10px; }
.cat-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.cat-head .name { font-weight: 700; }
.cat-head .sub { font-size: 13px; color: var(--ink-2); }
.cat-head .pct { margin-left: auto; font-weight: 800; white-space: nowrap; }
.cat-head .chev { color: var(--ink-3); transition: transform 0.15s; }
.cat.open .cat-head .chev { transform: rotate(90deg); }
.cat-body { padding: 0 10px 10px; }
.cat:not(.open) .cat-body { display: none; }

/* ---------- Audit: checkpoint ---------- */
.cp { border-top: 1px solid var(--line); padding: 14px 4px 12px; }
.cp:first-child { border-top: 0; }
.cp-top { display: flex; gap: 8px; align-items: flex-start; }
.cp-name { font-weight: 700; flex: 1; line-height: 1.3; }
.cp-standard { font-size: 14px; color: var(--ink-2); margin: 4px 0 10px; line-height: 1.4; }
.cp.unscored .cp-name::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); margin: 0 6px 2px 0; vertical-align: middle;
}

.scores { display: grid; grid-template-columns: repeat(5, 1fr) 1.1fr; gap: 6px; }
.score-btn {
  min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 2px; line-height: 1.1;
}
.score-btn .n { font-size: 19px; font-weight: 800; }
.score-btn .l { font-size: 10.5px; color: var(--ink-3); }
.score-btn:disabled { cursor: default; }
.score-btn.on.s0 { background: var(--s0-bg); border-color: var(--s0); color: var(--s0); }
.score-btn.on.s1 { background: var(--s1-bg); border-color: var(--s1); color: var(--s1); }
.score-btn.on.s2 { background: var(--s2-bg); border-color: var(--s2); color: var(--s2); }
.score-btn.on.s3 { background: var(--s3-bg); border-color: var(--s3); color: var(--s3); }
.score-btn.on.s4 { background: var(--s4-bg); border-color: var(--s4); color: var(--s4); }
.score-btn.on.na { background: var(--soft); border-color: var(--ink-2); }
.score-btn.on .l { color: inherit; }

.cp-tools { display: flex; gap: 8px; margin: 10px 0 0; flex-wrap: wrap; }
.cp-notes { margin: 10px 0 0; }
.hint { font-size: 13px; color: var(--s1); margin: 6px 0 0; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.thumb {
  width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: var(--soft); padding: 0; cursor: pointer; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.pending::after {
  content: "waiting"; position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px;
  background: rgba(0,0,0,0.55); color: #fff; text-align: center; padding: 2px 0;
}
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.cp-actions { margin: 10px 0 0; }
.mini-action {
  display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 8px 10px;
  background: var(--soft); border-radius: 10px; margin: 0 0 6px;
}
.action-form { background: var(--soft); border-radius: 12px; padding: 12px; margin: 10px 0 0; }

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.footer-bar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.footer-bar .status { font-size: 14px; color: var(--ink-2); flex: 1; min-width: 0; }

/* ---------- Report ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.grid th { font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
.finding { padding: 10px 0; border-top: 1px solid var(--line); }
.finding:first-child { border-top: 0; }
.finding .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.finding .notes { color: var(--ink-2); font-size: 14px; margin: 4px 0 0; white-space: pre-wrap; }

/* ---------- Actions ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; align-items: center; }
.filter-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.filter-btn.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.filters .select { width: auto; min-height: 38px; padding: 6px 10px; font-size: 14px; }
.action-card .top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 6px; }
.action-card .finding-text { font-weight: 600; margin: 4px 0; white-space: pre-wrap; }
.action-card .facts { font-size: 13px; color: var(--ink-2); display: flex; gap: 12px; flex-wrap: wrap; }
.overdue { color: var(--s0); font-weight: 700; }
.action-card .status-select { width: auto; min-height: 38px; padding: 4px 8px; font-size: 14px; }

/* ---------- Dashboard ---------- */
table.dash { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 900px; width: 100%; }
table.dash th, table.dash td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.dash th { font-size: 11px; color: var(--ink-3); text-transform: uppercase; }
table.dash td.prop, table.dash th.prop {
  text-align: left; position: sticky; left: 0; background: var(--card); z-index: 1;
  font-weight: 700; min-width: 150px;
}
table.dash td.prop .sub { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.cell { display: inline-block; min-width: 46px; padding: 4px 6px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.cell.band-Outstanding { background: var(--s4-bg); }
.cell.band-Good { background: var(--s3-bg); color: var(--s3); }
.cell.band-Improvement { background: var(--s2-bg); }
.cell.band-Poor { background: var(--s1-bg); }
.cell.band-Critical, .cell.band-CRITICAL { background: var(--s0-bg); }
.cell.draft { background: var(--soft); color: var(--ink-3); font-weight: 600; }
.cell-empty { display: inline-block; width: 46px; height: 24px; border-radius: 8px; border: 1px dashed var(--line); }
table.grid.key td { vertical-align: middle; }
.nowrap { white-space: nowrap; }

/* ---------- Resume ---------- */
.resume-card { border-color: var(--brand); border-width: 2px; }
.resume-card h3 { margin: 4px 0 10px; }
.resume-card progress { margin: 0 0 6px; }

/* ---------- Edit history ---------- */
.history-day { font-size: 15px; color: var(--ink-2); }
.history { padding: 4px 14px; }
.event { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event-time { min-width: 44px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.event-body { min-width: 0; flex: 1; }
.event-title { line-height: 1.35; }
.event-line { font-size: 14px; margin: 4px 0 0; }
.diff-toggle { margin: 4px 0 0; }
.diff-toggle summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 0; }
@media (max-width: 520px) { .diff { grid-template-columns: 1fr; } }
.diff-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--ink-3); margin: 0 0 2px; }
.diff-text { background: var(--soft); border-radius: 8px; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }

/* ---------- People ---------- */
.radio, .check { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 15px; line-height: 1.35; cursor: pointer; }
.radio input, .check input { margin: 3px 0 0; width: 18px; height: 18px; flex-shrink: 0; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 6px 0 0; }
@media (max-width: 480px) { .check-grid { grid-template-columns: 1fr; } }
.person-card .row { align-items: flex-start; }

/* ---------- Sign-in ---------- */
.signin { text-align: center; padding: 40px 8px; }
.signin img { height: 120px; width: auto; margin: 0 auto 16px; display: block; border-radius: 24px; }

/* ---------- Lightbox and toast ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: calc(100% - 80px); object-fit: contain; border-radius: 8px; }
.lightbox-bar { display: flex; gap: 10px; margin: 12px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--card); padding: 12px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.toast.bad { background: var(--s0); color: #fff; }

/* ---------- Print: the report as a document ---------- */
@media print {
  .topbar, .banner, .footer-bar, .no-print, .toast { display: none !important; }
  body, .page { background: #fff; color: #000; }
  .page { max-width: none; padding: 0; }
  .card { border-color: #ccc; break-inside: avoid; }
}
