:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f0;
  --brand: #f59e0b;
  --nav: #0f172a;
  --in: #16a34a;
  --in-soft: #dcfce7;
  --out: #dc2626;
  --out-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --grey-soft: #eef2f7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* shell */
#shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #1e293b; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { color: #fff; font-size: 16px; display: block; }
.brand span { font-size: 12px; color: #94a3b8; display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #475569 transparent; }
nav::-webkit-scrollbar { width: 8px; }
nav::-webkit-scrollbar-thumb { background: #475569; border-radius: 8px; }
nav::-webkit-scrollbar-thumb:hover { background: #64748b; }
nav::-webkit-scrollbar-track { background: transparent; }
.side .brand, .side .who { flex-shrink: 0; }
nav a { color: #cbd5e1; text-decoration: none; padding: 9px 12px; border-radius: 9px; display: flex; gap: 10px; align-items: center; font-weight: 550; }
nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
nav a:hover { background: #1e293b; color: #fff; }
nav a.on { background: var(--brand); color: var(--nav); }
nav .badge { margin-left: auto; background: var(--out); color: #fff; border-radius: 99px; font-size: 11.5px; font-weight: 800; padding: 1px 8px; }
nav a.on .badge { background: var(--nav); }
.rv { display: grid; grid-template-columns: 260px 1fr; gap: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 14px; margin-bottom: 12px; }
.rv .shots { display: flex; gap: 8px; flex-wrap: wrap; align-content: flex-start; }
.rv .shots img.main { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: var(--grey-soft); }
.rv .faces { display: flex; gap: 10px; margin-top: 8px; }
.rv .faces figure { margin: 0; text-align: center; font-size: 11.5px; color: var(--muted); }
.rv .faces img { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; display: block; background: var(--grey-soft); }
.rv ul { margin: 8px 0 12px; padding-left: 18px; line-height: 1.6; }
.risk { display: inline-block; font-weight: 800; border-radius: 10px; padding: 4px 10px; font-size: 13px; }
.risk.hi { background: var(--out); color: #fff; } .risk.mid { background: var(--warn-soft); color: #92400e; }
.facecmp { display: flex; gap: 10px; align-items: center; margin: 6px 0; font-size: 12px; color: var(--muted); }
.facecmp img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 6px; }
.who { padding: 14px 16px; border-top: 1px solid #1e293b; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.linkbtn { background: none; border: 0; color: #93c5fd; cursor: pointer; padding: 0; }
#page { padding: 22px 26px 40px; min-width: 0; }

/* page header & controls */
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin-right: auto; }
.ctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input.i, select.i, textarea.i { border: 1px solid #cfd6e0; border-radius: 9px; padding: 8px 10px; background: #fff; color: var(--ink); min-width: 0; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn { border: 1px solid #cfd6e0; background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 13px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--grey-soft); }
.btn.pri { background: var(--nav); color: #fff; border-color: var(--nav); }
.btn.pri:hover { background: #1e293b; }
.btn.amber { background: var(--brand); border-color: var(--brand); color: var(--nav); }
.btn.red { color: var(--out); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid #cfd6e0; border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 8px 11px; cursor: pointer; font-weight: 600; border-right: 1px solid #cfd6e0; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--nav); color: #fff; }

/* panels & KPIs */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 28px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; color: var(--muted); font-weight: 600; }
.kpi.good .v { color: var(--in); } .kpi.bad .v { color: var(--out); } .kpi.warn .v { color: var(--warn); }
.two { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 14px; margin-bottom: 14px; }
.map { height: 420px; border-radius: 10px; background: #e2e8f0; position: relative; z-index: 0; }
.map .nomap { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.feed { max-height: 420px; overflow: auto; margin: -4px -6px; }
.fi { display: flex; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.fi:hover { background: var(--grey-soft); }
.fi:last-child { border-bottom: 0; }
.thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; background: var(--grey-soft); flex: none; display: block; }
.thumb.none { display: grid; place-items: center; color: #94a3b8; font-size: 11px; }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.sc h3 { margin: 0; font-size: 15px; }
.bar { height: 8px; border-radius: 9px; background: var(--grey-soft); overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--in); }

/* tables */
.tw { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; padding: 10px 12px;
  background: #f8fafc; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #f8fafc; }
.t tr.off td { color: #94a3b8; }
.pt { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.pt .thumb { width: 38px; height: 38px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.sumline { display: flex; gap: 22px; flex-wrap: wrap; margin: 0 0 12px; color: var(--muted); }
.sumline b { color: var(--ink); font-size: 16px; }

/* badges */
.b { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; margin: 1px 2px 1px 0; }
.b.in { background: var(--in-soft); color: #166534; } .b.out { background: var(--out-soft); color: #991b1b; }
.b.red { background: var(--out-soft); color: #991b1b; } .b.amber { background: var(--warn-soft); color: #92400e; }
.b.blue { background: var(--blue-soft); color: #1e40af; } .b.grey { background: var(--grey-soft); color: #475569; }
.b.green { background: var(--in-soft); color: #166534; }

/* muster */
.mt td, .mt th { padding: 6px 4px; text-align: center; font-size: 12.5px; }
.mt th.d { min-width: 30px; } .mt th.sun { background: #fff1f2; color: #9f1239; }
.mt td.nm, .mt th.nm { text-align: left; position: sticky; left: 0; background: #fff; z-index: 2; min-width: 190px; padding-left: 12px; }
.mt th.nm { background: #f8fafc; z-index: 3; }
.mt td.c { font-weight: 700; cursor: default; }
.mt td.c.P { background: #ecfdf3; color: #166534; cursor: pointer; } .mt td.c.HD { background: #fffbeb; color: #92400e; cursor: pointer; }
.mt td.c.A { background: #fff5f5; color: #dc2626; } .mt td.sun { background: #fff8f8; }
.mt td.c.WO { background: #f1f5f9; color: #94a3b8; font-weight: 500; font-size: 11px; }
.mt td.tot { font-weight: 700; background: #f8fafc; }

/* modal & forms */
#modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000; display: grid; place-items: center; padding: 24px; }
.mbox { background: #fff; border-radius: 16px; width: min(980px, 100%); max-height: calc(100vh - 48px); overflow: auto; padding: 20px 22px; position: relative; }
.mbox.narrow { width: min(560px, 100%); }
.mbox .x { position: absolute; right: 14px; top: 12px; border: 0; background: var(--grey-soft); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.form .full { grid-column: 1 / -1; }
.form > * { min-width: 0; }                   /* long option texts must not widen a column */
.form select.i, .form input.i { width: 100%; }
.form .chk { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 550; font-size: 14px; }
.err { color: var(--out); margin-top: 10px; min-height: 1em; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.punches { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.pc { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.pc.void { opacity: .5; }
.pc img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--grey-soft); cursor: zoom-in; }
.pc .noimg { aspect-ratio: 4/3; display: grid; place-items: center; background: var(--grey-soft); color: var(--muted); }
.pc .body { padding: 10px 12px; font-size: 12.5px; line-height: 1.55; }
.pc .body .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pc .body .top b { font-size: 16px; }
.light { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 2000; display: grid; place-items: center; cursor: zoom-out; }
.light img { max-width: 94vw; max-height: 94vh; border-radius: 8px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--nav); font-weight: 800; display: grid; place-items: center; margin-bottom: 8px; }
.qr { width: 190px; height: 190px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 10px; display: block; margin: 10px 0; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; background: var(--grey-soft); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.note { background: var(--warn-soft); color: #78350f; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.note.blue { background: var(--blue-soft); color: #1e3a8a; }
.t.pay input.cut { width: 88px; text-align: right; padding: 6px 8px; }
.t tr.sel td { background: #fffbeb; }
.t tr.grp td { background: #f8fafc; padding-top: 12px; }
.wlist { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
@media print { .t.pay input.cut { border: 0; padding: 0; } .t.pay th:first-child, .t.pay td:first-child { display: none; } }
.dpr { margin-bottom: 12px; cursor: pointer; } .dpr:hover { border-color: #cbd5e1; } .dpr.off { opacity: .55; }
.dpr .dhead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 15px; }
.dpr .dbody { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
.dpr ul.work { margin: 0 0 6px; padding-left: 18px; line-height: 1.7; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmpimgs { display: grid; gap: 8px; margin-top: 8px; }
.cmpimgs img { width: 100%; border-radius: 10px; cursor: zoom-in; }
.tl { display: flex; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.tl:first-of-type { border-top: 0; }
.tlday { width: 130px; flex: none; font-weight: 650; font-size: 13px; }
@media (max-width: 760px) { .dpr .dbody, .cmp { grid-template-columns: 1fr; } .tl { flex-direction: column; } }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.sg { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; }
.sg img, .sg .thumb { width: 100%; height: 130px; object-fit: cover; display: block; border-radius: 0; }
.sg .small { padding: 8px 10px; line-height: 1.5; }
.poline { display: grid; grid-template-columns: minmax(0, 1fr) 90px 100px auto; gap: 6px; margin-bottom: 6px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.note.red { background: var(--out-soft); color: #7f1d1d; }
.licbox { text-align: left; margin: 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.licbox .mcode { display: flex; align-items: center; gap: 10px; font-size: 20px; letter-spacing: .04em; margin-top: 2px; }
.lock { max-width: 560px; margin: 70px auto; text-align: center; line-height: 1.6; }
.lock .big { font-size: 52px; } .lock h1 { margin: 6px 0 10px; } .lock .btn { margin-top: 10px; }
ol.tsteps { margin: 6px 0 12px; padding-left: 22px; line-height: 1.6; }
ol.tsteps li { margin-bottom: 10px; }
pre.report { white-space: pre-wrap; font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; line-height: 1.55; background: #f0fdf4;
  border: 1px solid #bbf7d0; border-radius: 12px; padding: 14px 16px; margin: 14px 0; max-height: 46vh; overflow: auto; }

/* auth */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--nav); }
.authbox { background: #fff; border-radius: 18px; padding: 28px; width: min(400px, 100%); }
.authbox img { width: 54px; height: 54px; border-radius: 14px; }
.authbox h1 { margin: 12px 0 4px; }
.authbox label { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; font-weight: 650; font-size: 13px; color: var(--muted); }
.authbox .btn { width: 100%; margin-top: 18px; padding: 11px; }
.authbox .linkbtn.forgot { display: block; margin: 14px auto 0; color: #2563eb; font-size: 14px; }
.authbox .okmsg { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--in-soft); color: #166534; font-size: 14px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--nav); color: #fff; padding: 10px 16px;
  border-radius: 10px; opacity: 0; transition: .2s; z-index: 3000; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--out); } #toast.good { background: var(--in); }

.leaflet-popup-content { font-family: inherit; font-size: 13px; }
.leaflet-popup-content img { width: 180px; border-radius: 8px; display: block; margin-bottom: 6px; }

@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }
@media (min-width: 761px) and (max-height: 820px) {
  .brand { padding: 12px 16px; }
  nav { padding: 6px 8px; gap: 1px; }
  nav a { padding: 7px 12px; }
  nav .sep { padding: 8px 12px 4px; }
  .who { padding: 10px 16px; }
}
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  nav { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  nav .sep, .who { display: none; }
  #page { padding: 16px 14px 30px; }
  .form { grid-template-columns: 1fr; }
}
@media print {
  .side, .ctl, .noprint, #toast { display: none !important; }
  #shell { display: block; }
  #page { padding: 0; }
  body { background: #fff; font-size: 11px; }
  .tw { border: 0; overflow: visible; }
  .t th { position: static; }
  .mt td.nm, .mt th.nm { position: static; }
  .panel, .kpi { break-inside: avoid; }
}
