:root {
  --bg: #0e1318; --panel: #161d25; --panel2: #1c2530; --line: #273240; --txt: #e7ebef; --mut: #8c99a6;
  --ok: #2fb35a; --okbg: #15301f; --bad: #e04848; --badbg: #3a1c1f; --warn: #e8a33a; --acc: #3b82f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: #7fb0ff; text-decoration: none; }
h1 { font-size: 20px; margin: 0 0 14px; font-weight: 600; }
h2 { font-size: 13px; margin: 22px 0 10px; color: var(--mut); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--mut); }
.small { font-size: 12px; }
.hide { display: none !important; }

/* top bar */
.top { display: flex; align-items: center; gap: 6px; padding: 0 18px; height: 60px; background: var(--panel);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; margin-right: 18px; white-space: nowrap; }
.brand span { color: var(--ok); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--txt); }
.brand .logo { height: 36px; max-width: 60px; object-fit: contain; }
.brand .bt { display: flex; flex-direction: column; line-height: 1.15; }
.brand .bt b { font-size: 14px; letter-spacing: .4px; }
.brand .bt small { font-size: 11px; color: var(--mut); font-weight: 400; }
.nav a { color: var(--mut); padding: 8px 12px; border-radius: 6px; white-space: nowrap; }
.nav a.on, .nav a:hover { color: var(--txt); background: var(--panel2); }
.top .sp { flex: 1; }
.user { position: relative; }
.user > button { background: none; border: 1px solid var(--line); color: var(--txt); border-radius: 20px; padding: 6px 12px; cursor: pointer; }
.menu { position: absolute; right: 0; top: 40px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
        min-width: 200px; padding: 6px; display: none; box-shadow: 0 8px 24px #0008; }
.menu.open { display: block; }
.menu a, .menu div { display: block; padding: 8px 10px; border-radius: 6px; color: var(--txt); cursor: pointer; }
.menu a:hover { background: var(--line); }
main { padding: 18px 22px 40px; max-width: 1800px; margin: 0 auto; }
.banner { background: #4a3510; border: 1px solid var(--warn); color: #ffd99a; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* controls */
button, .btn { background: var(--acc); color: #fff; border: 0; border-radius: 7px; padding: 8px 14px; font: inherit; cursor: pointer; }
button.sec, .btn.sec { background: var(--panel2); color: var(--txt); border: 1px solid var(--line); }
button.danger { background: #a83232; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); color: var(--txt); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font: inherit; }
input:focus, select:focus { outline: 1px solid var(--acc); }
label { display: block; font-size: 12px; color: var(--mut); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); cursor: pointer; color: var(--mut); }
.chip.on { background: var(--acc); color: #fff; border-color: var(--acc); }

/* cards / KPIs */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi div { font-size: 12px; color: var(--mut); }
.kpi b { font-size: 26px; font-variant-numeric: tabular-nums; }
.kpi.ok b { color: var(--ok); } .kpi.bad b { color: var(--bad); }

/* table board */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.t { border-radius: 8px; padding: 9px 10px; background: var(--panel); border-left: 5px solid var(--bad); }
.t.on { border-left-color: var(--ok); background: var(--okbg); }
.t.long { background: var(--badbg); }
.t.arr { border-left-color: var(--warn); background: #3a2e12; }
.t .n { font-weight: 700; }
.t .s { font-size: 12px; color: var(--mut); }

/* data tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--mut); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: #ffffff05; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--panel2); }
.pill.ok { background: var(--okbg); color: #7ee29d; } .pill.bad { background: var(--badbg); color: #ff9a9a; }
.pill.warn { background: #3d2f12; color: #ffcf7a; }
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--ok); }

/* cameras */
.cams { display: grid; gap: 12px; }
.cam { background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.cam img { width: 100%; display: block; cursor: zoom-in; min-height: 120px; }
.cam .cap { display: flex; justify-content: space-between; padding: 7px 10px; background: var(--panel); font-size: 12px; color: var(--mut); }
.off { color: var(--bad); }
#full { position: fixed; inset: 0; background: #000e; display: none; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; }
#full img { max-width: 99vw; max-height: 98vh; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: #000a; display: none; align-items: flex-start; justify-content: center; z-index: 40; overflow: auto; padding: 40px 10px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 560px; max-width: 100%; }
.modal h3 { margin: 0 0 6px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.test-img { width: 100%; border-radius: 8px; margin-top: 10px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--line); padding: 12px 16px;
         border-radius: 8px; z-index: 60; box-shadow: 0 8px 24px #0008; max-width: 420px; }
.toast.err { border-color: var(--bad); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--mut); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a.on { color: var(--txt); border-bottom-color: var(--acc); }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } .nav a { padding: 8px 6px; } .brand { display: none; } }
