/* WRI Reporting — same palette as the technician Power App:
   Wolfe red, charcoal header, light page, white cards. */
:root {
  --red: #C82613;
  --red-dark: #9E1C0C;
  --charcoal: #26292E;
  --page: #F2F3F5;
  --card: #FFFFFF;
  --text: #1E2126;
  --muted: #646A73;
  --border: #DEE0E4;
  --ok: #228B54;
  --warn: #E6961E;
  --radius: 12px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, p { margin: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ── Top bar & navigation ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--charcoal); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .75; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user { font-size: 14px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }

.nav {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 var(--gutter); background: var(--charcoal);
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.nav-link {
  padding: 12px 14px; color: rgba(255, 255, 255, .75); text-decoration: none; font-weight: 600; font-size: 15px;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.nav-link:hover { color: #fff; }
.nav-link.active { color: #fff; border-bottom-color: var(--red); }

.content { max-width: 1200px; margin: 0 auto; padding: 20px var(--gutter) calc(40px + env(safe-area-inset-bottom)); outline: none; }

/* ── Buttons & inputs ─────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  border: 0; border-radius: 10px; padding: 10px 16px; min-height: 44px;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid rgba(255, 255, 255, .35); padding: 8px 12px; min-height: 38px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.btn-block { width: 100%; }
.btn[hidden] { display: none; }

.input {
  font: inherit; font-size: 16px; /* 16px stops iPhone zooming in on focus */
  width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text);
}
.input:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }

/* ── Page & cards ─────────────────────────────────────────────────────── */
.page-head { margin-bottom: 16px; }
.page-title { font-size: 26px; font-weight: 700; color: var(--charcoal); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--page); color: var(--charcoal); border: 1px solid var(--border); white-space: nowrap;
}
.chip-submitted { background: #E6F4EC; color: var(--ok); border-color: #BFE3CD; }
.chip-reviewed { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.chip-draft, .chip-requested { background: #FDF3E3; color: #9A5B00; border-color: #F4D9A8; }

.chip-pending-acceptance { background: var(--red); color: #fff; border-color: var(--red); }
.chip-accepted, .chip-scheduled { background: #EAF1FB; color: #1F5FAD; border-color: #C5D8F2; }
.chip-in-progress { background: #FDF3E3; color: #9A5B00; border-color: #F4D9A8; }
.chip-waiting-on-parts { background: #F3EAFB; color: #6B2FA6; border-color: #DCC7F0; }
.chip-resolved { background: #E6F4EC; color: var(--ok); border-color: #BFE3CD; }
.chip-dismissed { background: var(--page); color: var(--muted); border-color: var(--border); text-decoration: line-through; }
.chip-needs-review { background: var(--red); color: #fff; border-color: var(--red); }

/* Review queue banner */
.queue { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-left: 6px solid var(--red); }
.queue-count { font-size: 24px; color: var(--red); }
.queue-clear { border-left-color: var(--ok); display: block; }

/* ── Activity log dialog ──────────────────────────────────────────────── */
.head-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.dialog-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(20, 22, 25, .55); display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: var(--card); width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dialog-title { font-size: 20px; color: var(--charcoal); }
.notice { background: #FDF3E3; border: 1px solid #F4D9A8; color: #7A4A00; border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.timeline.activity li { border-left-color: var(--red); }
.timeline.activity li.missing { border-left-color: var(--border); opacity: .7; }
.timeline.activity p { margin: 2px 0 0; }
@media (min-width: 720px) {
  .dialog-overlay { align-items: center; }
  .dialog { border-radius: 16px; }
}

/* ── Maintenance ─────────────────────────────────────────────────────── */
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-head-row .btn { text-decoration: none; display: inline-flex; align-items: center; }
.stats.stats-4 { grid-template-columns: repeat(2, 1fr); margin: 0; }
.stat-btn { font: inherit; border: 2px solid transparent; cursor: pointer; }
.stat-btn:hover { border-color: var(--border); }
.issue-row { border-left: 6px solid var(--muted); }
.issue-row.priority-high { border-left-color: var(--red); }
.issue-row.priority-medium { border-left-color: var(--warn); }
.issue-link { display: block; text-decoration: none; }
.issue-link:hover { background: #E9EBEE; }
.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field[hidden] { display: none; }
.pre { white-space: pre-wrap; margin: 10px 0; }
.resolution { background: #E6F4EC; border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--border); padding: 4px 0 10px 12px; margin-left: 4px; }
.timeline-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.btn-ghost-dark { background: transparent; color: var(--charcoal); border: 1px solid var(--border); }
.btn-ghost-dark:hover { border-color: var(--charcoal); }
.edit-card summary { cursor: pointer; margin: 0; }
.edit-card[open] summary { margin-bottom: 12px; }
.form-card { max-width: 640px; }

/* ── Home: module cards ───────────────────────────────────────────────── */
.module-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.module { display: flex; flex-direction: column; gap: 8px; text-decoration: none; margin: 0; }
.module .card-title { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--charcoal); margin: 0; }
.module-go { margin-top: auto; color: var(--red); font-weight: 700; }
a.module:hover { border-color: var(--red); }
.module-planned { opacity: .7; }
.module-planned .chip { align-self: flex-start; }

/* ── Report list ──────────────────────────────────────────────────────── */
.summary-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 8px; }
.stat { background: var(--page); border-radius: 10px; padding: 10px; text-align: center; }
.stat-value { display: block; font-size: 26px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-ok .stat-value { color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.stat-bad .stat-value { color: var(--red); }

.toolbar { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 12px; }
.select { display: block; }

.report-list { display: flex; flex-direction: column; gap: 8px; }
.report-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; box-shadow: var(--shadow);
}
.report-row:hover { border-color: var(--red); }
.report-main { display: flex; flex-direction: column; min-width: 0; }
.report-van { font-weight: 700; font-size: 17px; }
.report-tech { color: var(--muted); font-size: 14px; }
.report-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.rating { color: var(--charcoal); font-weight: 600; }

/* ── Report detail ────────────────────────────────────────────────────── */
.back { display: inline-block; margin-bottom: 12px; color: var(--red); font-weight: 600; text-decoration: none; padding: 6px 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.detail-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.fact dt { font-size: 13px; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-weight: 600; }

.checklist { list-style: none; margin: 0; padding: 0; }
.check { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--page); }
.check:last-child { border-bottom: 0; }
.check-result { font-weight: 700; font-size: 14px; }
.check-pass .check-result { color: var(--ok); }
.check-attention .check-result { color: var(--warn); }
.check-fail .check-result { color: var(--red); }

.issue { border-left: 4px solid var(--muted); padding: 8px 12px; background: var(--page); border-radius: 0 10px 10px 0; margin-bottom: 8px; }
.issue-high { border-left-color: var(--red); }
.issue-medium { border-left-color: var(--warn); }
.issue-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

.photo-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.photo {
  position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in;
  aspect-ratio: 4 / 3; background: var(--page);
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; text-align: left;
  font: 600 13px var(--font); color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .65));
}
.photo-error { cursor: default; }

.lightbox {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(20, 22, 25, .92); padding: 16px; cursor: zoom-out;
}
.lightbox img { max-height: 85vh; border-radius: 8px; }
.lightbox p { color: #fff; }

.rating-picker { display: flex; gap: 8px; margin: 8px 0; }
.rating-btn {
  flex: 1; min-height: 48px; font: 700 18px var(--font); border-radius: 10px;
  border: 2px solid var(--border); background: var(--page); color: var(--charcoal);
}
.rating-btn { cursor: pointer; }
.rating-btn:hover { border-color: var(--charcoal); }
.rating-btn.selected { background: var(--red); border-color: var(--red); color: #fff; }
.rating-meaning { min-height: 1.4em; margin-bottom: 10px; }
.notes { resize: vertical; margin-bottom: 10px; min-height: 80px; }
.reviewed-by { font-weight: 600; margin-bottom: 4px; }
.error-text { color: var(--red); margin-top: 8px; }

/* ── Loading / error states & sign-in ─────────────────────────────────── */
.state { padding: 32px 16px; text-align: center; color: var(--muted); }
.state-error { background: #FBEAE7; border: 1px solid #F1C3BB; border-radius: var(--radius); color: var(--red-dark); }
.state-title { font-weight: 700; margin-bottom: 4px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 10px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--red); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); background: var(--charcoal); }
.signin-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); }
.signin-card .brand { color: var(--charcoal); margin-bottom: 24px; }
.signin-card h1 { font-size: 22px; margin-bottom: 6px; }
.signin-card p { margin-bottom: 20px; }

/* ── Wider screens: office PC ─────────────────────────────────────────── */
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .toolbar { grid-template-columns: 2fr 1fr 1fr; }
  .facts { grid-template-columns: repeat(4, 1fr); }
  .stats.stats-4 { grid-template-columns: repeat(4, 1fr); }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) {
  .detail-grid { grid-template-columns: 1.1fr 1fr; }
}
@media (max-width: 520px) {
  .user { display: none; }
  .brand-sub { display: none; }
}
