:root {
    --bar: #102c4f;
    --bar-2: #1a3a63;
    --accent: #ee8a2b;
    --link: #1a4f8b;
    --bg: #efeff4;
    --cell: #fff;
    --tile: #f4f4f6;
    --hair: #c8c7cc;
    --text: #000;
    --muted: #8e8e93;
    --red: #d0021b;
    --green: #3a8a2e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; border: 0; background: none; outline: none; }
button { cursor: pointer; text-align: inherit; }

.hidden { display: none !important; }

/* ---------- Device ---------- */

#phone {
    position: absolute;
    right: 60px;
    bottom: 24px;
    transform-origin: bottom right;
    transform: scale(var(--scale, 1));
    transition: transform 200ms ease-out, opacity 200ms;
}

#phone.hidden { display: block !important; opacity: 0; transform: translateY(60px) scale(var(--scale, 1)); pointer-events: none; }

.frame {
    width: 350px;
    height: 726px;
    padding: 62px 13px 80px;
    background: #1b1c1f;
    border-radius: 50px;
    box-shadow: 0 0 0 7px #2b9bd3, 0 0 0 8px #1f7fb0, 0 18px 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

.speaker {
    position: absolute;
    top: 28px;
    left: 50%;
    width: 52px;
    height: 5px;
    margin-left: -26px;
    border-radius: 3px;
    background: #0d0d0f;
}

.speaker::before {
    content: '';
    position: absolute;
    left: -24px;
    top: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #0d0d0f;
}

.homebtn {
    position: absolute;
    bottom: 15px;
    left: 50%;
    width: 52px;
    height: 52px;
    margin-left: -26px;
    border-radius: 50%;
    background: #141517;
    box-shadow: inset 0 0 0 2px #2c2e33;
}

.screen {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---------- Header ---------- */

.statusbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    background: var(--bar);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
}

.statusbar .left { display: flex; align-items: center; gap: 4px; }
.statusbar .right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.signal { display: flex; gap: 1.5px; }
.signal i { width: 5px; height: 5px; border-radius: 50%; background: #fff; }
.signal i:last-child { background: transparent; box-shadow: inset 0 0 0 1px #fff; }

.battery { width: 22px; height: 10px; border: 1px solid #fff; border-radius: 2px; padding: 1px; position: relative; }
.battery::after { content: ''; position: absolute; right: -3px; top: 2px; width: 2px; height: 4px; background: #fff; border-radius: 0 1px 1px 0; }
.battery i { display: block; height: 100%; width: 86%; background: #fff; }

.spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
    visibility: hidden;
}

.spinner.active { visibility: visible; }

@keyframes spin { to { transform: rotate(360deg); } }

.appbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 38px;
    padding: 0 8px;
    background: var(--bar);
    color: #fff;
}

.appbar h1 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.appbar-btn {
    justify-self: start;
    color: var(--accent);
    font-size: 14px;
    padding: 6px 2px;
    white-space: nowrap;
}

.appbar-btn.info {
    justify-self: end;
    width: 21px;
    height: 21px;
    padding: 0;
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    font: italic 700 12px Georgia, serif;
    text-align: center;
}

.subbar {
    padding: 3px 8px 4px;
    background: var(--bar-2);
    color: #c9d3e0;
    font-size: 11px;
}

#view {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 24px;
}

#view::-webkit-scrollbar { width: 3px; }
#view::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.25); }

/* ---------- Home ---------- */

#view.home { padding: 0; overflow: hidden; }

.tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    height: 100%;
    background: #d6d6da;
    gap: 1px;
}

.tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px 10px 9px;
    background: var(--tile);
}

.tile:active { background: #e3e3e7; }

.tile svg {
    align-self: center;
    width: 50px;
    height: 50px;
    margin-top: 6px;
    fill: none;
    stroke: #c8742a;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile .lbl { font-size: 12px; line-height: 1.25; color: #333; }
.tile .lbl b { display: block; font-weight: 700; color: #000; }

.tile.wide {
    grid-column: span 2;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
}

.tile.wide svg { margin: 0; width: 42px; height: 42px; }

/* ---------- Grouped table lists ---------- */

.group-h {
    padding: 18px 12px 6px;
    font-size: 13px;
    color: #6d6d72;
}

.group-h:first-child { padding-top: 14px; }

.group-f {
    padding: 6px 12px 0;
    font-size: 12px;
    color: #6d6d72;
    line-height: 1.35;
}

.group-b {
    background: var(--cell);
    border-top: 1px solid var(--hair);
    border-bottom: 1px solid var(--hair);
}

.cell {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px 8px 0;
    margin-left: 12px;
    width: calc(100% - 12px);
    border-bottom: 1px solid #e0e0e3;
    background: var(--cell);
}

.cell:last-child { border-bottom: 0; }
button.cell:active, label.cell:active { background: #f0f0f2; }

.cell .k { color: #000; flex-shrink: 0; }
.cell .v { flex: 1; text-align: right; color: var(--muted); word-break: break-word; }
.cell .main { flex: 1; min-width: 0; }
.cell .main .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .main .s { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .chev { width: 8px; height: 13px; flex-shrink: 0; fill: none; stroke: #c7c7cc; stroke-width: 2; }

.cell.title .k { font-size: 17px; font-weight: 600; }

.cell.action { justify-content: center; color: var(--link); }
.cell.action.danger { color: var(--red); }

.cell.input .k { width: 92px; }
.cell.input input { flex: 1; min-width: 0; padding: 2px 0; user-select: text; }
.cell.input input::placeholder { color: #c4c4c9; }
.cell.input input.upper { text-transform: uppercase; }

textarea.cell {
    display: block;
    height: 84px;
    resize: none;
    padding: 10px 12px 10px 0;
    user-select: text;
}

textarea.cell::placeholder { color: #c4c4c9; }

.red { color: var(--red) !important; }
.green { color: var(--green) !important; }
.orange { color: #d9730d !important; }
.wanted-mark { color: var(--red); font-size: 12px; font-weight: 600; flex-shrink: 0; }

.empty-cell { padding: 11px 12px; color: var(--muted); font-size: 14px; }

.btn-wrap { padding: 12px; }

.btn {
    display: block;
    width: 100%;
    height: 40px;
    border-radius: 4px;
    background: var(--bar);
    color: #fff;
    font-weight: 600;
    text-align: center;
}

.btn:active { background: var(--bar-2); }

/* Wanted banner on detail pages */
.alert {
    padding: 9px 12px;
    background: var(--red);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.alert small { display: block; font-weight: 400; font-size: 12px; margin-top: 1px; opacity: 0.92; }

/* License plate */
.plate {
    display: inline-flex;
    align-items: stretch;
    height: 28px;
    border: 1.5px solid #222;
    border-radius: 3px;
    background: #fff;
    overflow: hidden;
    font-family: Arial, sans-serif;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
    flex-shrink: 0;
}

.plate::before { content: ''; width: 9px; background: #003399; }
.plate span { padding: 0 7px; line-height: 25px; font-size: 16px; letter-spacing: 0.04em; }
.plate.small { height: 21px; }
.plate.small span { line-height: 18px; font-size: 12px; padding: 0 5px; }
.plate.small::before { width: 6px; }

.plate-head { padding: 16px 0 2px; text-align: center; }

/* Notes */
.note { margin-left: 12px; padding: 9px 12px 9px 0; border-bottom: 1px solid #e0e0e3; }
.note:last-child { border-bottom: 0; }
.note p { white-space: pre-wrap; word-break: break-word; font-size: 14px; user-select: text; }
.note .meta { display: flex; justify-content: space-between; margin-top: 3px; font-size: 12px; color: var(--muted); }
.note .meta button { color: var(--red); font-size: 12px; }

/* ---------- Sheet dialog ---------- */

.sheet-backdrop {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.sheet {
    width: 100%;
    max-height: 90%;
    overflow-y: auto;
    animation: sheet-in 160ms ease-out;
}

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-box { background: #f7f7f8; border-radius: 12px; overflow: hidden; }
.sheet-title { padding: 12px 14px 10px; text-align: center; font-size: 13px; font-weight: 600; color: #555; }
.sheet-text { white-space: pre-line; max-height: 260px; overflow-y: auto; user-select: text; padding: 0 14px 12px; text-align: center; font-size: 13px; color: #6d6d72; line-height: 1.35; }
.sheet-box .group-b { border-bottom: 0; }

.sheet-btn {
    display: block;
    width: 100%;
    height: 46px;
    border-top: 1px solid var(--hair);
    background: #f7f7f8;
    color: var(--link);
    font-size: 17px;
    text-align: center;
}

.sheet-btn.danger { color: var(--red); }
.sheet-btn.cancel { margin-top: 8px; border: 0; border-radius: 12px; background: #fff; font-weight: 600; }

/* ---------- Toast ---------- */

.toast {
    position: absolute;
    left: 0;
    right: 0;
    top: 78px;
    padding: 7px 12px;
    background: #333;
    color: #fff;
    font-size: 13px;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 150ms, opacity 150ms;
    pointer-events: none;
    z-index: 5;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: #2f6f26; }

/* ---------- FAST-ID request card (scanned person, no focus) – dispatch alert look ---------- */

.fastid {
    position: fixed;
    left: 50%;
    bottom: 9vh;
    width: 470px;
    max-width: calc(100vw - 32px);
    padding: 14px 18px 16px;
    border-radius: 12px;
    background: rgba(18, 19, 23, 0.9);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    color: #fff;
    font-family: 'Segoe UI', -apple-system, Roboto, Arial, sans-serif;
    transition: opacity 180ms, transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
    z-index: 50;
}
.fastid { transform: translateX(-50%); }
.fastid.hidden { display: block !important; opacity: 0; transform: translate(-50%, 16px); pointer-events: none; }

.fastid-tags {
    display: flex;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.fastid-tag {
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.fastid-tag.t-red { background: #e81123; }
.fastid-tag.t-orange { background: #f7a41d; color: #fff; }
.fastid-tag.t-blue { background: #1f6fd1; }
.fastid-tag.t-green { background: #138a36; }
.fastid-tag.t-grey { background: #5a5d63; }

.fastid-title { display: block; font-size: 19px; font-weight: 700; line-height: 1.25; }
.fastid-text { margin: 6px 0 0; font-size: 15px; line-height: 1.4; color: #e6e6e6; }

.fastid-foot { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 14px; font-size: 15px; color: #e6e6e6; }
.fastid-foot span { display: flex; align-items: center; gap: 9px; }
.fastid kbd {
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 5px;
    background: #e9e9ea;
    color: #141414;
    font: 700 13px/24px 'Segoe UI', Arial, sans-serif;
    text-align: center;
}

.fastid-progress { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.fastid-progress i { display: block; height: 100%; width: 0; border-radius: 2px; background: #1f6fd1; animation: fastid-fill linear forwards; }
@keyframes fastid-fill { from { width: 0; } to { width: 100%; } }

@media (prefers-reduced-motion: reduce) {
    .fastid { transition: opacity 120ms; }
    .fastid.hidden { transform: translateX(-50%); }
}
