/* The cloud's UI: the same tokens and components as cvad's local UI (service/web/app.css). */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c2027;
  --muted: #687080;
  --line: #dde1e7;
  --brand-accent: #2563eb; /* the brand's (brand.json accent), set by app.js */
  --accent: var(--brand-accent);
  --accent-soft: color-mix(in srgb, var(--brand-accent) 12%, white);
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 8px;
  --side: 220px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111418;
  --panel: #1a1e24;
  --text: #e6e8eb;
  --muted: #9aa3b0;
  --line: #2b313a;
  /* a dark brand color stays readable on the dark background */
  --accent: color-mix(in srgb, var(--brand-accent) 60%, white);
  --accent-soft: color-mix(in srgb, var(--brand-accent) 30%, #1a1e24);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; }
.ok-text { color: var(--good); }
[hidden] { display: none !important; }

/* ---------- shell: top bar, side menu, page ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
.top { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 24px; }
.top .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.layout { display: grid; grid-template-columns: var(--side) 1fr; flex: 1; min-height: 0; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 10px 8px; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: 16px; padding: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.main { overflow: auto; padding: 20px; container-type: inline-size; }
.page { max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { margin-top: 2px; }
.crumbs { font-size: 13px; margin-bottom: 4px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; top: 49px; bottom: 0; left: 0; width: 240px; transform: translateX(-100%); transition: transform .15s; box-shadow: 0 0 24px rgba(0,0,0,.2); }
  body.nav-open .side { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 14px; }
  .top .user-name { display: none; }
}

/* ---------- components ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.primary { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn svg { width: 16px; height: 16px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side-r { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@container (max-width: 900px) { .grid.two, .grid.three, .grid.side-r { grid-template-columns: minmax(0, 1fr); } }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* Native selects otherwise use a smaller browser-defined height than text/date inputs. */
input:not([type="checkbox"]):not([type="radio"]), select { height: 27px; padding: 3px 8px; }
input[type="color"] { width: 27px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; overflow: hidden; appearance: none; -webkit-appearance: none; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 2px solid var(--line); border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: 2px solid var(--line); border-radius: 50%; }
select[multiple] { min-width: 180px; }
/* Tom Select: local Apache-2.0 dependency, styled with the same tokens as native fields. */
.ts-wrapper { min-width: 180px; min-height: 27px; height: 27px; font-size: 14px; }
.ts-wrapper.multi .ts-control, .ts-wrapper.multi.has-items .ts-control, .ts-control { height: 27px; min-height: 27px; padding: 1px 7px !important; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: none; align-items: center; flex-wrap: nowrap; }
.ts-wrapper.focus .ts-control { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ts-wrapper.multi .ts-control > div, .ts-wrapper.multi .ts-control > div.active { margin: 0 3px 0 0; padding: 0 6px; line-height: 18px; border: 1px solid var(--line) !important; border-radius: 4px; background: var(--bg) !important; color: var(--text) !important; }
.ts-wrapper.plugin-remove_button .item .remove { border-left-color: var(--line) !important; color: var(--muted); }
.ts-wrapper .ts-control > input { color: var(--text); }
.ts-dropdown, .ts-dropdown.form-control { margin-top: 3px; border-color: var(--line); border-radius: 6px; background: var(--panel); color: var(--text); box-shadow: 0 5px 16px #0002; }
.ts-dropdown .option { padding: 6px 9px; }
.ts-dropdown .active { background: var(--accent-soft); color: var(--text); }
.ts-dropdown .create { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); color: var(--text); padding: 5px 12px; cursor: pointer; font: inherit; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }

table.tbl { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg); }
.wrap { overflow-x: auto; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
@container (max-width: 520px) { .kpis { gap: 8px; } .kpi { padding: 10px 12px; } .kpi .v { font-size: 21px; } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.delta { font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* bars list (top cameras, counts by type) */
.bars { display: grid; grid-template-columns: minmax(80px, max-content) 1fr auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.bars .bar { height: 10px; background: var(--accent); border-radius: 3px; min-width: 2px; }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; }

/* charts */
.chart { position: relative; }
.chart-plot { position: relative; }
.chart svg { display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-tooltip { position: absolute; z-index: 3; min-width: 150px; max-width: 240px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 6px; background: color-mix(in srgb, var(--panel) 96%, #000); box-shadow: 0 3px 14px #0003; color: var(--text); font-size: 12px; pointer-events: none; }
.chart-tooltip > b { display: block; margin-bottom: 5px; }
.tip-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; }
.tip-row strong, .tip-total strong { font-variant-numeric: tabular-nums; }
.tip-total { display: flex; justify-content: space-between; gap: 14px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.pie-plot { position: relative; height: 220px; display: flex; justify-content: center; }
.pie-plot .pie-slice { cursor: pointer; transition: opacity .12s; }
.pie-plot .pie-slice:hover { opacity: .82; }
.chart .pie-total { fill: var(--text); font-size: 18px; font-weight: 650; }

/* cameras */
.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cam { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; color: var(--text); }
.cam:hover { border-color: var(--accent); text-decoration: none; }
.cam .pic { aspect-ratio: 16/9; background: #0f172a center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.cam .row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.cam .row b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.location-cams { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 18px; align-items: start; }
.channel-card:hover { border-color: var(--line); }
.channel-card .row { border-bottom: 1px solid var(--line); }
.channel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.channel-overview { display: grid; grid-template-columns: minmax(210px, 1fr) minmax(190px, .9fr); border-bottom: 1px solid var(--line); }
.channel-overview .camview { background: #0f172a; display: flex; align-items: center; }
.channel-overview .camview .rview { border-radius: 0; margin: 0; }
.analytics-info { padding: 2px 12px 10px; border-left: 1px solid var(--line); min-width: 0; }
.channel-body { padding: 2px 12px 12px; }
.section-title { display: flex; align-items: center; gap: 7px; margin: 9px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.trigger-list { display: flex; flex-direction: column; gap: 3px; }
.trigger-item { display: grid; grid-template-columns: 9px minmax(80px, 1fr) auto minmax(70px, auto); gap: 7px; align-items: center; padding: 5px 6px; border-radius: 5px; }
.trigger-item:hover, .trigger-item:focus-within { background: var(--accent-soft); }
.trigger-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.trigger-dot.line { background: #ef4444; }
.trigger-dot.zone { background: #a855f7; }
.trigger-dot.speed { background: #3b82f6; }
.trigger-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-id { border: 0; background: none; color: var(--muted); padding: 2px 4px; border-radius: 4px; cursor: copy; font: 11px ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.copy-id:hover, .copy-id:focus-visible { color: var(--accent); background: var(--panel); outline: 1px solid var(--line); }
.config-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 7px 0 10px; font-size: 12px; }
.config-list dt { color: var(--muted); }
.config-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.slider-list { display: flex; flex-direction: column; gap: 7px; }
.read-slider.off { opacity: .45; }
.slider-label { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; }
.slider-label b { font-variant-numeric: tabular-nums; }
.slider-track { height: 4px; border-radius: 3px; background: var(--bg); overflow: hidden; margin-top: 2px; }
.slider-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.capture-info { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 1px 12px 10px; border-bottom: 1px solid var(--line); }
.capture-part > div:last-child { display: flex; gap: 4px; flex-wrap: wrap; }
.local-ui-frame { display: block; width: 100%; height: max(720px, calc(100vh - 170px)); border: 0; background: #0f172a; }
.manage-page, .standalone-local-ui, .standalone-local-ui > .manager-empty { width: 100%; height: 100vh; margin: 0; padding: 0; }
.standalone-local-ui .local-ui-frame { width: 100%; height: 100vh; }
.standalone-local-ui > .manager-empty > .empty { min-height: 100vh; display: grid; place-items: center; }
.manager-empty { padding: 18px; }
.manager-empty p { max-width: 760px; color: var(--muted); }
.alert-location { margin-bottom: 14px; }
.alert-email { display: flex; align-items: end; gap: 8px; }
.alert-email .field { margin: 0; }
.alert-email input { min-width: min(300px, 45vw); }
.alert-settings { display: grid; }
.alert-setting { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 15px; border-top: 1px solid var(--line); }
.alert-copy { min-width: 0; }
.alert-switch { cursor: pointer; }
.alert-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.alert-switch .track { display: block; position: relative; width: 38px; height: 22px; border-radius: 12px; background: var(--line); transition: background .2s; }
.alert-switch .track::after { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0005; transition: transform .2s; }
.alert-switch input:checked + .track { background: var(--accent); }
.alert-switch input:checked + .track::after { transform: translateX(16px); }
.alert-switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.alert-switch input:disabled + .track { opacity: .55; cursor: default; }
.delay-field { display: flex; align-items: center; gap: 7px; }
.small-select { width: auto; min-width: 78px; }
@media (max-width: 700px) {
  .alert-email { width: 100%; align-items: stretch; flex-wrap: wrap; }
  .alert-email .field, .alert-email input { width: 100%; min-width: 0; }
  .alert-setting { grid-template-columns: auto minmax(0, 1fr); }
  .delay-field { grid-column: 2; justify-self: start; }
}
.manager-toolbar { display: flex; align-items: end; gap: 14px; justify-content: space-between; padding: 12px 14px; }
.manager-toolbar .field { margin: 0; min-width: min(360px, 60vw); }
.manager-tabs { padding: 0 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.manager-panel { padding: 14px; min-height: 160px; }
.manager-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; align-items: start; }
.manager-section { border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-width: 0; }
.manager-section h3 { margin: 0 0 12px; }
.manager-section .field { margin-bottom: 10px; }
.manager-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.manager-actions .spacer { flex: 1; }
.manager-add { max-width: 680px; }
.manager-message { min-height: 1em; }
.edit-sliders { display: flex; flex-direction: column; gap: 11px; }
.edit-slider { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(100px, 1fr) 42px; gap: 9px; align-items: center; }
.edit-slider > label, .edit-toggle { display: flex; align-items: center; gap: 7px; }
.edit-slider b { text-align: right; font-variant-numeric: tabular-nums; }
.capture-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 7px; margin-bottom: 12px; }
.rule-editor-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.rule-editor-tools .spacer { flex: 1; }
.rule-editor-layout { display: grid; grid-template-columns: minmax(300px, 1.65fr) minmax(230px, .75fr); gap: 12px; }
.rule-editor-stage { position: relative; aspect-ratio: 16/9; overflow: hidden; border-radius: 8px; background: #0f172a; }
.rule-editor-stage > img, .rule-editor-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rule-editor-stage > img { object-fit: contain; }
.rule-editor-svg g { opacity: .8; cursor: pointer; }
.rule-editor-svg g.selected { opacity: 1; filter: drop-shadow(0 0 4px rgba(255,255,255,.8)); }
.rule-editor-layout aside { display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.rule-editor-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.rule-list-item { display: flex; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); padding: 7px 9px; text-align: left; cursor: pointer; }
.rule-list-item.on { border-color: var(--accent); background: var(--accent-soft); }
.rule-properties { display: flex; flex-direction: column; gap: 9px; border-top: 1px solid var(--line); padding-top: 10px; }
.rule-properties .field { margin: 0; }
.manager-media-results { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; max-height: 560px; overflow: auto; }
@container (max-width: 620px) {
  .channel-overview { grid-template-columns: 1fr; }
  .analytics-info { border-left: 0; border-top: 1px solid var(--line); }
  .trigger-item { grid-template-columns: 9px 1fr auto; }
  .trigger-item > .muted { display: none; }
}
@media (max-width: 760px) {
  .manager-toolbar { align-items: stretch; flex-direction: column; }
  .manager-toolbar .field { min-width: 0; }
  .rule-editor-layout { grid-template-columns: 1fr; }
  .edit-slider { grid-template-columns: minmax(120px, 1fr) minmax(90px, 1fr) 38px; }
}
.locs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.loc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); display: block; }
.loc:hover { border-color: var(--accent); text-decoration: none; }
.loc h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.loc .meta { color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }

video { width: 100%; background: #000; border-radius: var(--radius); aspect-ratio: 16/9; display: block; }
.events { max-height: 520px; overflow: auto; }
.ev { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.ev img { width: 80px; height: 45px; object-fit: cover; border-radius: 4px; cursor: zoom-in; background: #0f172a; flex: none; }
.ev .t { font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs button { border: 0; background: none; padding: 7px 12px; color: var(--muted); cursor: pointer; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.dwell-summary { display: flex; justify-content: center; gap: 8px 18px; flex-wrap: wrap; margin: 2px 0 10px; color: var(--muted); font-size: 12px; }
.dwell-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.heat { position: relative; display: block; width: 100%; border-radius: var(--radius); overflow: hidden; background: #0f172a; aspect-ratio: 16/9; }
.heat img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.heat canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 50; }
#lightbox img, #lightbox video { max-width: 94vw; max-height: 90vh; border-radius: 6px; }

/* auth pages */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth .box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 700; font-size: 18px; }
.auth .logo img { height: 32px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .btn.primary { justify-content: center; padding: 9px; }
.auth .alt { display: flex; justify-content: space-between; font-size: 13px; margin-top: 14px; }

.theme-toggle svg { width: 18px; height: 18px; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, monospace; width: 9em; }

/* ---------- dashboards ---------- */
.dash-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.dash-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
  color: var(--muted); background: none; cursor: pointer; font: inherit; margin-bottom: -1px; }
.dash-tab:hover { color: var(--text); text-decoration: none; }
.dash-tab.on { color: var(--text); background: var(--panel); border-color: var(--line); font-weight: 600; }
.dash-tab .count { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 0 6px; }
.dash-tab.drop { outline: 2px dashed var(--accent); }
.dash-tab.add svg { width: 16px; height: 16px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.widget { margin: 0; }
.widget.wide { grid-column: span 2; }
@container (max-width: 900px) { .widget.wide { grid-column: auto; } }
.widget[draggable="true"] .card-head { cursor: grab; }
.widget.dragging { opacity: .4; }
.widget.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.widget-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.widget-meta .badge { color: var(--text); }
.wtools { display: flex; gap: 2px; opacity: .6; }
.widget:hover .wtools { opacity: 1; }
.counters { display: flex; gap: 12px; flex-wrap: wrap; }
.counter { flex: 1 1 140px; min-width: 0; text-align: center; }
.counter .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.counter .l i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.counter .v { font-size: 34px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
.gauge { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.gauge > div { height: 100%; border-radius: 4px; }
.bd { position: relative; display: grid; gap: 2px; font-size: 11px; align-items: stretch; }
.bd .bdh { color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; overflow: hidden; }
.bd .bdl { color: var(--muted); padding-right: 6px; white-space: nowrap; align-self: center; }
.bd i { font-style: normal; min-height: 18px; border-radius: 3px; background: color-mix(in srgb, var(--line) 45%, transparent); display: flex; align-items: center; justify-content: center; font-size: 10px; font-variant-numeric: tabular-nums; color: var(--text); overflow: hidden; }
.bd i.na { background: transparent; border: 1px dashed var(--line); }
.bd i.out { background: transparent; }
dialog.editor { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: 20px; width: min(980px, 96vw); max-height: 90vh; overflow: auto; }
dialog.editor::backdrop { background: rgba(0,0,0,.45); }
dialog.editor h2 { margin-bottom: 14px; }
.report-picker { width: min(900px, 96vw); }
.report-picker > .card-head { align-items: flex-start; margin-bottom: 16px; }
.report-picker > .card-head h2 { margin-bottom: 2px; }
.report-choice-group + .report-choice-group { margin-top: 18px; }
.report-choice-group h3 { margin-bottom: 8px; color: var(--muted); }
.report-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.report-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-height: 118px; padding: 14px; text-align: left; font: inherit;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.report-choice:hover, .report-choice:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.report-choice strong { font-size: 14px; }
.report-choice > span:not(.choose) { color: var(--muted); font-size: 13px; }
.report-choice .choose { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: auto; }
@media (max-width: 640px) { .report-choice-grid { grid-template-columns: 1fr; } }
.line-row { padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.line-row input[type=color] { width: 27px; height: 27px; padding: 0; }

/* Camera picker (by picture) and the line / zone picture of the report and alert editors. */
.campick-wrap { display: inline-flex; }
.campick { display: inline-flex; align-items: center; gap: 8px; height: 27px; padding: 3px 8px 3px 5px; line-height: normal; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); cursor: pointer; font: inherit; max-width: 280px; }
.campick:hover { border-color: var(--accent); }
.campick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campick svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.campick .thumb { width: 2em; height: 1.1em; margin: -2px 0; border-radius: 3px; background: #0f172a center/cover no-repeat; flex: none; }
dialog.camgrid { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: 16px 20px 20px; width: min(1040px, 96vw); max-height: 90vh; overflow: auto; }
dialog.camgrid::backdrop { background: rgba(0,0,0,.45); }
dialog.camgrid .cams { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
dialog.camgrid .cam { cursor: pointer; padding: 0; font: inherit; text-align: left; }
dialog.camgrid .cam.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
dialog.camgrid .pic.all { font-size: 15px; color: #cbd5e1; }
.rview { position: relative; width: 100%; max-width: 560px; background: #0f172a; border-radius: 8px; overflow: hidden; margin: 6px 0 10px; }
.rview img, .rview svg, .rview .noimg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rview .noimg { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.rview .rhint { position: absolute; left: 8px; bottom: 6px; right: 8px; color: #e2e8f0; font-size: 12px; text-shadow: 0 1px 2px #000; }
.rview .rule.off { opacity: .3; }
.rview .rule.dim { opacity: .55; }
.rview .rule.can { cursor: pointer; }
.rview .rule.can:hover { filter: brightness(1.25); }
.rview .rule.on { filter: drop-shadow(0 0 6px rgba(255,255,255,.75)); }
.rview .hit { stroke: transparent; stroke-width: 34; fill: none; }
.rview .lbl { fill: #fff; font: 600 26px system-ui, sans-serif; paint-order: stroke; stroke: rgba(0,0,0,.75); stroke-width: 5px; pointer-events: none; }
.cam .camview .rview { margin: 0; border-radius: 0; max-width: none; }
.cam .caminfo { padding: 0 10px 10px; font-size: 12px; line-height: 1.5; margin-top: -4px; }
.cam .caminfo div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Events page */
.evfilters .rview { max-width: 420px; }
.evfilters .field.check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 6px; }
table.events tr.evrow { cursor: pointer; }
table.events tr.evrow:hover td, table.events tr.evrow.open td { background: var(--accent-soft); }
table.events td.nowrap { white-space: nowrap; }
table.events td.media { color: var(--muted); }
table.events td.media svg { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
table.events tr.detail > td { background: var(--bg); }
.evdetail { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; padding: 6px 0; cursor: default; }
.evsnap { flex: 1 1 380px; max-width: 640px; color: var(--muted); font-size: 13px; }
.evsnap img { width: 100%; border-radius: 8px; display: block; }
.evvideo { flex: 1 1 320px; max-width: 640px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.evvideo video { width: 100%; border-radius: 8px; background: #000; }

/* Locations: full-width cards with the computer's health and the cameras */
.loclist { display: flex; flex-direction: column; gap: 14px; }
.loccard-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loccard-head .grow { flex: 1; }
.locname { font-size: 17px; font-weight: 650; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.loccard .meta { margin: 4px 0 10px; color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.loccard-body { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.locnums { display: flex; gap: 18px; flex-wrap: wrap; }
.locnums .k { font-size: 11px; color: var(--muted); }
.locnums .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.locnums .v.bad { color: var(--bad); }
.hcharts { flex: 1 1 360px; min-width: 260px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.hlabel { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hbars { display: flex; align-items: flex-end; gap: 1px; height: 48px; }
.hbar { flex: 1; height: 100%; position: relative; background: color-mix(in srgb, var(--line) 50%, transparent); border-radius: 2px 2px 0 0; min-width: 1px; }
.hbar i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 2px 2px 0 0; }
.hbar i.max { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.hbar i.avg { background: var(--accent); }
.hstrip { display: flex; gap: 1px; height: 12px; }
.hstrip i { flex: 1; border-radius: 2px; min-width: 1px; }
.hstrip i.on { background: var(--good, #16a34a); }
.hstrip i.part { background: #f59e0b; }
.hstrip i.off { background: var(--bad); }
.hstrip i.none { background: var(--line); }
.locchans { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.locchan { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dot.idle { background: var(--muted); }
.dot.warn { background: #f59e0b; }
.locstats { margin-bottom: 14px; }
.locstats .locnums { margin-bottom: 12px; }
dl.machine { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0 0 12px; font-size: 13px; }
dl.machine dt { color: var(--muted); }
dl.machine dd { margin: 0; }
