/* Diagnose. One idea runs through it: the ladder. Each check is a contact in series on a 24 V rail. A passing check
   closes its contact and power carries down; the first failed check opens, and everything below it goes dead, the
   way a tech walks a sequence of operation. Forefront colors, fonts and the leaning gold button come from the main
   site and the receipts app; the plain brand swaps the accent, drops the lean and the logo. */
@font-face { font-family: "Red Hat Display"; font-style: normal; font-weight: 500 900; font-display: swap; src: url(fonts/red-hat-display.woff2) format("woff2"); }
@font-face { font-family: "Red Hat Text"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/red-hat-text.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --ground: #E9ECEB; --surface: #F6F7F7; --ink: #131715; --muted: #4A544F; --line: #C3CAC7;
  --accent: #D4AF37; --accent-hi: #E3C35A; --on-accent: #121212; --accent-ink: #6E5600;
  --rail: #B8952A; --dead: #C3CAC7; --danger: #B3261E; --on-danger: #FFFFFF;
  --green: #1E4D2B; --gold: #D4AF37; --logo-ink: #121212;
  --display: "Red Hat Display", "Segoe UI", system-ui, sans-serif; --text: "Red Hat Text", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .24, 1); --lean: -12deg; --bar: 64px;
}
:root[data-brand="plain"] {
  --accent: #0A7C78; --accent-hi: #0C8F8A; --on-accent: #FFFFFF; --accent-ink: #075E5B; --rail: #0A7C78;
  --display: "Red Hat Text", "Segoe UI", system-ui, sans-serif; --lean: 0deg;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --ground: #0F1312; --surface: #161B1A; --ink: #E4E8E6; --muted: #9BA6A1; --line: #2A3230;
    --accent-ink: #E8C95A; --rail: #D4AF37; --dead: #2E3634; --danger: #F2766B; --on-danger: #1A0503; }
  :root[data-brand="plain"]:not([data-theme="light"]) { --accent: #3CC2BB; --accent-hi: #5CD3CD; --on-accent: #06201F; --accent-ink: #5CD3CD; --rail: #3CC2BB; }
}
:root[data-theme="dark"] { color-scheme: dark; --ground: #0F1312; --surface: #161B1A; --ink: #E4E8E6; --muted: #9BA6A1; --line: #2A3230;
  --accent-ink: #E8C95A; --rail: #D4AF37; --dead: #2E3634; --danger: #F2766B; --on-danger: #1A0503; }
:root[data-brand="plain"][data-theme="dark"] { --accent: #3CC2BB; --accent-hi: #5CD3CD; --on-accent: #06201F; --accent-ink: #5CD3CD; --rail: #3CC2BB; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 1.0625rem/1.45 var(--text); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bar) + 72px + env(safe-area-inset-bottom)); overflow-x: hidden; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h2 { font: 800 1.2rem/1.2 var(--display); margin: 28px 0 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.quiet { color: var(--muted); padding: 14px 0; }
.small { font-size: .9rem; color: var(--muted); }

/* frame */
.top { position: sticky; top: 0; z-index: 7; display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 18px;
  background: var(--ground); border-bottom: 1px solid var(--line); }
.brand { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { font-size: 21px; }
.brand .app-name { font: 800 1.15rem/1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; }
.newcall { min-height: 44px; padding: 0 14px; border: 1.5px solid var(--ink); border-radius: 8px; background: none; font-weight: 700; }
main { max-width: 640px; margin: 0 auto; padding: 14px 16px 0; outline: none; }

.tabs { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--bar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-top: 3px solid transparent; background: none;
  color: var(--muted); font: 600 .78rem/1 var(--text); }
.tabs button.on { color: var(--ink); border-top-color: var(--accent); }

/* the leaning button, as on the other Forefront apps */
.go { display: inline-flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 26px; border: 0; border-radius: 7px; background: var(--accent);
  color: var(--on-accent); font: 800 1.08rem/1 var(--display); transform: skewX(var(--lean)); transition: background .15s, transform .15s var(--ease); }
.go > span { transform: skewX(calc(var(--lean) * -1)); }
.go:active { transform: skewX(var(--lean)) scale(.97); background: var(--accent-hi); }
.plain { min-height: 48px; padding: 0 14px; border: 0; background: none; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line); border-radius: 8px; }
.plain.danger { color: var(--danger); }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 26px 0 8px; }
.acts .go { flex: 1 1 160px; margin-right: 6px; }

/* safety */
.alerts { position: sticky; top: calc(65px + env(safe-area-inset-top)); z-index: 6; max-width: 640px; margin: 0 auto; padding: 0 12px; }
.stop { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; padding: 14px 16px; border-radius: 10px; background: var(--danger); color: var(--on-danger); font-weight: 700; }
.stop b { font: 900 .95rem/1.45 var(--display); letter-spacing: .02em; }
.warn { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1.5px solid var(--danger); }
.warn svg { flex: none; color: var(--danger); margin-top: 2px; }
.note { color: var(--muted); font-size: .95rem; margin-top: 6px; }

/* call label */
.label-in { width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface); }
/* The tech's own words and what they matched */
.said-h { margin-top: 18px; }
#note { display: block; width: 100%; min-height: 88px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface); resize: vertical; line-height: 1.4; }
.said-go { margin: 10px 0 0; }
.said-opts { margin-top: 14px; }
.said-opts span { min-width: 0; }
.said-opts small { display: block; margin-top: 2px; font-weight: 400; font-size: .85rem; color: var(--muted); }
.said-saw { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 22px; }
.said-saw .chip { background: none; color: var(--ink); border: 1.5px solid var(--line); font-weight: 600; }
.said-none { padding: 10px 0 0; }

/* system picker */
.sys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.sys button { min-height: 64px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); font: 800 1.1rem/1.1 var(--display); }
.sys button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }

/* symptoms */
.cx { display: grid; gap: 6px; }
.cx button { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 14px; text-align: left; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 600; }
.cx button i { flex: none; width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 5px; }
.cx button[aria-pressed="true"] { border-color: var(--ink); }
.cx button[aria-pressed="true"] i { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.eqt { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px; border-radius: 8px; background: var(--ink); color: var(--ground); font-weight: 700; font-size: .95rem; }
.link { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--accent-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

/* the ladder */
.ladder-head { display: flex; justify-content: space-between; align-items: baseline; margin: 28px 0 6px; }
.ladder-head h2 { margin: 0; }
.rail-tag { font: 800 .8rem/1 var(--display); color: var(--rail); }
.ladder { position: relative; }
.rung { position: relative; display: grid; grid-template-columns: 38px 1fr; scroll-margin: 90px 0 160px; }
.rung.bad.brk::before { background: linear-gradient(var(--rail) 0 28px, var(--dead) 28px); }
.rung::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 3px; background: var(--rail); }
.rung.dead::before, .rung.dead ~ .end::before { background: var(--dead); }
.rung:first-child::before { top: 12px; }
.contact { position: relative; z-index: 1; width: 29px; height: 30px; margin-top: 13px; }
.contact rect.mask { fill: var(--ground); stroke: none; }
.contact path { stroke-width: 3; stroke-linecap: butt; }
.contact .plate { stroke: var(--muted); }
.contact .bridge { fill: var(--rail); stroke: none; transform-box: fill-box; transform-origin: center; }
.rung.ok .plate { stroke: var(--rail); }
.rung.bad .plate { stroke: var(--danger); }
.rung.info .plate { stroke: var(--rail); }
.rung.dead .plate { stroke: var(--dead); }
.rung.skip .plate { stroke: var(--muted); stroke-dasharray: 3 3; }
.rung.skip .ans { color: var(--muted); font-weight: 500; }
@media (prefers-reduced-motion: no-preference) {
  .rung.just .bridge { animation: make .22s var(--ease) both; }
  .rung.just.bad .plate:last-of-type { animation: drop .3s var(--ease) both; }
}
@keyframes make { from { transform: scaleY(0); } }
@keyframes drop { from { transform: translateY(-4px); } }
.rung-body { padding: 10px 0 14px; min-width: 0; }
.rung .q { display: block; font-weight: 700; line-height: 1.3; padding-top: 4px; }
.rung .q small { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; margin-top: 2px; }
.rung.dead .q { color: var(--muted); font-weight: 600; }
.rung.pending:not(.cur) .q { color: var(--muted); }
.qbtn { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.opts { display: grid; gap: 6px; margin-top: 10px; }
.opts button { min-height: 50px; padding: 10px 14px; text-align: left; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface); font-weight: 600; }
.opts button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.opts .skip { border-style: dashed; color: var(--muted); font-weight: 500; }
.ans { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin-top: 6px; padding: 6px 12px; border: 0; border-radius: 8px; background: var(--surface); font-weight: 700; text-align: left; }
.rung.bad .ans { color: var(--danger); }
.end { position: relative; display: grid; grid-template-columns: 38px 1fr; align-items: center; min-height: 34px; }
.end::before { content: ""; position: absolute; left: 13px; top: 0; height: 17px; width: 3px; background: var(--rail); }
.end span:first-child { position: relative; width: 29px; height: 3px; background: var(--rail); }
.rung.dead ~ .end span:first-child { background: var(--dead); }
.end .small { padding-left: 2px; }

/* likely causes */
.causes { display: grid; gap: 10px; }
.cause { border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.cause:first-child { border-color: var(--ink); }
.cause-head { display: grid; grid-template-columns: 30px 1fr; gap: 4px 10px; width: 100%; padding: 14px 14px 12px; border: 0; background: none; text-align: left; }
.cause-head .n { grid-row: span 2; font: 900 1.35rem/1 var(--display); color: var(--muted); padding-top: 1px; }
.cause:first-child .cause-head .n { color: var(--accent-ink); }
.cause-head .t { font: 800 1.05rem/1.25 var(--display); }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.why { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px 54px; }
.why span { padding: 3px 9px; border-radius: 6px; background: var(--ground); font-size: .86rem; font-weight: 600; }
.cause-body { padding: 0 14px 16px 54px; }
.checks { display: grid; gap: 10px; }
.checks li { position: relative; padding-left: 14px; }
.checks li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 1px; background: var(--muted); }
.flag { display: inline-grid; place-items: center; width: 32px; height: 28px; margin: -4px 0 -6px 2px; vertical-align: middle; border: 0; border-radius: 6px; background: none; color: var(--accent-ink); }
.flag[aria-expanded="true"] { background: var(--ground); }
.src { display: block; margin-top: 4px; font-size: .86rem; color: var(--muted); }
.fix { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.fix b { font-family: var(--display); }
.more { margin-top: 8px; }

/* readings */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; margin: 4px 0 14px; padding: 3px; border-radius: 10px; background: var(--surface); border: 1.5px solid var(--line); }
.seg button { min-height: 44px; border: 0; border-radius: 8px; background: none; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.grp { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.grp legend { padding: 0; margin-bottom: 10px; font: 800 1.1rem/1.2 var(--display); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span:first-child { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.inbox { position: relative; display: flex; align-items: center; }
.inbox input, .field select { width: 100%; min-height: 50px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 1.15rem; font-weight: 700; }
.inbox input { padding-right: 58px; }
.inbox input::placeholder { color: var(--muted); font-weight: 500; }
.inbox em { position: absolute; right: 10px; font-style: normal; font-size: .8rem; color: var(--muted); pointer-events: none; }
.field select { font-size: 1rem; }
.dv { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dv span { display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1.5px solid var(--line); font-size: .95rem; }
.dv span b { font-family: var(--display); }
.dv span em { font-style: normal; color: var(--muted); font-size: .85rem; }
.dv span.off { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.dv span.off em { color: inherit; opacity: .75; }
.pattern { margin: 8px 0 0; }

/* codes */
.search { width: 100%; min-height: 54px; padding: 0 16px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--surface); font-size: 1.15rem; font-weight: 600; }
.boards { display: flex; gap: 6px; overflow-x: auto; margin: 12px -16px 4px; padding: 0 16px 6px; scrollbar-width: none; }
.boards button { flex: none; min-height: 40px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.boards button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.codes { display: grid; gap: 10px; margin-top: 12px; }
.code { padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.code .k { font: 900 1.3rem/1.1 var(--display); word-break: break-word; }
.code .b { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.code .m { font-weight: 700; margin-top: 4px; }
.code .c { margin-top: 4px; }
.code .add { margin-top: 8px; }
.board-how { margin: 12px 0 4px; }

/* calls */
.calls { display: grid; gap: 10px; }
.call { padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.call .t { font: 800 1.05rem/1.25 var(--display); }
.call .acts { margin: 8px 0 0; flex-wrap: nowrap; }
.call .acts .go { flex: 1 1 auto; min-width: 0; padding: 0 18px; }

/* bottom peek at the top cause */
.peek { position: fixed; z-index: 5; left: 10px; right: 10px; bottom: calc(var(--bar) + 10px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto;
  display: grid; gap: 2px; padding: 10px 14px; border: 0; border-radius: 12px; background: var(--ink); color: var(--ground); text-align: left;
  box-shadow: 0 6px 18px rgb(0 0 0 / .25); }
.peek .t { font: 800 1rem/1.2 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek small { font-size: .85rem; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; z-index: 9; left: 12px; right: 12px; bottom: calc(var(--bar) + 76px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; padding: 14px 16px;
  border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s, transform .18s var(--ease); }
.toast.show { opacity: 1; transform: none; }

/* Forefront logo (receipts-app/src/logo.json) */
.logo { --plate: var(--green); --streak: var(--gold); --glyph: #FFFFFF; --mercury: var(--gold); --rule: var(--gold); --word: #FFFFFF; --sub: var(--gold);
  display: inline-flex; align-items: center; gap: .12em; flex: none; font-family: "Red Hat Display", sans-serif; transform: skewX(-12deg); }
.logo-streaks { display: flex; flex-direction: column; align-items: flex-end; gap: .14em; }
.logo-streaks span { display: block; height: .1em; background: var(--streak); }
.logo-streaks span:nth-child(1) { width: .64em; } .logo-streaks span:nth-child(2) { width: .44em; } .logo-streaks span:nth-child(3) { width: .26em; }
.logo-plate { display: flex; align-items: center; gap: .22em; height: 1.5em; padding: 0 .32em; border-radius: .1em; background: var(--plate); }
.logo-f { display: block; width: .74em; height: .98em; flex: none; }
.logo-f .glyph { fill: var(--glyph); stroke: none; } .logo-f .mercury { fill: var(--mercury); stroke: none; }
.logo-rule { width: .04em; height: .84em; background: var(--rule); flex: none; }
.logo-words { display: flex; flex-direction: column; gap: .1em; }
.logo-word { font-size: .54em; font-weight: 900; line-height: .8; color: var(--word); white-space: nowrap; }
.logo-sub { display: flex; justify-content: space-between; font-size: .17em; font-weight: 700; line-height: 1; color: var(--sub); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo { --plate: var(--gold); --glyph: var(--logo-ink); --mercury: var(--logo-ink); --rule: var(--logo-ink); --word: var(--logo-ink); --sub: var(--logo-ink); }
}
:root[data-theme="dark"] .logo { --plate: var(--gold); --glyph: var(--logo-ink); --mercury: var(--logo-ink); --rule: var(--logo-ink); --word: var(--logo-ink); --sub: var(--logo-ink); }

@media (min-width: 700px) {
  .fields { grid-template-columns: repeat(3, 1fr); }
  .sys { grid-template-columns: repeat(4, 1fr); }
}
