/* Primo Forms - Inspection Portal theme (Bootstrap 5.3) */
:root {
  --brand: #c32126;
  --brand-dark: #a01a1f;
  --brand-soft: #fbeaea;
  --ink: #141414;
  --ink-2: #2b2b2b;
  --muted: #6b6f76;
  --line: #e4e5e8;
  --surface: #f4f4f5;

  --bs-primary: #c32126;
  --bs-primary-rgb: 195, 33, 38;
  --bs-primary-text-emphasis: #7d1518;
  --bs-primary-bg-subtle: #fbeaea;
  --bs-primary-border-subtle: #efb9bb;
  --bs-link-color: #c32126;
  --bs-link-color-rgb: 195, 33, 38;
  --bs-link-hover-color: #a01a1f;
  --bs-link-hover-color-rgb: 160, 26, 31;
  --bs-body-color: #1d1d1f;
  --bs-body-bg: #f4f4f5;
  --bs-border-color: #e4e5e8;
  --bs-border-radius: .625rem;
  --bs-border-radius-lg: .875rem;
  --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 4rem;
}

body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.min-w-0 { min-width: 0; }
.narrow { max-width: 760px; margin-inline: auto; }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---- Buttons / form controls in brand colours ---- */
.btn { --bs-btn-font-weight: 600; }
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: #8c171b; --bs-btn-active-border-color: #8c171b;
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  --bs-btn-focus-shadow-rgb: 195, 33, 38;
}
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); }
.btn-lg { --bs-btn-padding-y: .75rem; --bs-btn-font-size: 1.0625rem; }
.btn-icon { width: 2.75rem; height: 2.75rem; padding: 0; display: inline-grid; place-items: center; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(195, 33, 38, .18);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.progress { --bs-progress-height: .625rem; --bs-progress-bg: #e3e4e7; --bs-progress-bar-bg: var(--brand); border-radius: 99px; }
.progress-thin { --bs-progress-height: .4rem; }
.badge-soft-primary { background: var(--brand-soft); color: var(--brand-dark); }
.badge-soft-success { background: #e3f4ea; color: #146c43; }
.card { --bs-card-border-color: var(--line); --bs-card-border-radius: .875rem; }
.dropdown-item:active { background: var(--ink); }

/* ---- Top navigation ---- */
.app-navbar { background: var(--ink); border-bottom: 3px solid var(--brand); padding-block: .6rem; }
.app-navbar .navbar-brand { font-weight: 700; letter-spacing: -.01em; }
.app-navbar .nav-link { font-weight: 600; padding-inline: .9rem !important; border-radius: .5rem; }
.app-navbar .nav-link.active { background: rgba(255, 255, 255, .12); }
.brand-mark { width: 2.1rem; height: 2.1rem; border-radius: .6rem; background: var(--brand); color: #fff; display: inline-grid; place-items: center; }
.brand-mark-lg { width: 3.5rem; height: 3.5rem; border-radius: 1rem; font-size: 1.6rem; }
.avatar-btn { width: 2.6rem; height: 2.6rem; border-radius: 50%; padding: 0; background: #333; color: #fff; font-weight: 700; font-size: .85rem; border: 0; }
.avatar-btn:hover, .avatar-btn:focus-visible { background: #444; color: #fff; }

.app-main { padding-top: 1.5rem; padding-bottom: calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .app-main { padding-bottom: 3rem; } }

/* ---- Bottom tab bar (phones) ---- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 1030; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: .6875rem; font-weight: 600;
}
.tabbar a i { font-size: 1.3rem; line-height: 1; }
.tabbar a.active { color: var(--brand); }
.tabbar-fab { width: 2.6rem; height: 2.6rem; margin-top: -1.1rem; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(195, 33, 38, .4); }
.tabbar-fab i { font-size: 1.25rem !important; }
.tabbar-badge { position: absolute; top: .45rem; left: calc(50% + .45rem); min-width: 1.1rem; padding: 0 .3rem; border-radius: 99px; background: var(--brand); color: #fff; font-size: .65rem; font-style: normal; line-height: 1.1rem; text-align: center; }

/* ---- Shared page pieces ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .75rem; color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none; }
.back-link:hover { color: var(--ink); }
.empty-state { text-align: center; padding: 2.25rem 1rem; color: var(--muted); background: #fff; border: 1px dashed #cfd1d6; border-radius: .875rem; }
.empty-state i { display: block; font-size: 2rem; margin-bottom: .5rem; color: #b3b6bc; }
.list-card { overflow: hidden; }
.list-card .list-group-item { padding: .9rem 1rem; }
.search-box { position: relative; min-width: min(100%, 16rem); }
.search-box i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .form-control { padding-left: 2.5rem; }

.stat-tile {
  display: flex; flex-direction: column; height: 100%; padding: 1rem 1.1rem; background: #fff; border: 1px solid var(--line);
  border-radius: .875rem; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
a.stat-tile:hover { border-color: #c9cbd1; box-shadow: 0 4px 14px rgba(0, 0, 0, .06); }
.stat-icon { width: 2.25rem; height: 2.25rem; border-radius: .6rem; background: var(--surface); color: var(--ink-2); display: grid; place-items: center; font-size: 1.05rem; margin-bottom: .75rem; }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-label { margin-top: .35rem; font-size: .8125rem; color: var(--muted); }
.stat-tile-accent { border-color: var(--bs-primary-border-subtle); background: var(--brand-soft); }
.stat-tile-accent .stat-icon { background: var(--brand); color: #fff; }
.stat-tile-accent .stat-value { color: var(--brand-dark); }

.insp-card, .store-card { transition: box-shadow .15s, transform .15s; }
.insp-card:hover, .store-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.insp-card { border-left: 4px solid var(--brand); }

.rate-ring {
  flex: 0 0 auto; width: 2.9rem; height: 2.9rem; border-radius: 50%; display: grid; place-items: center; grid-auto-flow: column;
  font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; border: 3px solid; background: #fff; color: var(--ink);
}
.rate-ring small { font-size: .6rem; font-weight: 700; margin-left: 1px; }
.rate-success { border-color: #198754; }
.rate-warning { border-color: #e0a800; }
.rate-danger { border-color: var(--brand); }
.rate-secondary { border-color: #d5d7db; color: var(--muted); }
.rate-open { border-color: var(--ink); border-style: dashed; }
.rate-num { min-width: 2.6rem; text-align: right; font-variant-numeric: tabular-nums; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.mini-stats > div { background: var(--surface); border-radius: .6rem; padding: .5rem .6rem; }
.mini-stats dt { font-size: .6875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mini-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.pick-row {
  display: flex; align-items: center; gap: .9rem; width: 100%; min-height: 4.25rem; padding: .8rem 1rem; background: #fff;
  border: 1px solid var(--line); border-radius: .875rem; color: inherit; transition: border-color .15s, box-shadow .15s;
}
.pick-row:hover, .pick-row:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(195, 33, 38, .12); outline: 0; }
.pick-icon { width: 2.6rem; height: 2.6rem; flex: 0 0 auto; border-radius: .7rem; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }

.seg-pills { display: inline-flex; padding: .25rem; background: #e6e7ea; border-radius: .75rem; gap: .25rem; }
.seg-pills .nav-link { color: var(--ink-2); font-weight: 600; border-radius: .55rem; padding: .5rem 1rem; }
.seg-pills .nav-link.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* Pass-rate trend (store page) */
.trend { display: flex; align-items: stretch; gap: .5rem; height: 11rem; }
.trend-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .25rem; text-decoration: none; color: var(--ink); min-width: 0; }
.trend-bar { width: 100%; max-width: 2.25rem; border-radius: .35rem .35rem 0 0; }
.trend-val { font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.trend-lbl { font-size: .6875rem; color: var(--muted); white-space: nowrap; }

/* ---- Sign in ---- */
.login-wrap { min-height: calc(100dvh - 3rem); display: grid; place-items: center; padding-block: 1rem; }
.login-card { width: 100%; max-width: 27rem; border-radius: 1.25rem; overflow: hidden; }
.login-head { background: var(--ink); color: #fff; text-align: center; padding: 2.25rem 1.5rem 2rem; border-bottom: 4px solid var(--brand); }
.login-head h1 { color: #fff; }
.login-wrap .input-group .btn { border-color: var(--bs-border-color); }

/* ---- Inspection form ---- */
.focus-mode .app-navbar { position: static; }
.focus-mode .app-main { padding-top: 0; padding-bottom: 7rem; }
.insp-top {
  position: sticky; top: 0; z-index: 1020; margin-inline: calc(var(--bs-gutter-x) * -.5); padding: .85rem calc(var(--bs-gutter-x) * .5) .6rem;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.insp-body { padding-top: 1.5rem; }
.save-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .65rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e3f4ea; color: #146c43; white-space: nowrap; }
.save-pill[data-state="saving"] { background: var(--surface); color: var(--muted); }
.save-pill[data-state="saving"] i { animation: spin 1s linear infinite; display: inline-block; }
.save-pill[data-state="offline"] { background: var(--brand-soft); color: var(--brand-dark); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 420px) { .save-pill span { display: none; } }

.step-pills { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: .15rem; }
.step-pills::-webkit-scrollbar { display: none; }
.step-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .4rem; min-height: 2.4rem; padding: .35rem .8rem; border-radius: 99px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.step-pill em { font-style: normal; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.step-pill.done em { color: #198754; }
.step-pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.step-pill.active em { color: rgba(255, 255, 255, .7); }
.step-pill.active.done em { color: #7ee2a8; }
.step-icon { width: 3rem; height: 3rem; flex: 0 0 auto; border-radius: .85rem; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.35rem; }

.q-card { margin-bottom: .85rem; scroll-margin-top: 11rem; transition: box-shadow .3s, border-color .3s; }
.q-card.q-attention { border-color: var(--brand); box-shadow: 0 0 0 .25rem rgba(195, 33, 38, .2); }
.q-num { flex: 0 0 auto; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--surface); color: var(--muted); font-size: .78rem; font-weight: 700; display: grid; place-items: center; margin-top: .1rem; }
.q-text { font-weight: 600; font-size: 1.02rem; line-height: 1.35; color: var(--ink); }
.q-help { font-size: .875rem; color: var(--muted); margin-top: .2rem; }
.q-optional { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface); padding: .1rem .4rem; border-radius: .3rem; vertical-align: middle; }
.q-answer { margin-top: .9rem; }
.q-number { max-width: 14rem; }

.pf-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.pf-btn { min-height: 3.25rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1.5px solid #d5d7db; background: #fff; color: var(--ink-2); font-size: 1rem; }
.pf-btn:hover { border-color: #9a9da4; background: #fff; color: var(--ink); }
.btn-check:checked + .pf-pass { background: #198754; border-color: #198754; color: #fff; }
.btn-check:checked + .pf-fail { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-check:checked + .pf-na { background: #5c6068; border-color: #5c6068; color: #fff; }
.btn-check:focus-visible + .btn { box-shadow: 0 0 0 .2rem rgba(195, 33, 38, .25); }

.q-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.btn-tool { --bs-btn-padding-y: .45rem; --bs-btn-padding-x: .7rem; --bs-btn-font-size: .84rem; background: var(--surface); border: 1px solid transparent; color: var(--ink-2); min-height: 2.5rem; display: inline-flex; align-items: center; gap: .35rem; }
.btn-tool:hover { background: #e6e7ea; color: var(--ink); }
.btn-tool.active { background: #e6e7ea; border-color: #c9cbd1; color: var(--ink); }
.btn-check:checked + .btn-flag { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.q-comment { margin-top: .6rem; }

.q-photos { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.q-photos:empty { display: none; }
.thumb { position: relative; width: 5rem; height: 5rem; border-radius: .6rem; overflow: hidden; background: var(--surface); display: grid; place-items: center; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb a { display: block; width: 100%; height: 100%; }
.thumb-loading { opacity: .6; }
.thumb-x { position: absolute; top: .2rem; right: .2rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .7); color: #fff; display: grid; place-items: center; padding: 0; font-size: 1rem; }

.insp-bottom {
  position: fixed; inset: auto 0 0 0; z-index: 1025; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
}
.review-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; text-align: center; }
.review-grid > div { background: var(--surface); border-radius: .7rem; padding: .7rem .25rem; }
.review-grid strong { display: block; font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.review-grid span { font-size: .72rem; color: var(--muted); font-weight: 600; }

/* ---- Report ---- */
.report { max-width: 900px; margin-inline: auto; }
.report-head { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: .875rem; padding: 1.25rem; }
.report-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1.1rem; }
@media (min-width: 768px) { .report-stats { grid-template-columns: repeat(6, 1fr); } }
.report-stat { background: var(--surface); border-radius: .7rem; padding: .7rem .5rem; text-align: center; }
.report-stat strong { display: block; font-size: 1.45rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.report-stat span { font-size: .72rem; font-weight: 600; color: var(--muted); }
.report-summary { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.report-section { margin-top: 1.5rem; }
.report-section-title { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.report-section-title i { color: var(--brand); }
.report-q { font-weight: 500; }
.report-item.is-flagged { background: #fffafa; }
.report-note { margin: .4rem 0 0; font-size: .9rem; color: #45484e; }
.answer-badge { font-size: .8rem; padding: .4em .65em; }
.followup-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .6rem; padding: .5rem .75rem; border-radius: .6rem; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; font-size: .875rem; }
.followup-fixed { background: #e3f4ea; color: #146c43; }
.followup-fixed .fw-normal { color: #1d1d1f; }
.issues-only .no-issue { display: none !important; }
.fu-item .btn-success { min-width: 9rem; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; font-size: 11pt; }
  .app-main { padding: 0 !important; max-width: none; }
  .report { max-width: none; }
  .report-head, .card { border-color: #bbb !important; }
  .report-item, .report-section-title { break-inside: avoid; }
  .report-section-title { break-after: avoid; }
  .badge, .report-stat, .followup-bar, .report-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .thumb { width: 8rem; height: 8rem; }
  a { text-decoration: none; color: inherit; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
