:root {
  color-scheme: light;
  --bg: #f2f3f5;
  --surface: #fff;
  --text: #17212d;
  --accent: #2f6fed;
  --accent-text: #fff;
  --success: #1f7a4d;
  --warning: #8a5a00;
  --danger: #b3362f;
  /* Telegram's hint colours are too faint for body copy, so secondary text derives from the text colour. */
  --muted: color-mix(in srgb, var(--text) 64%, var(--surface));
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --fill: color-mix(in srgb, var(--text) 6%, transparent);
  --soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171d;
  --surface: #20252d;
  --text: #f3f5f8;
  --accent: #6ea0ff;
  --success: #6fcf9f;
  --warning: #f0c060;
  --danger: #ff9a92;
  --muted: color-mix(in srgb, var(--text) 68%, var(--surface));
  --line: color-mix(in srgb, var(--text) 14%, transparent);
  --fill: color-mix(in srgb, var(--text) 9%, transparent);
  --soft: color-mix(in srgb, var(--accent) 20%, var(--surface));
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, h5, h6, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; touch-action: manipulation; -webkit-appearance: none; }
button:disabled { cursor: default; opacity: .5; }
button, input, a { outline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); }
button:active:not(:disabled) { transform: scale(.985); }
.icon { display: inline-flex; flex: none; }
.icon svg { width: 20px; height: 20px; display: block; }
[hidden] { display: none !important; }

.app { max-width: 640px; margin: 0 auto; padding: max(16px, var(--tg-content-safe-area-inset-top, 0px)) max(16px, var(--tg-content-safe-area-inset-right, 0px)) max(32px, var(--tg-content-safe-area-inset-bottom, 0px)) max(16px, var(--tg-content-safe-area-inset-left, 0px)); min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100dvh); }

/* Buttons */
.primary-button, .secondary-button, .tinted-button { border: 0; min-height: 50px; border-radius: 14px; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 12px 18px; font-size: 16px; font-weight: 600; width: 100%; transition: opacity .15s, transform .1s; }
.primary-button { background: var(--accent); color: var(--accent-text); }
.secondary-button { background: var(--soft); color: var(--accent); }
.tinted-button { min-height: 46px; padding: 10px 12px; font-size: 15px; background: var(--fill); color: var(--text); border-radius: 12px; }
.tinted-button.accent { background: var(--soft); color: var(--accent); }
.tinted-button .icon svg { width: 18px; height: 18px; }
.danger-button { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
/* Irreversible: the only filled danger control. --surface keeps its label legible in both themes. */
.danger-solid { background: var(--danger); color: var(--surface); }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 16px; font-weight: 600; padding: 10px 6px; min-height: 44px; border-radius: 10px; }
.icon-button { background: transparent; border: 0; border-radius: 50%; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--muted); }
.icon-button:hover { background: var(--fill); }
.icon-button .icon svg { width: 22px; height: 22px; }

/* Home */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.page-header h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.4px; }
.list-section { margin-top: 20px; }
.list-section + .list-section { margin-top: 10px; }
.section-heading { margin: 0 -6px 4px; }
.section-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 10px; background: none; font-size: 15px; font-weight: 600; color: var(--muted); text-align: left; }
.section-toggle .count { font-weight: 500; }
.section-toggle .chevron { margin-left: auto; }
.section-toggle .chevron svg { width: 18px; height: 18px; transition: transform .15s; }
.section-toggle[aria-expanded="false"] .chevron svg { transform: rotate(-90deg); }
.section-hint { margin: 0 2px 12px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.search { position: relative; margin-bottom: 12px; }
.search .icon { position: absolute; top: 14px; left: 14px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; border: 1.5px solid transparent; background: var(--surface); color: var(--text); height: 48px; border-radius: 12px; padding: 0 14px 0 44px; font-size: 16px; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { border-color: var(--accent); outline: none; }
.session-list { display: grid; gap: 12px; }
.loading-list { margin-top: 26px; }
.session-card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 26px; }
.card-updated, .survey-ref { font-size: 14px; color: var(--muted); }
.card-title { font-size: 18px; line-height: 1.3; font-weight: 650; margin-top: 8px; overflow-wrap: anywhere; }
.card-title + .survey-ref { margin-top: 2px; }
/* Swipe left: the card slides off its one action, which waits underneath at the right edge. */
.swipe-row { position: relative; overflow: hidden; border-radius: var(--radius); }
.swipe-row .session-card { position: relative; z-index: 1; touch-action: pan-y; transition: transform .2s ease; }
.swipe-row.dragging .session-card { transition: none; user-select: none; -webkit-user-select: none; }
.swipe-action { position: absolute; top: 0; right: 0; bottom: 0; width: 88px; border: 0; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; transition: filter .15s; }
.swipe-action.archive { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.swipe-action.delete { color: var(--surface); background: var(--danger); }
.swipe-action .icon svg { width: 22px; height: 22px; }
/* Covered while closed; fully hidden so no edge of it shows around the card's corners. */
.swipe-row:not(.open) .swipe-action { opacity: 0; }
.swipe-action:focus-visible { outline-offset: -3px; }
/* Swiped far enough that letting go runs the action. */
.swipe-row.full .swipe-action { filter: brightness(1.12) saturate(1.2); }
.card-notice { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14px; line-height: 1.45; color: var(--warning); }
.card-notice .icon { margin-top: 1px; }
.card-notice .icon svg { width: 18px; height: 18px; }
.card-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; line-height: 1; padding: 6px 10px; border-radius: 999px; white-space: nowrap; background: var(--fill); color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.success { color: var(--success); background: color-mix(in srgb, var(--success) 13%, var(--surface)); }
.pill.accent { color: var(--accent); background: var(--soft); }
.pill.warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, var(--surface)); }
.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; background: var(--soft); color: var(--text); margin-top: 12px; }
.notice .icon { color: var(--accent); margin-top: 1px; }
.notice strong { display: block; font-weight: 650; }
.empty-state { text-align: center; padding: 36px 20px 28px; color: var(--muted); }
.empty-state .empty-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; background: var(--fill); color: var(--muted); margin: 0 auto 16px; }
.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state h2 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 15px; line-height: 1.5; max-width: 300px; margin: 0 auto; }
.initial-loading { min-height: 65vh; display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); font-size: 15px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, color-mix(in srgb, var(--text) 5%, var(--surface)) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease infinite; height: 152px; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-panel { border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-radius: 14px; padding: 14px 16px 6px; margin-top: 14px; }
.error-panel p { font-size: 15px; line-height: 1.5; }
.error-panel .text-button { margin-left: -6px; }

/* Sheets */
.sheet { color: var(--text); background: var(--surface); border: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -12px 80px #0003; padding: 24px 20px max(24px, env(safe-area-inset-bottom)); margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; }
.sheet[open] { animation: slide-up .2s ease-out; }
.sheet::backdrop { background: #0717268c; }
@keyframes slide-up { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.sheet .close-sheet { position: absolute; top: 12px; right: 12px; }
.sheet-symbol { background: var(--soft); color: var(--accent); border-radius: 14px; width: 48px; height: 48px; display: grid; place-items: center; margin: 0 0 16px; }
.sheet-symbol svg { width: 24px; height: 24px; }
.sheet-symbol.success-symbol { background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success); }
.sheet-symbol.danger-symbol { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.sheet h2 { font-size: 22px; line-height: 1.25; letter-spacing: -.3px; padding-right: 36px; }
.sheet-description { color: var(--muted); font-size: 16px; line-height: 1.5; margin-top: 8px; }
.survey-form { margin-top: 22px; }
.field-label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.survey-input { width: 100%; height: 56px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); padding: 0 16px; color: var(--text); font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.survey-input::placeholder { font-weight: 400; letter-spacing: 0; color: var(--muted); opacity: .75; }
.survey-input:focus { border-color: var(--accent); outline: none; }
.survey-input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 15px; line-height: 1.45; margin: 10px 0 0; }
.form-helper { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 10px 0 20px; }
.pending-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--fill); margin: 16px 0 0; font-size: 15px; line-height: 1.5; color: var(--text); }
.pending-note .icon { color: var(--muted); margin-top: 1px; }
.sheet-actions { margin-top: 20px; display: grid; gap: 6px; }
.sheet-actions .text-button { width: 100%; }
.ready-card { margin-top: 18px; background: var(--fill); padding: 14px 16px; border-radius: 14px; }
.ready-card .card-title { margin-top: 0; }
/* Warnings open as a popup in the middle of the screen rather than a sheet. */
.sheet.popup { margin: auto; width: calc(100% - 48px); max-width: 340px; border-radius: 22px; padding: 24px 20px 12px; text-align: center; box-shadow: 0 18px 80px #0006; }
.sheet.popup[open] { animation: pop-in .18s ease-out; }
@keyframes pop-in { from { transform: scale(.94); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.sheet.popup .sheet-symbol { margin: 0 auto 14px; }
.sheet.popup h2 { font-size: 20px; padding-right: 0; }
.sheet.popup .sheet-description { font-size: 15px; }
.sheet.popup .pending-note { text-align: left; }

/* Inspection detail */
.detail-nav { margin: -6px 0 6px; }
.back-button { display: inline-flex; align-items: center; gap: 2px; margin-left: -10px; }
.back-button .icon svg { width: 22px; height: 22px; }
.detail-heading h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.3px; margin: 10px 0 2px; overflow-wrap: anywhere; }
.detail-heading .survey-ref { font-size: 15px; }
.detail-heading .primary-button { margin-top: 16px; }
.fill-card { margin-top: 12px; padding: 16px; background: var(--surface); border-radius: var(--radius); }
.fill-main { display: flex; align-items: center; gap: 14px; }
.fill-copy { flex: 1; min-width: 0; }
.fill-copy h2 { font-size: 17px; font-weight: 650; line-height: 1.3; }
.fill-copy p { font-size: 14px; line-height: 1.45; color: var(--muted); margin-top: 2px; }
.fill-main .secondary-button { width: auto; min-height: 44px; padding: 10px 16px; font-size: 15px; border-radius: 12px; flex: none; }
.fill-card .notice { margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--line); border-radius: 0; background: none; color: var(--muted); }
.fill-card .notice strong { display: inline; color: var(--text); margin-right: 4px; }
.fill-card .notice .icon { color: var(--muted); }
.fill-card .notice .icon svg { width: 18px; height: 18px; }
.fill-main .cancel-fill { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.action-state { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 15px; line-height: 1.45; background: var(--fill); color: var(--text); }
.action-state .icon, .action-state .spinner { margin-top: 2px; color: var(--muted); }
.action-state.success { background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.action-state.success .icon { color: var(--success); }
.action-state.error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.action-state.error .icon { color: var(--danger); }
.tabs { position: sticky; top: var(--tg-content-safe-area-inset-top, 0px); z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 20px -4px 0; padding: 8px 4px; background: var(--bg); }
.tabs::before { content: ""; position: absolute; inset: 8px 4px; border-radius: 12px; background: var(--fill); pointer-events: none; }
.tab { position: relative; background: none; border: 0; min-height: 44px; border-radius: 10px; margin: 3px; color: var(--muted); font-size: 15px; font-weight: 600; }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px #0000001f; }
:root[data-theme="dark"] .tab[aria-selected="true"] { background: color-mix(in srgb, var(--text) 20%, var(--surface)); }

/* Notes and report */
.document { padding: 8px 0 0; overflow-wrap: anywhere; font-size: 16px; line-height: 1.55; }
.document:focus-visible { outline-offset: 6px; border-radius: 8px; }
.doc-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 2px 12px; }
.doc-title h2 { font-size: 18px; font-weight: 650; line-height: 1.3; }
.doc-title span { font-size: 14px; color: var(--muted); white-space: nowrap; }
.doc-card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.doc-card > :first-child, .doc-lead > :first-child { margin-top: 0; }
.doc-card > :last-child, .doc-lead > :last-child { margin-bottom: 0; }
.doc-lead { margin: 4px 2px 14px; }
.document h2, .document h3, .document h4, .document h5, .document h6 { line-height: 1.3; font-weight: 650; }
.prose h2 { font-size: 20px; margin: 20px 0 8px; }
.prose h3 { font-size: 18px; margin: 20px 0 8px; }
.prose h4, .prose h5, .prose h6 { font-size: 16px; margin: 16px 0 6px; }
.doc-card.prose > h3:first-child { margin-bottom: 10px; }
.prose p { margin: 0 0 12px; white-space: pre-line; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 12px; }
.prose li { margin-bottom: 6px; padding-left: 2px; }
.prose li:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.status-card h3 { font-size: 15px; font-weight: 650; margin-bottom: 6px; }
.status-card p { font-size: 15px; line-height: 1.45; }
.status-card summary { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: -10px; font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer; }
.status-card ul { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.status-card li + li { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.report-section > h3 { font-size: 18px; }
/* Page, section, subsection: each level is smaller and quieter than the one above it. */
.report-section h4 { font-size: 16px; font-weight: 700; color: var(--text); margin: 20px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--fill); }
.report-section h5 { font-size: 15px; font-weight: 700; color: var(--text); margin: 16px 0 0; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.report-section h6 { font-size: 14px; font-weight: 700; color: var(--muted); margin: 14px 0 0; }
.report-section > h3 + h4, .report-section > h4 + h5, .report-section > h5 + h6 { margin-top: 12px; }
.qa { padding: 12px 0; border-bottom: 1px solid var(--line); }
.qa:last-child { border-bottom: 0; padding-bottom: 0; }
.qa:has(+ h4, + h5, + h6) { border-bottom: 0; }
.qa-label { font-size: 14px; line-height: 1.4; font-weight: 600; color: var(--muted); }
.qa-value { margin-top: 3px; font-size: 16px; line-height: 1.5; white-space: pre-line; }
.qa-value.blank { color: var(--muted); }
.footnotes { margin: 16px 2px 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.footnotes p + p { margin-top: 6px; }
.loading-note { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 32px 0; color: var(--muted); font-size: 15px; }

.toast { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; background: var(--text); color: var(--surface); border-radius: 12px; font-size: 15px; line-height: 1.45; z-index: 10; box-shadow: 0 6px 30px #0003; pointer-events: none; }
.locked { max-width: 340px; margin: 15vh auto 0; }
.locked h1 { font-size: 24px; letter-spacing: -.3px; margin-bottom: 10px; color: var(--text); }
.locked p { font-size: 16px; }
.noscript { padding: 24px; text-align: center; }
@media (min-width: 580px) {
  .app { padding-top: 28px; padding-left: 24px; padding-right: 24px; }
  .sheet { border-radius: 22px; margin-bottom: max(24px, env(safe-area-inset-bottom)); max-width: 460px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
#tabs-anchor { scroll-margin-top: var(--tg-content-safe-area-inset-top, 0px); }
