@font-face { font-family: "Heebo"; src: url("/static/heebo.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #070B11; --panel: #0E1620; --panel2: #132030; --line: #1E2B38;
  --text: #FFFFFF; --muted: #A9B6C4; --cyan: #22E5F2; --cyan-dim: #1F6F78;
  --green: #34D399; --yellow: #FBBF24; --blue: #60A5FA; --red: #F87171; --orange: #FB923C;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45;
  min-height: 100vh; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--red); min-height: 1.2em; margin: 0; font-size: 14px; }
.ok { color: var(--green); margin: 0; }

/* buttons */
.btn { display: block; width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); font-weight: 600; padding: 10px 16px; }
.btn.primary { background: var(--cyan); color: #04121A; border: 0; font-weight: 700; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border: 0; color: var(--muted); }
.btn:focus-visible, .icon-btn:focus-visible, .tile:focus-visible, .tabs button:focus-visible, .link:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; }
.icon-btn svg { width: 24px; height: 24px; stroke: var(--text); stroke-width: 2; fill: none; stroke-linecap: round; }
.link { background: none; border: 0; color: var(--muted); padding: 8px 10px; min-height: 44px; }
.link.on { color: var(--cyan); }

/* login */
#login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.auth { width: 100%; max-width: 380px; padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.auth-logo { width: 84px; height: auto; margin: 0 auto; }
.auth h1 { font-size: 20px; margin: 4px 0 0; font-weight: 600; }
.brand-word { font-weight: 800; letter-spacing: 1px; font-size: 22px; direction: ltr; }
.brand-word b { color: var(--cyan); }
label { display: flex; flex-direction: column; gap: 6px; text-align: start; font-size: 14px; color: var(--muted); }
input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px; width: 100%; }
input:focus { outline: 2px solid var(--cyan); border-color: transparent; }
#totp, #twofa-code { letter-spacing: 6px; text-align: center; font-size: 22px; direction: ltr; }
.lang-row { display: flex; gap: 4px; }

/* app shell */
#app { max-width: 1100px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 0 10px; position: sticky; top: 0;
  background: var(--bg); z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; margin-inline-end: auto; }
.brand img { width: 36px; height: auto; }
.brand .brand-word { font-size: 18px; }
#site { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 10px; max-width: 45vw; }
.tabs { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel2); color: var(--cyan); }
.foot { text-align: center; margin-top: 28px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* camera grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.tile { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--panel); padding: 0; display: block; width: 100%; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile img:not([src]) { visibility: hidden; }
.tile-name { position: absolute; inset-inline-start: 10px; bottom: 8px; background: rgba(7, 11, 17, .72); padding: 3px 10px;
  border-radius: 8px; font-size: 14px; font-weight: 600; }
.tile-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.tile.off img { opacity: .25; }

/* viewer */
.viewer { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; background: rgba(7, 11, 17, .9); }
.viewer-bar #viewer-name { font-weight: 600; margin-inline-end: auto; }
.live { color: #04121A; background: var(--cyan); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.viewer-stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
.viewer-stage video, .viewer-stage img { width: 100%; height: 100%; object-fit: contain; }
.viewer-msg { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); margin: 0; color: var(--muted); font-size: 14px;
  background: rgba(7, 11, 17, .8); padding: 6px 12px; border-radius: 8px; }
.viewer-msg:empty { display: none; }

/* analytics */
.banner { background: #2A1215; border: 1px solid #5B2129; color: #FECACA; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 28px; line-height: 1.1; color: var(--cyan); direction: ltr; text-align: start; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.bad b { color: var(--red); }
h2 { font-size: 16px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 10px; }
.table { background: var(--panel); border: 1px solid var(--line); border-inline-start: 5px solid var(--green); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.table b { font-size: 18px; }
.table .pill { align-self: flex-start; font-size: 13px; font-weight: 700; border-radius: 999px; padding: 2px 10px; background: rgba(52, 211, 153, .15); color: var(--green); }
.table .timer { font-size: 14px; color: var(--muted); direction: ltr; text-align: start; unicode-bidi: plaintext; }
.table.st-ESPERANDO { border-inline-start-color: var(--yellow); } .table.st-ESPERANDO .pill { background: rgba(251, 191, 36, .15); color: var(--yellow); }
.table.st-ATENDIDA { border-inline-start-color: var(--blue); } .table.st-ATENDIDA .pill { background: rgba(96, 165, 250, .15); color: var(--blue); }
.table.st-SUCIA { border-inline-start-color: var(--orange); } .table.st-SUCIA .pill { background: rgba(251, 146, 60, .15); color: var(--orange); }
.table.alert { border-color: var(--red); border-inline-start-color: var(--red); animation: pulse 1.4s ease-in-out infinite; }
.table.alert .pill { background: rgba(248, 113, 113, .18); color: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(248, 113, 113, .18); } }
@media (prefers-reduced-motion: reduce) { .table.alert { animation: none; } }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.events li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: baseline; }
.events time { color: var(--muted); font-size: 13px; direction: ltr; min-width: 44px; }
.events li.bad { border-color: #5B2129; } .events li.bad span { color: #FECACA; }
.events li.good span { color: var(--green); }

/* account sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow: auto; }
.sheet-head { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); min-width: 48px; min-height: 40px; border-radius: 8px; font-weight: 600; }
.seg button.on { background: var(--panel2); color: var(--cyan); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 200px; margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { display: block; text-align: center; direction: ltr; font-size: 13px; color: var(--muted); word-break: break-all; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
details[open] { display: flex; flex-direction: column; gap: 10px; }
summary { cursor: pointer; min-height: 28px; font-weight: 600; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }

/* first login */
#setpw { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }

/* admin */
.admin-cols { display: grid; grid-template-columns: 1fr; gap: 8px 24px; }
@media (min-width: 900px) { .admin-cols { grid-template-columns: 1.2fr 1fr; } }
.admin-col h2 { margin-top: 4px; }
.card.form, .site-card, .user-card, .welcome { padding: 12px 14px; margin-bottom: 10px; display: block; }
.card.form[open], .site-card[open], .user-card[open] { display: flex; flex-direction: column; gap: 10px; }
.card summary { cursor: pointer; min-height: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 48px; width: 100%; }
.sub { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.sub[open] { display: flex; flex-direction: column; gap: 10px; }
.tag { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; background: var(--panel2); color: var(--muted); }
.tag.good { color: var(--green); } .tag.bad { color: var(--red); }
.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-inline-start: auto; }
.cam-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cam-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.cam-n { font-weight: 600; }
.cam-src { color: var(--muted); font-size: 12px; word-break: break-all; flex: 1 1 200px; }
.link.small { min-height: 36px; font-size: 13px; padding: 4px 6px; }
.danger-t { color: var(--red); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); min-height: 40px; }
label.inline input { width: 20px; height: 20px; min-height: 0; accent-color: var(--cyan); }
.btn-row { display: flex; gap: 8px; } .btn-row.wrap { flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1 1 auto; text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.btn.small { min-height: 40px; font-size: 14px; padding: 6px 12px; }
.scan { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.scan-tile { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.scan-tile img, .scan-tile .noimg { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; display: grid; place-items: center; background: #000; color: var(--muted); font-size: 13px; }
.scan-tile.off { opacity: .6; }
.scan-tile input:not([type]) , .scan-tile input[type=text] { min-height: 40px; padding: 8px; }
.welcome pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; font-size: 14px; margin: 8px 0; }
.welcome pre { unicode-bidi: plaintext; text-align: start; }
a.btn { color: var(--text); }

.scan-tile .noimg.why { padding: 8px; text-align: center; line-height: 1.3; }

/* viewer: zoom + tools */
.viewer-stage { touch-action: none; user-select: none; -webkit-user-select: none; }
.zoomwrap { width: 100%; height: 100%; display: grid; place-items: center; transform-origin: center center; will-change: transform; }
.zoomwrap video, .zoomwrap img { width: 100%; height: 100%; object-fit: contain; }
.zoom-badge { position: absolute; top: 10px; inset-inline-end: 10px; background: rgba(7, 11, 17, .8); padding: 2px 8px; border-radius: 6px; font-size: 13px; direction: ltr; }
.viewer-tools { display: flex; justify-content: center; gap: 14px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: rgba(7, 11, 17, .95); }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; min-height: 64px; padding: 8px 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 600; }
.tool svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tool .on { display: none; } .tool.on .on { display: inline; } .tool.on .off { display: none; }
.tool.on { color: #04121A; background: var(--cyan); border-color: var(--cyan); }
.tool.talk.on { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.tool:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
