/* EQ Movement — mobile-first, no build step. */
:root {
    --ink: #12161c;
    --ink-2: #2b333d;
    --muted: #6b7480;
    --line: #e2e5ea;
    --bg: #f6f6f7;
    --card: #fff;
    --primary: #d1262a;          /* overridden from Settings → Branding */
    --primary-dark: #a31e21;
    --primary-ink: #fff;
    --primary-soft: #fdecec;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --green-bg: #dcfce7;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;
    --purple: #6d28d9;
    --purple-bg: #ede9fe;
    --radius: 12px;
    --tap: 48px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--primary-dark); }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; line-height: 1.2; }
h1.tight { margin: .1rem 0 .2rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }
.block { display: block; }
.mt { margin-top: 1rem; }
.pre { white-space: pre-wrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.warn-text { color: var(--amber); font-weight: 600; }

/* ---------- header ---------- */
.top { background: #fff; color: var(--ink); position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top); border-bottom: 3px solid var(--primary); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; max-width: 960px; margin: 0 auto; }
.brand { color: var(--ink); font-weight: 700; text-decoration: none; letter-spacing: .01em; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { height: 34px; width: auto; display: block; flex: none; }
.brand-name { padding-left: 10px; border-left: 2px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-user { display: flex; gap: 10px; align-items: center; margin: 0; font-size: .875rem; color: var(--muted); flex: none; }
.top-user .who { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish { background: none; border: 0; color: var(--primary-dark); text-decoration: underline; font: inherit; padding: 6px 0; cursor: pointer; }
.nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px 8px; max-width: 960px; margin: 0 auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 7px 12px; border-radius: 999px; white-space: nowrap; font-size: .9rem; }
.nav a.on { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- layout ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.wrap.narrow { max-width: 520px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line); }
.card.warn { border-color: #f59e0b; background: #fffbeb; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.lead { align-items: flex-start; border-bottom: 0; padding-top: 0; }
.row.link { color: inherit; text-decoration: none; }
.row.link:active { background: #f8fafc; }
.row.dim { opacity: .55; }
.card > .row:first-child { padding-top: 0; }
.list .row { padding: 12px 0; }
.grow { flex: 1; min-width: 0; }
.pills { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; font-size: .95rem; color: var(--ink-2); text-decoration: none; }
.info { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
label .muted { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 22px; height: 22px; flex: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], select, textarea {
    font: inherit; font-weight: 400; width: 100%; min-height: var(--tap); padding: 10px 12px;
    border: 1px solid #cfd5dc; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(209,38,42,.2); border-color: var(--primary); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { flex-direction: row; align-items: center; gap: 8px; border: 1px solid #cfd5dc; border-radius: 10px; padding: 12px; font-weight: 600; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--primary); background: var(--green-bg); }
.seg label:has(input[value=damaged]:checked) { border-color: var(--red); background: var(--red-bg); }
.sticky-save { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); }
.sticky-save .btn { width: 100%; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: var(--tap); padding: 10px 18px; border-radius: 10px; border: 1px solid #cfd5dc;
    background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover, .btn.primary:active { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .85rem; }
.btn.huge { min-height: 64px; font-size: 1.15rem; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.disabled, .btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- flash ---------- */
.flash { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash.ok { background: var(--green-bg); border-color: #86efac; color: #14532d; }
.flash.bad { background: var(--red-bg); border-color: #fca5a5; color: #7f1d1d; }
.flash.note { background: var(--amber-bg); border-color: #fcd34d; color: #78350f; }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: #eef0f3; color: var(--ink-2); }
.st-available, .st-closed { background: var(--green-bg); color: #166534; }
.st-out { background: var(--amber-bg); color: #92400e; }
.st-review, .st-returned { background: var(--purple-bg); color: var(--purple); }
.st-maintenance, .st-damaged, .st-overdue { background: var(--red-bg); color: var(--red); }
.st-retired, .st-draft { background: #e5e7eb; color: #4b5563; }
.st-flag { background: var(--amber-bg); color: var(--amber); }
.st-admin { background: var(--blue-bg); color: var(--blue); }

/* ---------- dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.tile .n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.tile span:last-child { font-size: .82rem; color: var(--muted); }
.tile.alert { border-color: #fca5a5; background: #fff5f5; }
.tile.alert .n { color: var(--red); }
.tile.attn { border-color: #c4b5fd; background: #faf8ff; }
.tile.attn .n { color: var(--purple); }
.meter { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 6px 0 8px; }
.meter span { display: block; height: 100%; background: var(--primary); }
.card.warn .meter span { background: var(--red); }

/* ---------- movement detail ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.compare { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.compare.head { font-weight: 700; font-size: .85rem; color: var(--muted); padding-top: 0; }
.compare:last-child { border-bottom: 0; }
.angle-name { font-weight: 600; font-size: .9rem; padding-top: 4px; }
.shot img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; background: #e5e7eb; display: block; }
.shot .empty { aspect-ratio: 4/3; border-radius: 8px; background: #f1f3f5; display: flex; align-items: center; justify-content: center; color: var(--muted); }
@media (min-width: 720px) { .compare { grid-template-columns: 140px 1fr 1fr; gap: 14px; } }
details summary { cursor: pointer; font-weight: 600; }

/* ---------- settings angles ---------- */
.angles { display: flex; flex-direction: column; gap: 8px; }
.angle-row { display: grid; grid-template-columns: 64px 1fr 44px 44px; gap: 8px; align-items: center; }
.angle-row > input[type=text]:nth-of-type(2) { grid-column: 2 / -1; grid-row: 2; }
.angle-row.head { display: none; }
.angle-row { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.angle-row.new input[type=text] { background: #fafafa; }
.angle-row label.check { justify-content: center; }
@media (min-width: 720px) {
    .angle-row { grid-template-columns: 70px 180px 1fr 44px 60px; border-bottom: 0; padding-bottom: 0; }
    .angle-row > input[type=text]:nth-of-type(2) { grid-column: auto; grid-row: auto; }
    .angle-row.head { display: grid; font-size: .8rem; color: var(--muted); font-weight: 600; }
}

/* ---------- scan ---------- */
.scan-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; max-height: 70vh; margin: 0 auto 14px; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18% 14%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scan-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; background: rgba(0,0,0,.65); color: #fff; padding: 10px 12px; border-radius: 10px; text-align: center; font-size: .92rem; }
.scan-msg.bad { background: rgba(185,28,28,.9); }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0 20px; }

/* ---------- capture (full screen, dark) ---------- */
body.capture-body { background: #000; color: #fff; }
.cap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); max-width: 720px; margin: 0 auto; }
.cap .flash { margin: 8px 12px; }
.cap-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.cap-head form { margin: 0; }
.cap-x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #262b33; color: #fff; font-size: 1.1rem; cursor: pointer; }
.cap-title { flex: 1; min-width: 0; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-title .muted { color: #9aa4b1; }
.cap-phase { font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 6px; margin-right: 6px; letter-spacing: .04em; }
.cap-phase.out { background: var(--primary); color: #fff; }
.cap-phase.in { background: #22c55e; color: #000; }
.cap-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.cap-angle { padding: 6px 14px 10px; }
.cap-angle strong { display: block; font-size: 1.35rem; }
.cap-angle span { color: #c9d1db; font-size: .92rem; }
.cap-stage { position: relative; flex: 1; min-height: 52vh; background: #111; overflow: hidden; }
.cap-stage video, .cap-stage > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.ref { position: absolute; top: 10px; right: 10px; width: 30%; max-width: 160px; margin: 0; border: 2px solid #fff; border-radius: 8px; overflow: hidden; background: #000; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.ref img { width: 100%; display: block; }
.ref figcaption { font-size: .65rem; text-align: center; background: rgba(0,0,0,.7); padding: 2px; }
.cam-error { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 24px; background: #111; color: #fff; text-align: center; gap: 6px; }
.cam-error[hidden] { display: none; }
.cam-error .btn { margin-top: 8px; }
.busy { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.8); padding: 12px; border-radius: 10px; }
.busy[hidden] { display: none; }
.spinner { width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.cap-dots { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; }
.cap-dots::-webkit-scrollbar { display: none; }
.dot { flex: none; width: 64px; border: 2px solid #3a414b; background: #1b1f25; color: #c9d1db; border-radius: 10px; padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; font: inherit; }
.dot img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.dot span { font-size: .62rem; padding: 3px 2px; line-height: 1.15; text-align: center; }
.dot:not(.done)::before { content: ""; display: block; aspect-ratio: 4/3; background: repeating-linear-gradient(45deg, #1b1f25, #1b1f25 6px, #232830 6px, #232830 12px); }
.dot.done { border-color: #22c55e; }
.dot.current { border-color: #fff; box-shadow: 0 0 0 2px #fff; }
.cap-dots.grid { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; }
.cap-dots.grid .dot { width: auto; }
.cap-dots.grid .dot span { font-size: .75rem; }
.cap-controls { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 20px 16px; min-height: 104px; }
.cap-controls[hidden] { display: none; }
.cap-controls .btn { flex: 1; min-height: 56px; font-size: 1.05rem; }
.cap-controls .btn:not(.primary) { background: #262b33; color: #fff; border-color: #3a414b; }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: #fff; box-shadow: inset 0 0 0 4px #000; cursor: pointer; margin: 0 auto; flex: none; -webkit-tap-highlight-color: transparent; }
.shutter:active { transform: scale(.94); }
.shutter:disabled { opacity: .4; }
.shutter[hidden], .round[hidden] { display: none; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #262b33; color: #fff; font-size: 1.2rem; flex: none; cursor: pointer; }
.round.on { background: #fde047; }
.round.torch { position: absolute; left: 12px; top: 12px; z-index: 2; }
.cap-finish { margin: 6px 12px 24px; background: #fff; color: var(--ink); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.cap-finish[hidden] { display: none; }
.cap-finish h2 { margin: 0; }

/* ---------- branding: footer, login, tabs ---------- */
.mt-s { margin-top: 10px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.foot-co { font-weight: 700; color: var(--ink-2); letter-spacing: .02em; margin-bottom: 2px; }
.foot a { color: var(--primary-dark); }
.login-brand { text-align: center; margin: 12px 0 18px; }
.login-brand img { height: 64px; width: auto; }
.login-co { font-weight: 800; letter-spacing: .03em; margin-top: 8px; color: var(--ink); }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; }
.tabs a { flex: 1; text-align: center; padding: 10px 8px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem; }
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: rgba(0,0,0,.12); font-size: .75rem; }
.chev { font-size: 1.4rem; color: var(--muted); line-height: 1; }
.logo-preview { display: flex; align-items: center; gap: 14px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: #fff; }
.logo-preview img { height: 48px; width: auto; }
input[type=color] { width: 64px; height: var(--tap); padding: 4px; border: 1px solid #cfd5dc; border-radius: 10px; background: #fff; }
@media (max-width: 420px) { .top-user .who { display: none; } .brand-logo { height: 30px; } }
/* keep the footer at the bottom on short pages */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }

/* review badge in the nav + H.O.D pill */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--primary); color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.nav a.on .badge { background: #fff; color: var(--primary-dark); }
.st-hod { background: var(--purple-bg); color: var(--purple); }

/* ---------- account menu (v1.3) ---------- */
.usermenu { position: relative; flex: none; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: #fff; -webkit-tap-highlight-color: transparent; user-select: none; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { border-color: var(--primary); }
.usermenu .who { font-size: .9rem; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.usermenu .caret { color: var(--muted); transition: transform .15s; }
.usermenu[open] .caret { transform: rotate(180deg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; letter-spacing: .02em; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; z-index: 30; }
.usermenu .menu-head { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.usermenu .menu-head .pill { align-self: flex-start; margin-top: 6px; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--primary-soft); }
.usermenu .menu form { margin: 0; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
.usermenu .menu button { color: var(--primary-dark); font-weight: 600; }
.st-staff { background: #eef0f3; color: var(--ink-2); }
.profile-head { display: flex; align-items: center; gap: 14px; }
h3 { font-size: .95rem; margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 560px) {
    .usermenu .who, .usermenu .caret { display: none; }
    .usermenu summary { padding: 2px; border-color: transparent; }
    .top-inner { padding: 8px 12px; }
    .brand-name { font-size: .95rem; }
}
@media (max-width: 360px) { .brand-name { display: none; } }
