:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --side: #17222c;
  --side-text: #c9d3dc;
  --side-active: #243443;
  --text: #1d2730;
  --muted: #6b7782;
  --line: #e3ded3;
  --accent: #0e8f7e;
  --accent-soft: #e2f3f0;
  --ok: #1a9b55;
  --warn: #c98a12;
  --bad: #c2412d;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }     /* beats display rules on .row, label.f, ... */
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
}
.brand-name { font-weight: 600; letter-spacing: .3px; line-height: 1.1; }
.brand-name small { display: block; font-weight: 400; font-size: 11px; color: var(--side-text); }
.brand-logo { height: 32px; max-width: 64px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.logo-prev { border-radius: 10px; padding: 16px 12px 0; margin-bottom: 14px; }
.logo-prev.side-bg { background: var(--side, #17242d); }
.logo-thumb { display: block; max-height: 36px; max-width: 160px; margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: #fff; }
.dev-name .small { display: block; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--side-text); margin-bottom: 2px;
}
.nav a span:first-of-type { flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #6f8293; padding: 14px 12px 6px; }
.nav-group:first-child { padding-top: 0; }
.ico { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #2b3a48; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .me { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.side-foot .me .role { margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex: none; }
.avatar.big { width: 38px; height: 38px; font-size: 14px; background: var(--accent-soft); color: var(--accent); }
.avatar .ico { width: 20px; height: 20px; }
.side-foot .role { color: var(--side-text); font-size: 12px; margin-bottom: 8px; }
.side-foot a { color: var(--side-text); margin-right: 12px; font-size: 12px; }
.side-foot a:hover { color: #fff; }

.main { padding: 26px 32px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- panels & grids ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b8b1a4; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #1a9b5522; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles { margin-bottom: 18px; }
.tile { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.tile .note { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.fault { border-left-color: var(--warn); }
.tile.fault .note { color: var(--warn); }
.tile .lbl { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .val small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.tile.fault .val { color: var(--bad); font-size: 15px; }

/* ---- controls ---- */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(1.07); }
a.btn { display: inline-block; }
.chipbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 6px 11px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }

form.stack { display: grid; gap: 12px; max-width: 420px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f input, label.f select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #fff; min-width: 180px; }
label.f input:focus, label.f select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--bg); }
.badge.active { background: #e3f4ea; color: var(--ok); }
.badge.blocked { background: #f8e4e0; color: var(--bad); }
.badge.inactive { color: var(--muted); }

.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.msg.err { background: #f8e4e0; color: #8a2a1c; }
.msg.ok { background: #e3f4ea; color: #155f36; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.muted { color: var(--muted); }

/* ---- alarms ---- */
.nav .count { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px;
  padding: 1px 7px; margin-top: 1px; }
.alarm-tag { color: var(--bad); font-size: 12px; font-weight: 600; }
.tile.alarm { border-color: #efc3b9; border-left-color: var(--bad); background: #fdf3f0; }
.tile.alarm .note { color: var(--bad); font-weight: 600; }
.tile.alarm .val { color: var(--bad); }
.tile .kind { font-size: 11px; color: var(--bad); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.banner { background: #fdf1ee; border: 1px solid #f0c8bf; color: #8a2a1c; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.badge.alarm { background: #f8e4e0; color: var(--bad); }
.badge.cleared { background: #e3f4ea; color: var(--ok); }
.badge.sent { background: #e3f4ea; color: var(--ok); }
.badge.failed { background: #f8e4e0; color: var(--bad); }
.badge.skipped, .badge.pending { background: #fbf0d9; color: var(--warn); }
table.t input.cell { width: 86px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
table.t input.cell.wide { width: 130px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs.big { border-bottom: 1px solid var(--line); gap: 22px; margin-bottom: 18px; }
.tabs.big a { padding: 10px 2px; border-radius: 0; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs.big a.on { background: none; border-bottom-color: var(--accent); }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
td.wrap { max-width: 320px; overflow-wrap: anywhere; }

/* ---- home: status board ---- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hero-title { font-size: 24px; font-weight: 600; }
.hero-title.good { color: var(--ok); }
.hero-title.warn { color: var(--warn); }
.hero-title.bad { color: var(--bad); }
.search { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 240px; background: #fff; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.counter { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 14px 18px;
  text-align: left; cursor: pointer; display: flex; align-items: baseline; gap: 12px; }
.counter .n { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counter .l { color: var(--muted); }
.counter.alarm .ic, .lane-head.alarm .ic { color: var(--bad); }
.counter.offline .ic, .lane-head.offline .ic { color: #8a94a0; }
.counter.running .ic, .lane-head.running .ic { color: var(--ok); }
.counter.alarm .n { color: var(--bad); }
.counter.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.counter:hover { border-color: var(--accent); }
.lane { margin-bottom: 18px; }
.lane-head { font-weight: 600; font-size: 14px; padding: 4px 2px 8px; display: flex; align-items: center; gap: 8px; }
.lane-head .cnt { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; padding: 0 8px; }
.lane-head .hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.dev { display: grid; grid-template-columns: minmax(170px, 1.2fr) 130px minmax(0, 3fr) 110px; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 6px; color: inherit; }
.dev.alarm { border-left-color: var(--bad); background: #fffaf8; }
.dev.offline { border-left-color: #a7afb8; }
.dev:hover { border-color: var(--accent); border-left-color: inherit; }
.dev-name { display: flex; flex-direction: column; min-width: 0; }
.dev-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-name .muted { font-size: 12px; }
.spark { width: 120px; height: 28px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.dev.alarm .spark polyline { stroke: var(--bad); }
.dev.offline .spark polyline { stroke: #a7afb8; }
.dev-vals { display: flex; flex-wrap: wrap; gap: 6px 14px; min-width: 0; font-variant-numeric: tabular-nums; }
.val { white-space: nowrap; font-weight: 600; }
.val .vn { color: var(--muted); font-weight: 400; font-size: 12px; margin-right: 2px; }
.val small { color: var(--muted); font-weight: 400; margin-left: 2px; }
.val.bad { color: var(--bad); }
.val.more { color: var(--muted); font-weight: 400; }
.dev-seen { color: var(--muted); font-size: 12px; text-align: right; }
.notice { background: #fbf0d9; border: 1px solid #ecd6a6; color: #6d4c0c; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.setup ol.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.setup li { display: flex; gap: 10px; align-items: flex-start; }
.setup .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center;
  font-size: 13px; flex: none; color: #fff; }
.setup li.ok .tick { background: var(--ok); border-color: var(--ok); }
.setup li.ok b { color: var(--muted); text-decoration: line-through; }
.setup .muted { font-size: 12px; margin-top: 2px; }

/* ---- wall display ---- */
body.wall-mode { background: #0f171e; }
.wall { min-height: 100vh; padding: 18px 26px; color: #e6edf2; }
.wall-head { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.wall-head .brand { color: #fff; padding: 0; }
.wall-head .brand-name small { color: #8fa1ae; }
.wall-clock { margin-left: auto; font-size: 22px; font-variant-numeric: tabular-nums; color: #c9d6df; }
.wall-exit { color: #8fa1ae; border: 1px solid #2b3a48; padding: 6px 12px; border-radius: 8px; }
.wall-dev { margin-bottom: 20px; }
.wall-dev h2 { font-size: 20px; font-weight: 600; margin: 0 0 10px; display: flex; gap: 10px; align-items: baseline; }
.wall-dev h2 span:last-child { font-size: 13px; color: #8fa1ae; font-weight: 400; }
.wall-dev.alarm h2 .ic { color: #ff6b57; }
.wall-dev.offline h2 .ic { color: #8a94a0; }
.wall-dev.running h2 .ic { color: #3ccf7f; }
.wall-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.wtile { background: #18232d; border: 1px solid #243443; border-radius: 10px; padding: 12px 14px; }
.wtile .wl { color: #8fa1ae; font-size: 14px; }
.wtile .wv { font-size: 40px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.wtile .wv small { font-size: 16px; color: #8fa1ae; font-weight: 400; margin-left: 4px; }
.wtile.bad { border-color: #ff6b57; background: #2a1a18; }
.wtile.bad .wv { color: #ff8a78; }
.wall-dev.offline .wtile { opacity: .55; }

@media (max-width: 900px) {
  .dev { grid-template-columns: 1fr auto; }
  .dev-spark { display: none; }
  .dev-vals { grid-column: 1 / -1; }
  .counters { grid-template-columns: 1fr 1fr 1fr; }
  .counter { padding: 10px; flex-direction: column; gap: 2px; }
}

/* ---- shared bits ---- */
.small { font-size: 12.5px; }
.opt { font-size: 11.5px; color: #98a2ab; font-weight: 400; }
.nowrap { flex-wrap: nowrap; }
.group-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 2px 8px; }
.group-label:first-child { margin-top: 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.alarm { background: #f8e4e0; color: var(--bad); }
.pill.offline { background: #eceef0; color: #5d6873; }
.pill.running { background: #e3f4ea; color: var(--ok); }
.role-chip { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; background: #eceef0; color: #4f5b66; }
.role-chip.admin, .role-chip.pro { background: #e6e9fb; color: #3a46a8; }
.role-chip.operator { background: #fbf0d9; color: #8a5d06; }
.role-chip.staff { background: var(--accent-soft); color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cards2 > .panel, .cards2 > div > .panel { margin-bottom: 18px; }
.tscroll { overflow-x: auto; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fgrid .span2 { grid-column: 1 / -1; }
.fsec { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 8px;
  padding-top: 10px; border-top: 1px solid var(--line); }
label.f input, label.f select, label.f textarea { min-width: 0; }
label.f textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--text); resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--muted); position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 34px; height: 20px; border-radius: 10px; background: #cfd5da; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 17px; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + span { opacity: .45; }
.switch em { font-style: normal; }

/* ---- dialog & toasts ---- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 23, 30, .42); display: grid; place-items: center; padding: 16px; z-index: 50;
  animation: fade .12s ease-out; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto;
  padding: 22px 24px 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal:has(.fgrid) { max-width: 620px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.modal-text { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.modal-body { display: grid; gap: 12px; margin-top: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #17222c; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  max-width: 380px; border-left: 4px solid var(--ok); animation: fade .15s ease-out; transition: opacity .4s; }
.toast.err { border-left-color: #ff6b57; }
.toast.out { opacity: 0; }

/* ---- device page ---- */
.back { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.back:hover { color: var(--accent); }
.dhead { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--ok); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 14px; }
.dhead.alarm { border-left-color: var(--bad); background: #fffaf8; }
.dhead.offline { border-left-color: #a7afb8; }
.dhead h1 { margin: 0; font-size: 22px; font-weight: 600; }
.dsum { font-size: 15px; margin: 8px 0 6px; }
.dhead.alarm .dsum { color: #8a2a1c; }
.dhead .meta { font-size: 12.5px; color: var(--muted); }
tr.dirty td { background: #fffbea; }
.subs { list-style: none; margin: 0 0 12px; padding: 0; }
.subs li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.subs li:last-child { border-bottom: 0; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.pcard h2 { display: flex; align-items: center; gap: 8px; }
.pcard h2 .ico { color: var(--accent); }

/* ---- list rows (alarms, users, e-mails, clients) ---- */
.arow, .urow, .lrow { display: grid; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 6px; }
.arow { grid-template-columns: 26px minmax(0, 1fr) 150px 130px; border-left: 5px solid var(--bad); }
.arow.offline { border-left-color: #a7afb8; }
.arow.cleared { border-left-color: #c9cfd4; }
.arow .aic { color: var(--bad); font-size: 16px; text-align: center; }
.arow.offline .aic { color: #8a94a0; }
.arow.cleared .aic { color: var(--ok); }
.arow.cleared .amain b a { color: var(--text); }
.amain { min-width: 0; }
.amain b a { color: inherit; }
.amain b a:hover { color: var(--accent); }
.ackline { font-size: 13px; margin-top: 4px; color: #155f36; }
.urow { grid-template-columns: 38px minmax(0, 1fr) 170px 190px 130px auto; }
.uname { min-width: 0; overflow-wrap: anywhere; }
.urow > .row { justify-content: flex-end; }
.urow.blocked { opacity: .7; }
.urow select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; width: 100%; }
.lrow { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.panel.cfg { border-left: 5px solid var(--ok); }
.panel.cfg.warn { border-left-color: var(--warn); }
.big-empty { padding: 40px 0; }
.big-ok { width: 46px; height: 46px; border-radius: 50%; background: #e3f4ea; color: var(--ok); display: grid; place-items: center;
  font-size: 22px; margin: 0 auto 10px; }

/* ---- signatures ---- */
.signer { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.esig { display: inline-block; font-size: 11.5px; font-weight: 600; color: #3a46a8; background: #e6e9fb; border-radius: 5px; padding: 0 6px; margin-left: 4px; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-left: 5px solid #a7afb8; border-radius: 8px; padding: 12px 16px; margin-bottom: 6px; }
.srow.approved { border-left-color: var(--ok); }
.srow.broken { border-left-color: var(--bad); background: #fffaf8; }
.tl-row.signature_failed::before { background: var(--bad); }
.tl-row.review::before, .tl-row.approve::before { background: #3a46a8; }
label.check.span2 { align-items: flex-start; }
label.check input { margin-top: 3px; }

/* ---- alerts ---- */
.chans { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.chan { border: 1px solid var(--line); border-left: 4px solid #c9cfd4; border-radius: 8px; padding: 8px 12px; min-width: 170px; }
.chan.ok { border-left-color: var(--ok); }
.chan.ok b { color: var(--ok); }
.btn.al { font-size: 12.5px; white-space: nowrap; }

/* ---- registers ---- */
.pill.due { background: #fbf0d9; color: #8a5d06; }
.lrow.svc { border-left: 5px solid var(--ok); }
.lrow.svc.due { border-left-color: var(--warn); }
.lrow.svc.overdue { border-left-color: var(--bad); background: #fffaf8; }
.lrow.svc.off { border-left-color: #c9cfd4; opacity: .7; }
.chipbtn.warnchip { border-color: var(--bad); color: var(--bad); }

.lrow.off { opacity: .65; }

/* ---- diagnostics ---- */
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
ul.issues { margin: 6px 0 0; padding-left: 20px; color: #8a2a1c; }
.prob { padding: 8px 0; border-bottom: 1px solid var(--line); }
.prob:last-child { border-bottom: 0; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; margin-top: 3px; overflow-wrap: anywhere; }

/* ---- data health ---- */
.hcards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.hcard { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: 8px; padding: 12px 14px; }
.hcard.warn { border-left-color: var(--warn); }
.hcard.bad { border-left-color: var(--bad); }
.hcard .hv { font-size: 24px; font-weight: 600; margin: 4px 0; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .hcards { grid-template-columns: 1fr 1fr; } }

/* ---- roles matrix ---- */
table.matrix th, table.matrix td.cell-c { text-align: center; }
table.matrix th:first-child { text-align: left; }
table.matrix th.custom { color: #3a46a8; }
table.matrix th.off { opacity: .55; }
table.matrix tr.actions td { border-bottom: 0; padding-top: 12px; white-space: nowrap; }
.small-btn { padding: 4px 9px; font-size: 12.5px; }
.permlist { display: grid; gap: 6px; }

/* ---- audit timeline ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters label.f input, .filters label.f select { min-width: 0; }
.filters .grow { flex: 1; min-width: 180px; }
.timeline { padding: 6px 20px 10px; }
.tl-day { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 14px 0 6px; }
.tl-row { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 8px 0 8px 14px; border-left: 2px solid var(--line); margin-left: 4px;
  font-size: 14px; position: relative; }
.tl-row::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: #c9cfd4; }
.tl-row.update::before, .tl-row.create::before { background: var(--accent); }
.tl-row.acknowledge::before { background: var(--ok); }
.tl-row.login_failed::before { background: var(--bad); }
.tl-row.export::before { background: #3d6fd6; }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-what { background: var(--bg); border-radius: 5px; padding: 0 6px; }
.tl-change { margin-top: 2px; }
.tl-change s { color: var(--muted); }

@media (max-width: 1400px) {
  .urow > .row { grid-column: 2 / -1; justify-content: flex-start; }
}
@media (max-width: 1000px) {
  .cards2 { grid-template-columns: 1fr; }
  .arow { grid-template-columns: 26px 1fr; }
  .arow .astate, .arow > div:last-child { grid-column: 2; }
  .urow { grid-template-columns: 38px 1fr; }
  .urow > *:nth-child(n+3) { grid-column: 2; }
  .lrow { grid-template-columns: auto 1fr; }
  .fgrid { grid-template-columns: 1fr; }
}

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 20%, #e7efe9 0, transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px 30px 26px; }
.login-card .brand { color: var(--text); padding: 0 0 20px; }
.login-card .brand-name small { color: var(--muted); }
.login-card h1 { font-size: 18px; margin: 0 0 18px; font-weight: 600; }
.login-card label.f input { min-width: 0; width: 100%; }
.login-card .btn { width: 100%; padding: 10px; }

/* ---- chart ---- */
.chart-box { width: 100%; min-height: 360px; }
.uplot { font-family: inherit; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 18px 14px; }
}

/* ---- sub-project channel picker ---- */
.chpick { max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; margin-bottom: 12px; }
.chgroup { padding: 8px 0; border-bottom: 1px solid var(--line); }
.chgroup:last-child { border-bottom: 0; }
.chlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 12px; padding: 4px 0 0 24px; }
.devall [data-n] { margin-left: 6px; }
.modal#sch { max-width: 680px; }
.plist { max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.prow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.prow:last-child { border-bottom: 0; }
.prow select { max-width: 170px; }
.modal#spp { max-width: 560px; }
.langsel { font: inherit; font-size: 12px; background: transparent; color: var(--side-text); border: 1px solid #3a4b5a; border-radius: 6px; padding: 1px 4px; margin-right: 10px; }
.langsel option { color: #1d2a33; }
.login-lang { position: absolute; top: 16px; right: 16px; }
.login-lang .langsel { color: var(--muted); border-color: var(--line); }
.login-card { position: relative; }
.side-foot .langsel { display: block; margin: 0 0 6px; }
.side-foot a { white-space: nowrap; display: inline-block; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--soft, #f3efe8); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.secret code { flex: 1; overflow-wrap: anywhere; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.lrow.off { opacity: .65; }

/* ---- channel view (device page) ---- */
.chsel-panel { padding: 10px 14px; margin-bottom: 10px; }
.chsel-top { align-items: center; gap: 8px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  background: var(--panel); font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip small { color: var(--muted); }
.chip.off { opacity: .45; }
.chip.off i { background: #c9cfd4 !important; }
.chip:hover { border-color: var(--accent); }
.tile.outside { border-style: dashed; }
.tile.hidden-count { border-left-color: #c9cfd4; background: transparent; }
.yrange { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 8px; }
.yr { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.yr select, .yr input { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; }
.yr input { width: 80px; }

/* comparisons */
.cmprow { grid-template-columns: 80px minmax(0, 1fr) 260px 110px; color: inherit; text-decoration: none; }
.cmprow:hover { border-color: var(--accent); }
h2.sub { font-size: 14px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.cmp-top { align-items: end; }
label.f.grow { flex: 1; min-width: 220px; }
label.f.inline { grid-auto-flow: column; align-items: center; gap: 8px; }
label.f.inline select { min-width: 130px; }
.crange { margin: 0 0 12px; align-items: end; }
td i.dot { display: inline-block; vertical-align: middle; }
@media (max-width: 800px) { .cmprow { grid-template-columns: 1fr; } }

/* device status */
.devwarn { font-size: 11.5px; color: #8a5d06; font-weight: 600; margin-top: 2px; }
.devwarn.bad { color: var(--bad); }
.stok { border-left: 5px solid var(--ok); }
.stwarn { border-left: 5px solid var(--warn); }
.stbad { border-left: 5px solid var(--bad); background: #fffaf8; }
.stp { margin: 4px 0; }
.stp.bad { color: var(--bad); font-weight: 600; }
.okt { color: var(--ok); }
.badt { color: var(--bad); font-weight: 600; }
table.t.stkv { width: 100%; }
table.t.stkv td:first-child { color: var(--muted); width: 45%; }
.sigbars { display: inline-flex; gap: 2px; align-items: flex-end; margin-right: 4px; }
.sigbars i { width: 5px; background: #d6d9dc; border-radius: 1px; display: inline-block; }
.sigbars i.on { background: var(--accent); }
.sigspark { width: 100%; height: 70px; display: block; }
.sigspark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.sigspark .lim { stroke: var(--bad); stroke-dasharray: 5 4; stroke-width: 1; vector-effect: non-scaling-stroke; }
h3.sub { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
