/* HitchCheck — plain CSS, no external requests. Theme colours from SPEC §0. */
:root {
  color-scheme: light dark;
  --bg: #f7f5ef; --surface: #fffdf8; --surface-alt: #efece2;
  --text: #17211b; --dim: #5c665e; --border: #d8d4c6;
  --accent: #00703c; --accent-ink: #ffffff;
  --warn: #b45309; --warn-bg: #fdf3e0;
  --fail: #b91c1c; --fail-bg: #fbe9e7; --pass-bg: #e3f2e8;
  --scan-blue: #2f7bff; --radius: 10px;
  --font: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12160f; --surface: #1b211a; --surface-alt: #242b22;
    --text: #eef2ea; --dim: #a3ada0; --border: #39412f;
    --accent: #35b06f; --accent-ink: #0c140e;
    --warn: #e8a34c; --warn-bg: #3a2c14;
    --fail: #f08080; --fail-bg: #3a1a18; --pass-bg: #1d3a28;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 17px; line-height: 1.45; -webkit-text-size-adjust: 100%;
}
main { max-width: 768px; margin: 0 auto; padding: 0 14px 48px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.35rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; margin-top: 1.2em; }
p { margin: .35em 0 .7em; }
.dim { color: var(--dim); }
.small { font-size: .9rem; }
a { color: var(--accent); }
button { font-family: inherit; font-size: 1rem; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55em .7em; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input:disabled, select:disabled, button:disabled { opacity: .55; cursor: not-allowed; }
label { display: block; font-weight: 600; margin: .8em 0 .25em; }
.hint { color: var(--dim); font-size: .9rem; margin: .15em 0 .5em; }
.err { color: var(--fail); font-weight: 600; margin: .4em 0; }
.warn-text { color: var(--warn); }
.ok-text { color: var(--accent); }

/* ---------- opening screen ---------- */
#opening { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem 1rem; }
#opening h1 { font-size: 2rem; margin-bottom: .5rem; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 1rem auto; }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header / branding ---------- */
.app-header { text-align: center; padding: 18px 0 4px; }
.logo-card {
  display: inline-block; background: #ffffff; border-radius: 14px;
  padding: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.18); line-height: 0;
}
.logo-card img { width: 132px; height: 132px; border-radius: 8px; display: block; }
.logo-fallback { color: #17211b; font-weight: 700; font-size: 1.25rem; line-height: 1.2; padding: 2.2em .6em; max-width: 200px; }
.app-header h1 { font-size: 2rem; margin: .45em 0 0; }
.app-header .tagline { color: var(--dim); margin-top: .1em; }
.app-header .intro-price { color: var(--accent); font-weight: 700; margin-top: .35em; }
.user-bar { display: flex; justify-content: space-between; align-items: center; gap: .6em; margin-top: .8em; font-size: .92rem; }
.user-bar .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); border-radius: var(--radius); padding: .6em 1.1em;
  font-weight: 600; text-align: center; text-decoration: none;
}
.btn.outline { background: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; }
.btn.danger { background: transparent; border-color: var(--fail); color: var(--fail); }
.btn.small { padding: .35em .7em; font-size: .92rem; }
.btn.scan { background: var(--scan-blue); border-color: var(--scan-blue); color: #fff; }
.btn-row { display: flex; gap: .6em; flex-wrap: wrap; margin: .6em 0; }
.btn-row .btn { flex: 1 1 auto; }
.linklike { background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; text-decoration: underline; }

/* ---------- cards / sections ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: .7em 0; }
.card.alt { background: var(--surface-alt); }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: .1em .55em; border-radius: 999px; background: var(--pass-bg); color: var(--accent); border: 1px solid var(--border); }
.tag.full { background: var(--warn-bg); color: var(--warn); }
.paid-label { color: var(--dim); font-size: .92rem; }

/* verdict */
.verdict { border-radius: var(--radius); padding: 16px; margin: .7em 0; border: 1px solid var(--border); background: var(--surface); }
.verdict.pass { background: var(--pass-bg); border-color: var(--accent); }
.verdict.warn { background: var(--warn-bg); border-color: var(--warn); }
.verdict.fail { background: var(--fail-bg); border-color: var(--fail); }
.verdict .ratio { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.verdict h2 { margin: .15em 0 .3em; font-size: 1.4rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; margin: .7em 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6em .7em; }
.stat .k { color: var(--dim); font-size: .88rem; }
.stat .v { font-weight: 700; }
.stat .v.bad { color: var(--fail); }
.note { margin: .5em 0; }

/* performance stars */
.perf-row { display: flex; justify-content: space-between; align-items: baseline; gap: .8em; padding: .45em 0; border-bottom: 1px solid var(--border); }
.perf-row:last-of-type { border-bottom: none; }
.stars { color: var(--accent); font-size: 1.25rem; letter-spacing: .08em; white-space: nowrap; }
.stars .empty { color: var(--dim); }
.perf-note { color: var(--dim); font-size: .92rem; margin: .1em 0 .6em; }

/* forms */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8em; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.reg-row { display: flex; gap: .6em; }
.reg-row input { text-transform: uppercase; flex: 1; }
.reg-row .btn { flex: 0 0 auto; }
.picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8em; }
@media (max-width: 480px) { .picker-grid { grid-template-columns: 1fr; } }
.picked-box { background: var(--pass-bg); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px; margin: .7em 0; }

/* checklist */
.check-group { font-weight: 700; margin: 1em 0 .3em; }
.check-item { display: flex; gap: .6em; align-items: flex-start; padding: .5em .2em; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-item input { width: 1.3em; height: 1.3em; flex: 0 0 auto; margin-top: .1em; accent-color: var(--accent); }
.check-item.done span { color: var(--dim); text-decoration: line-through; }

/* wallet */
.doc-row { display: flex; gap: .8em; align-items: flex-start; padding: .7em 0; border-bottom: 1px solid var(--border); }
.doc-row:last-child { border-bottom: none; }
.doc-thumb { width: 64px; height: 64px; flex: 0 0 64px; border: 1px solid var(--border); border-radius: 8px; object-fit: cover; background: var(--surface-alt); display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--dim); text-align: center; padding: 4px; }
.doc-body { flex: 1; min-width: 0; }
.doc-body .name { font-weight: 700; }
.doc-body .expired { color: var(--fail); font-weight: 700; }
.doc-actions { display: flex; gap: .45em; flex-wrap: wrap; margin-top: .45em; }

/* diary */
.holiday-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: .8em 0; }
.entry { border-top: 1px solid var(--border); padding: .7em 0; }
.entry .date { font-weight: 700; }
.entry .activities { white-space: pre-wrap; margin: .3em 0; }
.dictate-status { display: flex; gap: .5em; align-items: center; color: var(--fail); font-weight: 600; margin: .4em 0; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fail); animation: pulse 1.2s ease-in-out infinite; flex: 0 0 auto; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .pulse-dot { animation: none; } }

/* reminders */
.rem-row { display: flex; justify-content: space-between; gap: .8em; align-items: flex-start; padding: .6em 0; border-bottom: 1px solid var(--border); }
.rem-row:last-child { border-bottom: none; }
.rem-due { font-weight: 700; white-space: nowrap; }
.rem-due.overdue { color: var(--fail); }
.rem-due.soon { color: var(--warn); }

/* dialogs (preview, scan, crop, viewer) */
dialog {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); max-width: min(680px, 94vw); width: 100%; padding: 0;
  max-height: 90vh; max-height: 90dvh;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-body { padding: 16px; overflow-y: auto; max-height: calc(90vh - 32px); max-height: calc(90dvh - 32px); }
.dialog-body h2 { margin-top: 0; }
.preview-item { border-bottom: 1px solid var(--border); padding: .8em 0; }
.preview-item:last-of-type { border-bottom: none; }
.dialog-full { max-width: 100vw; width: 100vw; max-height: 100vh; max-height: 100dvh; height: 100vh; height: 100dvh; border: none; border-radius: 0; margin: 0; }
.dialog-full .dialog-body { max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.scan-stage { position: relative; flex: 1; min-height: 40vh; background: #000; border-radius: var(--radius); overflow: hidden; }
.scan-stage video, .scan-stage canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.crop-stage { position: relative; flex: 1; min-height: 40vh; background: #111; border-radius: var(--radius); overflow: hidden; touch-action: none; }
.crop-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.magnifier { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 2px solid #fff; background: #000; pointer-events: none; display: none; z-index: 3; }
.scan-actions { display: flex; gap: .6em; flex-wrap: wrap; margin-top: .8em; }
.scan-actions .btn { flex: 1 1 auto; }
.viewer-frame { flex: 1; min-height: 50vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); overflow-y: auto; }
.viewer-frame embed, .viewer-frame iframe, .viewer-frame img { width: 100%; height: 100%; min-height: 50vh; border: none; display: block; }
.viewer-frame canvas { width: 100%; height: auto; display: block; margin-bottom: .6em; }
.viewer-frame canvas:last-child { margin-bottom: 0; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .8em 1.1em; border-radius: var(--radius);
  max-width: min(92vw, 560px); z-index: 50; display: none; box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
#toast.show { display: block; }

footer { margin-top: 2.2em; border-top: 1px solid var(--border); padding-top: 1em; color: var(--dim); font-size: .92rem; }
.hidden { display: none !important; }
