:root {
  --bg: #f2f4f7; --card: #ffffff; --text: #18202e; --muted: #5f6879; --line: #e2e6ec;
  --accent: #1f5fd1; --accent-soft: #e6eefc; --on-accent: #ffffff;
  --ok: #16794a; --ok-soft: #e2f4e9; --warn: #b0560c; --warn-soft: #fdeedd;
  --bad: #c62828; --bad-soft: #fde8e8; --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --card: #181c24; --text: #e7eaf0; --muted: #9aa3b3; --line: #2a303b;
    --accent: #5b9dff; --accent-soft: #19253d; --on-accent: #0b1220;
    --ok: #4cc38a; --ok-soft: #13281d; --warn: #f0a35a; --warn-soft: #2d2115;
    --bad: #ff7b7b; --bad-soft: #331a1a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --card: #181c24; --text: #e7eaf0; --muted: #9aa3b3; --line: #2a303b;
  --accent: #5b9dff; --accent-soft: #19253d; --on-accent: #0b1220;
  --ok: #4cc38a; --ok-soft: #13281d; --warn: #f0a35a; --warn-soft: #2d2115;
  --bad: #ff7b7b; --bad-soft: #331a1a; --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; overscroll-behavior-y: contain; }
a { color: var(--accent); text-decoration: none; }
h2 { font-size: 19px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
img { max-width: 100%; }

/* ---------- shell ---------- */
header.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: var(--card); border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: none; background: none; color: var(--text); font-size: 32px; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }
.who[hidden] { display: none; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 46%; color: var(--text);
  padding: 4px 10px 4px 4px; border-radius: 22px; background: var(--bg); border: 1px solid var(--line); }
.who-av { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; background: var(--accent); }
.who-av.r-Operator { background: #0f8a6a; } .who-av.r-Technician { background: #c2620c; }
.who-av.r-Head { background: #7a3fd1; } .who-av.r-Admin { background: #1f5fd1; }
.who-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.who-t b, .who-t small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-t b { font-size: 13.5px; }
.who-t small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
@media (max-width: 360px) { .who { padding-right: 4px; } .who-t { display: none; } }
.bell { position: relative; font-size: 22px; padding: 6px; }
.badge { position: absolute; top: 0; right: -2px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; text-align: center; padding: 0 4px; }
main { max-width: 600px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 90px); }
main.wide { max-width: 1000px; }
body.bare header.top, body.bare nav.bottom { display: none; }
body.bare main { padding-bottom: 30px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; align-items: flex-end;
  background: var(--card); border-top: 1px solid var(--line); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--nav-h);
  color: var(--muted); font-size: 11px; font-weight: 600; gap: 2px; }
nav.bottom a .i { font-size: 22px; line-height: 1; }
nav.bottom a.on { color: var(--accent); }
nav.bottom a.scanbtn .i { background: var(--accent); color: var(--on-accent); width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin-top: -26px; box-shadow: 0 4px 14px rgba(31, 95, 209, .4);
  border: 4px solid var(--card); }

/* ---------- basics ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.code { font-weight: 800; font-size: 17px; letter-spacing: .01em; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .i { font-size: 48px; display: block; margin-bottom: 8px; }
.err { background: var(--bad-soft); color: var(--bad); padding: 14px; border-radius: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.p-bad { background: var(--bad-soft); color: var(--bad); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-acc { background: var(--accent-soft); color: var(--accent); }
.p-ok { background: var(--ok-soft); color: var(--ok); }
.p-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

label.f { display: block; font-size: 14px; font-weight: 700; margin: 14px 0 6px; }
input, select, textarea { width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 50px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.chk { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 600; }
.chk input { width: 22px; min-height: 22px; height: 22px; }

/* ---------- login ---------- */
body.bare main.auth { max-width: none; padding: 0; }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  padding: calc(env(safe-area-inset-top) + 28px) 24px 74px;
  background: radial-gradient(120% 90% at 100% 0%, #3f86ff 0%, transparent 55%), linear-gradient(150deg, #1f5fd1 0%, #123c8c 100%);
  border-radius: 0 0 28px 28px;
}
.auth-hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%;
  border: 34px solid rgba(255, 255, 255, .07); }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 52px; height: 52px; border-radius: 15px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.auth-brand b { display: block; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.auth-brand span { display: block; font-size: 21px; font-weight: 800; line-height: 1.15; }
.auth-hero h1 { font-size: 26px; line-height: 1.2; margin: 26px 0 6px; letter-spacing: -.01em; }
.auth-hero p { margin: 0; opacity: .85; font-size: 15px; max-width: 30em; }
.auth-points { display: none; list-style: none; padding: 0; margin: 30px 0 0; }
.auth-points li { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-size: 15px; }
.auth-points li span { width: 36px; height: 36px; border-radius: 11px; background: rgba(255, 255, 255, .14);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }

.auth-card {
  position: relative; z-index: 1; background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  margin: -48px 16px 0; padding: 26px 20px 20px; box-shadow: 0 12px 34px rgba(16, 24, 40, .12);
  width: auto; max-width: 420px; align-self: stretch;
}
.auth-card h2 { margin: 0; font-size: 23px; }
.auth-sub { margin: 4px 0 20px; color: var(--muted); font-size: 14px; }

/* floating-label field */
.fl { position: relative; display: flex; align-items: center; height: 60px; margin-bottom: 14px;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 15px; transition: border-color .15s, box-shadow .15s, background .15s; }
.fl:focus-within { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
.fl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fl-ico { color: var(--muted); padding: 0 4px 0 15px; display: flex; flex: none; transition: color .15s; }
.fl:focus-within .fl-ico { color: var(--accent); }
.fl-pre { font-weight: 700; color: var(--text); padding: 18px 8px 0 4px; font-size: 17px; flex: none; opacity: 0; transition: opacity .15s; }
.fl input { border: none; background: transparent; min-height: 0; height: 100%; border-radius: 15px; flex: 1; min-width: 0;
  padding: 20px 10px 0 4px; font-size: 18px; font-weight: 600; letter-spacing: .06em; }
.fl input:focus { border: none; }
.fl label { position: absolute; left: 47px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px;
  pointer-events: none; transition: top .15s, font-size .15s, color .15s; }
.fl:focus-within label, .fl input:not(:placeholder-shown) ~ label { top: 15px; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.fl:focus-within label { color: var(--accent); }
.fl:focus-within .fl-pre, .fl:has(input:not(:placeholder-shown)) .fl-pre { opacity: 1; }
.fl-ok { color: var(--ok); padding: 0 14px; display: flex; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.fl.valid .fl-ok { opacity: 1; transform: none; }
.fl-eye { border: none; background: none; color: var(--muted); padding: 0 14px; height: 100%; cursor: pointer; display: flex; align-items: center; }
.fl-eye:hover { color: var(--text); }

.auth-err { min-height: 0; color: var(--bad); font-size: 14px; font-weight: 600; }
.auth-card.has-err .auth-err { background: var(--bad-soft); padding: 10px 12px; border-radius: 11px; margin-bottom: 12px; }
.auth-card.has-err #f-pin { border-color: var(--bad); }
.auth-card.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.auth-btn { margin-top: 6px; border-radius: 15px; box-shadow: 0 8px 20px rgba(31, 95, 209, .28); }
.auth-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.auth-btn:hover svg { transform: translateX(3px); }
.auth-btn.busy { opacity: .75; }
.auth-btn.busy svg { display: none; }
.auth-btn.busy::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-help { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 16px calc(env(safe-area-inset-bottom) + 18px); margin-top: auto; }

@media (min-width: 440px) { .auth-card { margin-left: auto; margin-right: auto; width: calc(100% - 32px); } }
@media (min-width: 900px) {
  .auth-wrap { display: grid; grid-template-columns: minmax(380px, 1.05fr) 1fr; grid-template-rows: 1fr auto; }
  .auth-hero { grid-row: 1 / 3; border-radius: 0; padding: 56px 56px; display: flex; flex-direction: column; justify-content: center; }
  .auth-hero h1 { font-size: 40px; margin-top: 46px; }
  .auth-hero p { font-size: 17px; }
  .auth-points { display: block; }
  .auth-hero::after { width: 380px; height: 380px; right: -120px; bottom: -140px; border-width: 56px; }
  .auth-card { align-self: center; justify-self: center; margin: 0; width: min(420px, calc(100% - 64px)); padding: 34px 30px 26px;
    box-shadow: none; border: none; background: transparent; }
  .auth-card h2 { font-size: 28px; }
  .auth-card .fl { background: var(--card); }
  .auth-foot { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .auth-card.shake, .auth-btn.busy::before { animation: none; } }

/* ---------- home ---------- */
.hello { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.hero-scan { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 16px; border-radius: 22px;
  background: var(--accent); color: var(--on-accent); margin: 14px 0; box-shadow: 0 6px 20px rgba(31, 95, 209, .3); }
.hero-scan .i { font-size: 54px; line-height: 1.1; }
.hero-scan b { font-size: 22px; }
.hero-scan span { opacity: .9; }
.alert-card { background: var(--warn-soft); border: 1px solid transparent; }
.alert-card b { display: block; margin-bottom: 4px; }

/* ticket rows / job cards */
.tick-row { display: flex; gap: 12px; align-items: center; color: var(--text); }
.tick-row .meta { flex: 1; min-width: 0; }
.tick-row .meta div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-s { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; background: var(--bg); }
.job { border-left: 5px solid var(--line); }
.job.s-Open { border-left-color: var(--bad); }
.job.s-Reopened, .job.s-Acknowledged { border-left-color: var(--warn); }
.job.s-InProgress { border-left-color: var(--accent); }
.job.s-Done { border-left-color: var(--ok); }
.job .act { margin-top: 12px; }
.confirm-card { background: var(--ok-soft); border-color: transparent; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.seg { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a, .seg button { flex: 0 0 auto; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.seg .on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- report (samosa-simple) ---------- */
.mach { display: flex; gap: 12px; align-items: center; }
.mach .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.step-t { font-size: 17px; font-weight: 800; margin: 18px 0 10px; }
.step-t small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { border: 2px solid var(--line); background: var(--card); color: var(--text); border-radius: 16px; padding: 14px 8px;
  font: inherit; font-weight: 700; cursor: pointer; text-align: center; min-height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.opt .i { font-size: 26px; }
.opt small { font-weight: 500; color: var(--muted); font-size: 13px; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt.yes.on { border-color: var(--bad); background: var(--bad-soft); }
.opt.no.on { border-color: var(--ok); background: var(--ok-soft); }
.opts.c3 { grid-template-columns: 1fr 1fr; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs .t { position: relative; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
.thumbs .x { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--bad); color: #fff; font-size: 13px; cursor: pointer; }
.sticky-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 9;
  padding: 10px 14px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.sticky-bar > div { max-width: 600px; margin: 0 auto; }
.success { text-align: center; padding-top: 6vh; }
.success .tick { font-size: 84px; animation: pop .4s ease-out; }
.success h2 { font-size: 28px; margin: 6px 0; }
.ticket-no { display: inline-block; margin: 14px 0 26px; padding: 8px 18px; border-radius: 12px; background: var(--card); border: 1px dashed var(--line); font-weight: 800; font-size: 20px; }
.success .btn { margin-bottom: 10px; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- tracker (like a food-order tracker) ---------- */
.status-line { font-size: 21px; font-weight: 800; margin: 2px 0 4px; }
.tracker { display: flex; margin: 16px 0 6px; }
.tracker .s { flex: 1; text-align: center; position: relative; font-size: 11px; font-weight: 700; color: var(--muted); }
.tracker .s .d { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 4px; background: var(--line); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; position: relative; z-index: 1; }
.tracker .s::before { content: ""; position: absolute; top: 12px; left: -50%; right: 50%; height: 3px; background: var(--line); }
.tracker .s:first-child::before { display: none; }
.tracker .s.done .d { background: var(--ok); }
.tracker .s.done::before, .tracker .s.cur::before { background: var(--ok); }
.tracker .s.cur .d { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); animation: pulse 1.6s infinite; }
.tracker .s.done, .tracker .s.cur { color: var(--text); }
.tracker .s .tm { display: block; font-weight: 500; color: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px transparent; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.timeline div { position: relative; margin-bottom: 12px; font-size: 14px; }
.timeline div::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- scanner ---------- */
.scan { position: relative; background: #000; border-radius: 20px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; }
.scan video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan .frame { position: absolute; inset: 18% 14%; border: 4px solid rgba(255, 255, 255, .9); border-radius: 22px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scan .hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-weight: 700; text-shadow: 0 1px 4px #000; }

/* ---------- alerts ---------- */
.noti { display: block; color: var(--text); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.noti:last-child { border-bottom: none; }
.noti.unread { background: var(--accent-soft); }
.noti b { display: block; }
.list { padding: 0; overflow: hidden; }
.li { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--text); width: 100%;
  background: none; border-left: none; border-right: none; border-top: none; font: inherit; text-align: left; cursor: pointer; }
.li:last-child { border-bottom: none; }
.li .i { font-size: 20px; width: 28px; text-align: center; }
.li .chev { margin-left: auto; color: var(--muted); }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 800; line-height: 1.2; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 3px; }
.bar.r { background: var(--bad); }

/* ---------- sheet / toasts ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 600px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin-top: 0; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.photo-full { width: 100%; border-radius: 12px; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 64px); z-index: 60;
  display: flex; flex-direction: column; gap: 8px; width: calc(100% - 28px); max-width: 440px; pointer-events: none; }
.toast { background: #18202e; color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); animation: up .2s ease-out; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- preventive maintenance checklist ---------- */
.chk-item { border-left: 5px solid var(--line); }
.chk-item.ok { border-left-color: var(--ok); }
.chk-item.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.chk-item .it { font-weight: 700; }
a.kpi { display: block; color: var(--text); }
a.kpi:active { transform: scale(.98); }
.kpi .l span { font-weight: 700; }
.print-head { display: none; }
input[type="date"] { min-height: 50px; }

/* ---------- QR labels (print) ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.label { background: #fff; color: #000; border: 2px dashed #bbb; border-radius: 12px; padding: 12px; text-align: center; break-inside: avoid; }
.label img { width: 140px; height: 140px; image-rendering: pixelated; }
.label .code { font-size: 18px; }
@media print {
  header.top, nav.bottom, .no-print, #toasts { display: none !important; }
  body, main { background: #fff; padding: 0; max-width: none; }
  .label { border: 1px solid #000; }
  /* Reports print as a clean A4 page in light colours, whatever the phone theme. */
  :root { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #ccc; --bad: #c62828; --accent: #1f5fd1; }
  .print-head { display: block; font-size: 16px; margin-bottom: 10px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .tbl-wrap { overflow: visible; break-inside: avoid; }
  h3 { break-after: avoid; }
}

/* ===================== modern home screens ===================== */
:root { --violet: #6a3fc8; --violet-soft: #efe9fb; --hero-a: #1f5fd1; --hero-b: #123c8c; --hero-glow: #3f86ff;
  --shadow-2: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --violet: #a88bfa; --violet-soft: #251c3d; --hero-a: #1d4fae; --hero-b: #0f2a63; --hero-glow: #2f6fe0; --shadow-2: none; } }
:root[data-theme="dark"] { --violet: #a88bfa; --violet-soft: #251c3d; --hero-a: #1d4fae; --hero-b: #0f2a63; --hero-glow: #2f6fe0; --shadow-2: none; }

/* shell: softer cards, glassy header, pill-highlighted nav */
.card { border-radius: 18px; box-shadow: var(--shadow-2); }
header.top { background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
nav.bottom { background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
nav.bottom a:not(.scanbtn) .i { padding: 3px 16px; border-radius: 16px; transition: background .15s; }
nav.bottom a.on:not(.scanbtn) .i { background: var(--accent-soft); }
h3 { font-size: 12.5px; letter-spacing: .07em; margin: 22px 2px 10px; }

/* hero banner */
.dhero { position: relative; overflow: hidden; color: #fff; border-radius: 22px; padding: 18px 18px 16px; margin-bottom: 14px;
  background: radial-gradient(110% 120% at 100% 0%, var(--hero-glow) 0%, transparent 55%), linear-gradient(145deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 10px 28px rgba(18, 60, 140, .25); }
.dhero::after { content: ""; position: absolute; right: -50px; bottom: -70px; width: 190px; height: 190px; border-radius: 50%; border: 30px solid rgba(255, 255, 255, .07); pointer-events: none; }
.dhero-top { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.dhero-txt { flex: 1; min-width: 0; }
.dhero-date { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.dhero h2 { margin: 4px 0 2px; font-size: 23px; line-height: 1.2; }
.dhero p { margin: 0; opacity: .88; font-size: 14.5px; }
.dchips { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin-top: 16px; position: relative; z-index: 1; }
.dchip { display: block; color: #fff; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .16); }
a.dchip:active { transform: scale(.98); }
.dchip b { display: block; font-size: 22px; line-height: 1.1; }
.dchip span { font-size: 12px; font-weight: 600; opacity: .85; }
.dchip.bad { background: rgba(255, 92, 92, .26); border-color: rgba(255, 140, 140, .45); }
.dchip.warn { background: rgba(255, 170, 70, .22); border-color: rgba(255, 190, 110, .4); }
.dchip.ok { background: rgba(60, 210, 140, .22); border-color: rgba(110, 230, 170, .4); }
.dchip.acc { background: rgba(255, 255, 255, .22); }

.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: rgba(255, 255, 255, .18); }
.ring-fg { stroke: #7ef0b6; stroke-linecap: round; }
.ring-t { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.ring-t b { font-size: 18px; } .ring-t b small { font-size: 12px; opacity: .75; } .ring-t span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }

/* toolbar under the hero */
.dbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dbar .seg { margin: 0; }
.dbar-r { display: flex; gap: 8px; margin-left: auto; }

/* KPI cards */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat { display: block; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-2); min-width: 0; }
a.stat:hover { border-color: var(--accent); }
.stat-ic { width: 34px; height: 34px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.t-acc .stat-ic { background: var(--accent-soft); color: var(--accent); }
.t-bad .stat-ic { background: var(--bad-soft); color: var(--bad); }
.t-warn .stat-ic { background: var(--warn-soft); color: var(--warn); }
.t-ok .stat-ic { background: var(--ok-soft); color: var(--ok); }
.t-violet .stat-ic { background: var(--violet-soft); color: var(--violet); }
.stat-v { font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-l { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 1px; }
.delta { display: inline-block; margin-top: 8px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.delta i { font-style: normal; font-weight: 600; opacity: .8; }
.delta.good { background: var(--ok-soft); color: var(--ok); }
.delta.bad { background: var(--bad-soft); color: var(--bad); }

/* panels */
.dgrid { display: grid; gap: 14px; }
@media (min-width: 900px) { .dgrid { grid-template-columns: 1.5fr 1fr; align-items: start; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow-2); min-width: 0; }
.ph { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ph h4 { margin: 0; font-size: 15.5px; flex: 1; display: flex; align-items: center; gap: 8px; }
.ph a, .ph-note { font-size: 12.5px; font-weight: 700; }
.ph-note { color: var(--muted); font-weight: 600; text-align: right; }
.count { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; }
.more { display: block; text-align: center; font-size: 13px; font-weight: 700; padding-top: 10px; }

/* trend chart */
.tchart { position: relative; height: 150px; margin-top: 8px; }
.tgrid { position: absolute; inset: 0 0 0 26px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.tgrid span { border-top: 1px dashed var(--line); position: relative; height: 0; }
.tgrid span::before { content: attr(data-v); position: absolute; left: -26px; top: -8px; width: 20px; text-align: right; font-size: 10.5px; color: var(--muted); }
.tbars { position: absolute; inset: 0 0 0 26px; display: flex; align-items: flex-end; gap: 2px; }
.tcol { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; outline: none; min-width: 0; }
.tb { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.tbars.dense .tb { border-radius: 2px 2px 0 0; }
.tb.zero { height: 2px !important; background: var(--line); border-radius: 1px; }
.tbars:hover .tb:not(.zero) { opacity: .45; }
.tcol:hover .tb, .tcol:focus .tb { opacity: 1 !important; }
.tcol:hover::after, .tcol:focus::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 3;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; padding: 6px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
.tcol:nth-child(-n+5):hover::after, .tcol:nth-child(-n+5):focus::after { left: 0; transform: none; }
.tcol:nth-last-child(-n+5):hover::after, .tcol:nth-last-child(-n+5):focus::after { left: auto; right: 0; transform: none; }
.taxis { display: flex; justify-content: space-between; padding-left: 26px; margin-top: 6px; font-size: 11px; color: var(--muted); }

/* needs attention / all good */
.att { display: grid; gap: 8px; }
.att-i { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; color: var(--text); border: 1px solid var(--line); }
.att-i.t-bad { background: var(--bad-soft); border-color: transparent; }
.att-i.t-warn { background: var(--warn-soft); border-color: transparent; }
.att-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.att-i b { display: block; font-size: 14.5px; } .att-i small { color: var(--muted); font-size: 12.5px; }
.att-i .chev { margin-left: auto; color: var(--muted); font-size: 20px; }
.allgood { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--ok-soft); }
.allgood > span { width: 34px; height: 34px; border-radius: 50%; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.allgood b { display: block; } .allgood small { color: var(--muted); }

/* live list */
.lv { display: grid; }
.lv-i { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--text); }
.lv-i:last-child { border-bottom: none; }
.lv-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lv-dot.bad { background: var(--bad); animation: pulse 1.6s infinite; } .lv-dot.warn { background: var(--warn); } .lv-dot.acc { background: var(--accent); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
.lv-m { flex: 1; min-width: 0; } .lv-m div, .lv-m small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lv-m small, .lv-r small { color: var(--muted); font-size: 12.5px; }
.lv-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* horizontal bars (downtime, problems) */
.hb { display: grid; gap: 12px; }
.hb-i { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; align-items: center; gap: 10px; color: var(--text); }
.hb-l { min-width: 0; } .hb-l b, .hb-l small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-l small { color: var(--muted); font-size: 12px; }
.hb-track { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.hb-bar { height: 100%; border-radius: 6px; background: var(--accent); }
.hb-bar.soft { background: color-mix(in srgb, var(--accent) 60%, var(--card)); }
.hb-v { font-weight: 800; font-size: 13.5px; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* technician leaderboard */
.lb { display: grid; }
.lb-i { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.lb-i:last-child { border-bottom: none; }
.lb-av { width: 36px; height: 36px; border-radius: 50%; background: #c2620c; color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.lb-m { flex: 1; min-width: 0; } .lb-m b, .lb-m small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-m small { color: var(--muted); font-size: 12px; }
.lb-v { text-align: center; } .lb-v b { display: block; font-size: 18px; line-height: 1; } .lb-v small { color: var(--muted); font-size: 11px; }

/* operator: scan call-to-action */
.hero-scan { flex-direction: row; align-items: center; gap: 16px; padding: 18px; border-radius: 22px; margin: 0 0 14px; text-align: left;
  background: var(--card); color: var(--text); border: 1.5px solid var(--accent); box-shadow: 0 10px 26px rgba(31, 95, 209, .16); }
.hs-ic { width: 64px; height: 64px; border-radius: 20px; flex: none; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--hero-glow), var(--hero-a)); box-shadow: 0 6px 16px rgba(31, 95, 209, .35); position: relative; }
.hs-ic::after { content: ""; position: absolute; inset: -5px; border-radius: 24px; border: 2px solid var(--accent); opacity: 0; animation: ringpulse 2.2s infinite; }
@keyframes ringpulse { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.15); opacity: 0; } }
.hero-scan .i { font-size: 30px; line-height: 1; }
.hs-t { flex: 1; min-width: 0; } .hs-t b { display: block; font-size: 19px; } .hero-scan .hs-t span { color: var(--muted); font-size: 14px; opacity: 1; }
.hs-go { font-size: 30px; color: var(--accent); font-weight: 300; }

/* job cards */
.job { position: relative; overflow: hidden; border-left: 1px solid var(--line); padding-left: 18px; }
.job::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line); }
.job.s-Open::before { background: var(--bad); }
.job.s-Reopened::before, .job.s-Acknowledged::before { background: var(--warn); }
.job.s-InProgress::before { background: var(--accent); }
.job.s-Done::before { background: var(--ok); }
.job .code { font-size: 16px; }
.job .act .btn.big { min-height: 52px; border-radius: 14px; }
.alert-card { border-radius: 16px; }

@media (prefers-reduced-motion: reduce) { .lv-dot.bad, .hs-ic::after { animation: none; } }
@media print { .dhero { box-shadow: none; } .dbar { display: none; } }

/* ===================== Font Awesome icons (no emojis) ===================== */
.fa { line-height: 1; }
.btn .fa { font-size: .95em; }
nav.bottom a .i { font-size: 19px; }
nav.bottom a .i .fa { width: 1.25em; text-align: center; }
nav.bottom a.scanbtn .i { font-size: 22px; color: #fff; }
.li .i { color: var(--accent); font-size: 17px; }
.li .chev { font-size: 12px; }
.empty .i { font-size: 40px; color: var(--muted); opacity: .6; }
.mach .ic { color: var(--accent); font-size: 22px; }
.opt .i { font-size: 24px; color: var(--accent); }
.opt.yes .i { color: var(--bad); } .opt.no .i { color: var(--ok); }
.opt.on .i { color: inherit; }
.success .tick { color: var(--ok); font-size: 76px; }
.pill .fa { font-size: .9em; margin-right: 2px; }
.bell { color: var(--text); font-size: 20px; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.back .fa { font-size: 20px; }
.toast .fa { margin-right: 6px; }
.hero-scan .i { color: #fff; font-size: 28px; }
.hs-go { font-size: 20px; }
.stat-ic .fa { font-size: 15px; }
.att-ic { font-size: 15px; }
.att-i.t-bad .att-ic { color: var(--bad); } .att-i.t-warn .att-ic { color: var(--warn); }
.att-i .chev { font-size: 13px; }
.allgood > span .fa { font-size: 15px; }
.auth-points li span { font-size: 15px; }
.delta .fa { font-size: .85em; }
.noti { display: flex; gap: 12px; align-items: flex-start; }
.noti-ic { width: 36px; height: 36px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.noti-ic.t-bad { background: var(--bad-soft); color: var(--bad); } .noti-ic.t-warn { background: var(--warn-soft); color: var(--warn); }
.noti-ic.t-ok { background: var(--ok-soft); color: var(--ok); } .noti-ic.t-acc { background: var(--accent-soft); color: var(--accent); }
.noti-m { flex: 1; min-width: 0; }
.alert-card b .fa, .card b .fa { margin-right: 4px; }
