:root {
    --blue: #427DBF;
    --blue-dark: #3C70AF;
    --magenta: #E30F5A;
    --magenta-dark: #AF0944;
    --ink: #1d2433;
    --muted: #667085;
    --line: #e3e7ee;
    --bg: #f4f6fa;
    --card: #ffffff;
    --ok: #1f8a4c;
    --warn: #c27c00;
    --ko: #c4213b;
    --radius: 12px;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); line-height: 1.45; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.35rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
a { color: var(--blue-dark); }
code { background: #eef1f6; padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; background: #fff; border-bottom: 3px solid var(--blue); }
.brand img { display: block; height: 22px; width: auto; }
.topbar-user { display: flex; gap: .6rem; align-items: center; font-size: .9rem; margin: 0; }

.mainnav { display: flex; gap: .25rem; overflow-x: auto; background: var(--blue-dark); padding: 0 .5rem; position: sticky; top: 0; z-index: 10; }
.mainnav a { color: #fff; text-decoration: none; padding: .75rem .8rem; white-space: nowrap; font-weight: 600; font-size: .95rem; }
.mainnav a:hover, .mainnav a:focus { background: rgba(255,255,255,.15); }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 4rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1.1rem; box-shadow: 0 1px 2px rgba(16,24,40,.06); margin-bottom: 1rem; }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

.form { display: grid; gap: .8rem; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; display: grid; gap: .7rem; }
.form legend { font-weight: 600; padding: 0 .3rem; }
.form label { display: grid; gap: .25rem; font-weight: 600; font-size: .92rem; }
.form label.check { display: flex; gap: .5rem; font-weight: 400; align-items: flex-start; }
input, select, textarea { font: inherit; font-size: 16px; padding: .65rem .7rem; border: 1px solid #cfd5df; border-radius: 9px; background: #fff; width: 100%; color: var(--ink); }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(66,125,191,.3); border-color: var(--blue); }
textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid #cfd5df; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; min-height: 44px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--ko); border-color: var(--ko); color: #fff; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-accent { background: var(--magenta); border-color: var(--magenta); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.1rem; min-height: 56px; }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
button.link { background: none; border: 0; color: var(--blue-dark); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

.alert { padding: .75rem .9rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: #e9f7ef; border-color: #b6e2c8; color: #135c33; }
.alert-error { background: #fdecef; border-color: #f5bcc6; color: #8a1328; }
.alert-info { background: #eaf1fb; border-color: #bfd3ee; color: #1f4a7d; }

.checklist { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .92rem; }
.checklist .ok { color: var(--ok); }
.checklist .ko { color: var(--ko); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: #fff; border-radius: var(--radius); padding: .8rem; border-left: 5px solid var(--line); }
.stat strong { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .88rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef1f6; color: var(--ink); white-space: nowrap; }
.status-stock { border-color: #98a2b3; } .badge.status-stock { background: #eef1f6; }
.status-installed { border-color: var(--ok); } .badge.status-installed { background: #e3f4ea; color: #135c33; }
.status-incident { border-color: var(--warn); } .badge.status-incident { background: #fff2d6; color: #7a4d00; }
.status-faulty { border-color: var(--ko); } .badge.status-faulty { background: #fde3e7; color: #8a1328; }
.status-removed { border-color: var(--blue); } .badge.status-removed { background: #e3edf9; color: #1f4a7d; }

table.list { width: 100%; border-collapse: collapse; font-size: .92rem; background: #fff; }
table.list th, table.list td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-ok td:first-child { border-left: 4px solid var(--ok); }
.row-missing td:first-child { border-left: 4px solid var(--ko); }
.row-partial td:first-child { border-left: 4px solid var(--warn); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto 1rem; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }

@media (min-width: 800px) {
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}

/* Install / removal by location (mobile first) */
.btn-sm { min-height: 40px; padding: .45rem .8rem; font-size: .92rem; }
.inline-form { display: flex; gap: .5rem; margin-top: .7rem; }
.inline-form input, .inline-form select { flex: 1; min-width: 0; }
.inline-form .btn { flex: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-head h2 { margin: 0; }
.device-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.device-list li { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.device-list li form { margin: 0; flex: none; }
.pick-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.pick-list a, .pick-row { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem .2rem; min-height: 52px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pick-row { border-bottom: 0; padding: 0; }
.pick-list a span[aria-hidden], .pick-row span[aria-hidden] { font-size: 1.6rem; color: var(--muted); }
.site-summary { cursor: pointer; display: grid; gap: .15rem; min-height: 44px; }
.scan-log { list-style: none; margin: .8rem 0 0; padding: 0; font-size: .92rem; max-height: 40vh; overflow-y: auto; }
.scan-log li { padding: .45rem .6rem; border-radius: 8px; margin-bottom: .35rem; }
.scan-log li.ok { background: #e9f7ef; color: #135c33; }
.scan-log li.ko { background: #fdecef; color: #8a1328; }
.home-actions { display: grid; gap: .6rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; align-items: end; }
.filters label { display: grid; gap: .25rem; font-weight: 600; font-size: .88rem; }
@media (max-width: 600px) {
    table.list.stack thead { display: none; }
    table.list.stack tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
    table.list.stack td { display: block; border: 0; padding: .1rem .3rem; }
    table.list.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
}
.group-row th { background: #eef3fa; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .92rem; }
.zone-edit { border-bottom: 1px solid var(--line); padding: .55rem 0; }
.zone-edit summary { cursor: pointer; min-height: 32px; }
@media (max-width: 600px) { table.list.stack tr.group-row { background: #eef3fa; } table.list.stack tr.group-row th { display: block; } }
