/* Plant floor iPads. Colours, fonts and motion come from the Angstrom Brand Kit 2.0 tokens (cc/tokens/tokens.css,
   loaded first); light or dark follows the iPad's setting (theme.js). Text is large and high-contrast so it can be
   read at arm's length on the plant floor. */
:root {
  --bar: #06090D;          /* Night: the top bar, in both themes */
  --bar-ink: #FFFFFF;
  --bar-ink-2: #C3C8CE;    /* Silver */
  --chip-on: #06090D;      /* Night */
  --chip-on-ink: #FFFFFF;
  --danger: #B42318;       /* Danger: white text 6.6:1 */
  --warning: #B45309;      /* Warning: white text 5.0:1 */
  --success: #1E7A46;      /* Success: white text 5.4:1 */
  --info: #2F5F8F;         /* Info: white text 6.6:1 */
  --viewer: #2B3540;       /* Steel, behind document pages */
  --card: var(--surface);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --footer-h: 52px;
}
:root[data-theme="dark"] {
  --bar: #0A0F15;
  --chip-on: #98B8D9;      /* Sky Blue: active states on dark */
  --chip-on-ink: #06090D;
  --viewer: #0A0F15;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font: 17px/1.4 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; touch-action: manipulation; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0 0 calc(var(--footer-h) + var(--safe-bottom)) 0; display: flex; flex-direction: column; }

.splash { margin: auto; text-align: center; color: var(--ink-3); display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* Emergency footer */
.emergency { position: fixed; left: 0; right: 0; bottom: 0; min-height: calc(var(--footer-h) + var(--safe-bottom)); padding: 0 20px var(--safe-bottom); background: var(--danger); color: #fff; font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; text-align: center; z-index: 40; }

/* Header */
.topbar { background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid #2B3540; padding: calc(12px + var(--safe-top)) 20px 12px; display: flex; align-items: center; gap: 14px; flex: none; }
.topbar .logo { width: 44px; height: 38px; flex: none; }
.topbar .title { font: 700 23px/1.1 var(--brand-font); letter-spacing: var(--ang-head-track); text-transform: uppercase; }
.topbar .subtitle { font: 600 13px var(--label-font); letter-spacing: .08em; text-transform: uppercase; color: var(--bar-ink-2); margin-top: 3px; }
.topbar .spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--bar-ink-2); background: rgba(255,255,255,.08); border: 1px solid #2B3540; padding: 6px 12px; border-radius: 20px; white-space: nowrap; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: #4CC184; flex: none; }
.status.offline .dot { background: #F0A64A; }
.status.syncing .dot { background: #98B8D9; animation: pulse 1.2s var(--ang-ease) infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Search and filters */
.controls { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 20px 10px; flex: none; }
.searchbox { position: relative; }
.searchbox input { width: 100%; height: 56px; border-radius: 12px; border: 2px solid var(--input-line); padding: 0 56px 0 52px; font-size: 20px; background: var(--surface-2); color: var(--ink); -webkit-appearance: none; appearance: none; }
.searchbox input:focus { outline: none; border-color: var(--focus-ring); background: var(--surface); }
.searchbox .icon { position: absolute; left: 17px; top: 17px; width: 22px; height: 22px; color: var(--ink-3); pointer-events: none; }
.searchbox .clear { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--hover-2); font-size: 20px; color: var(--ink-2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 40px; padding: 0 16px; border-radius: 20px; border: 1.5px solid var(--input-line); background: var(--surface); font-size: 15px; font-weight: 600; color: var(--ink-2); transition: background var(--ang-dur-1) var(--ang-ease), border-color var(--ang-dur-1) var(--ang-ease); display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-ink); }
.chip.picto { padding: 0 10px 0 4px; }
.chip.picto img { width: 32px; height: 32px; }
.chip-label { font: 600 13px var(--label-font); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--ang-label-track); align-self: center; flex: none; margin-right: 2px; }

/* Results */
.results-wrap { flex: 1; position: relative; min-height: 0; display: flex; }
.results { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 20px 24px; }
.count { color: var(--ink-3); font-size: 14px; padding: 8px 2px 4px; }
.letter { font: 700 17px var(--brand-font); color: var(--ink); padding: 14px 4px 6px; position: sticky; top: -6px; background: var(--bg); z-index: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 84px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-xs); color: var(--ink); }
.item:active { background: var(--hover-2); transform: scale(.995); }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.item .mfr { color: var(--ink-3); font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.item .pictos { display: flex; flex-wrap: wrap; gap: 0; justify-content: flex-end; max-width: 132px; flex: none; }
.item .pictos img { width: 40px; height: 40px; }
.item .chev { color: var(--ink-4); font-size: 26px; flex: none; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 10px; letter-spacing: .04em; }
.badge.danger { background: var(--danger); color: #fff; }
.badge.warning { background: var(--warning); color: #fff; }
.tagline { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.item .meta { flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-3); padding: 60px 20px; font-size: 18px; }
.empty strong { display: block; color: var(--ink); font-size: 21px; margin-bottom: 6px; }

.az { width: 34px; flex: none; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; padding: 6px 0; font-size: 12px; font-weight: 700; color: var(--ink); background: var(--surface-2); border-left: 1px solid var(--line); touch-action: none; }
.az span { padding: 1px 6px; }
.az span.dim { color: var(--ink-4); opacity: .55; }

/* Enrollment */
.enroll { margin: auto; width: min(520px, calc(100% - 40px)); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 34px 34px 30px; box-shadow: var(--shadow-lg); text-align: center; }
.enroll img { width: 64px; height: 64px; }
.enroll h1 { font: 700 28px/1.15 var(--brand-font); letter-spacing: var(--ang-head-track); text-transform: uppercase; margin: 16px 0 8px; }
.enroll p { color: var(--ink-2); margin: 0 0 20px; }
.enroll input { width: 100%; height: 64px; text-align: center; font: 400 30px var(--mono); letter-spacing: .15em; text-transform: uppercase; border: 2px solid var(--input-line); border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.enroll input:focus { outline: none; border-color: var(--focus-ring); }
.enroll .err { color: var(--red); font-weight: 600; min-height: 24px; margin: 10px 0 4px; }
.btn-primary { width: 100%; height: 58px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 19px; font-weight: 700; transition: background var(--ang-dur-1) var(--ang-ease); }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; }

/* Viewer */
.viewer { position: fixed; inset: 0 0 calc(var(--footer-h) + var(--safe-bottom)) 0; background: var(--viewer); display: flex; flex-direction: column; z-index: 30; }
.vbar { background: var(--bar); color: var(--bar-ink); padding: calc(10px + var(--safe-top)) 14px 10px; display: flex; align-items: center; gap: 12px; flex: none; }
.back { height: 52px; min-width: 120px; padding: 0 18px 0 12px; border-radius: 10px; border: 0; background: #FFFFFF; color: #06090D; font-size: 18px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; flex: none; }
.back:active { background: #E6EAEF; }
.vtitle { flex: 1; min-width: 0; }
.vtitle .name { font-size: 20px; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtitle .mfr { font-size: 14px; color: var(--bar-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vpictos { display: flex; gap: 2px; flex: none; align-items: center; }
.vpictos img { width: 46px; height: 46px; }
.sections { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; flex: none; scrollbar-width: none; align-items: center; }
.sections::-webkit-scrollbar { display: none; }
.sec { flex: none; height: 46px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--input-line); background: var(--surface-2); font-size: 15px; font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 7px; }
.sec .n { display: inline-flex; width: 24px; height: 24px; border-radius: 6px; background: var(--chip-on); color: var(--chip-on-ink); font-size: 13px; align-items: center; justify-content: center; }
.sec.urgent { border-color: var(--red-line); background: var(--red-50); }
.sec.urgent .n { background: var(--danger); color: #fff; }
.sec:disabled { opacity: .38; }
.sec:active:not(:disabled) { background: var(--hover-2); }
.sections .sep { width: 1px; align-self: stretch; background: var(--line); flex: none; margin: 4px 2px; }
.zoom { flex: none; width: 46px; height: 46px; border-radius: 10px; border: 1.5px solid var(--input-line); background: var(--surface-2); color: var(--ink); font-size: 24px; font-weight: 700; }
.pages { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 14px 0 40px; touch-action: pan-x pan-y; }
.page { margin: 0 auto 14px; background: #FFFFFF; box-shadow: 0 2px 10px rgba(0,0,0,.3); position: relative; }
.page canvas { display: block; width: 100%; height: 100%; }
.page .pno { position: absolute; right: 8px; bottom: -22px; font-size: 13px; color: #C3C8CE; }
.vmsg { margin: auto; color: #FFFFFF; text-align: center; padding: 30px; font-size: 18px; }
.vmsg .sub { color: #C3C8CE; font-size: 15px; margin-top: 8px; }
.pageind { position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px; background: rgba(6, 9, 13, .82); color: #FFFFFF; padding: 6px 14px; border-radius: 16px; font-size: 15px; font-weight: 600; pointer-events: none; transition: opacity var(--ang-dur-3) var(--ang-ease); }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .topbar .subtitle, .status .label-long { display: none; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .title { font-size: 19px; }
  .topbar .spacer { display: none; }
  .topbar > div:not(.spacer):not(.status) { flex: 1 1 0; min-width: 0; }
  .status { flex: 1 1 100%; white-space: normal; border-radius: 12px; }
  .vpictos { display: none; }
  .back { min-width: 0; }
}

.tbadge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 5px; background: var(--hover-2); color: var(--ink-2); letter-spacing: .04em; }
.tbadge.sds { background: var(--red-50); color: var(--red-text); }

.nbadge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--success); color: #fff; letter-spacing: .05em; }
.nbadge.upd { background: var(--info); }

/* Pairing by QR code */
.install-steps { text-align: left; margin: 0 auto 18px; padding: 0; list-style: none; counter-reset: s; max-width: 400px; }
.install-steps li { counter-increment: s; position: relative; padding: 8px 0 8px 44px; font-size: 18px; line-height: 1.45; }
.install-steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.share-ic { display: inline-flex; vertical-align: -5px; margin: 0 4px 0 2px; color: var(--link); }
.install-code { font-size: 15px; }
.btn-link { background: none; border: 0; color: var(--link); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; padding: 8px; }

/* Announcements from the administration site */
.notice-bar { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 12px 20px; font-size: 17px; background: var(--blue-50); color: var(--blue-text); border-bottom: 1px solid var(--blue-line); }
.notice-bar strong { font-weight: 700; }
.notice-bar.update { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: color-mix(in srgb, var(--accent-soft-ink) 30%, transparent); }
.notice-bar.important { background: var(--amber-50); color: var(--amber-text); border-color: var(--amber-line); }

/* Keyboard focus (iPads with a keyboard, and switch control). */
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.topbar :focus-visible, .vbar :focus-visible { outline-color: #98B8D9; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
