:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --sidebar: #17191d;
  --sidebar-2: #22252b;
  --text: #202226;
  --muted: #777c86;
  --line: #e3e5e9;
  --accent: #f26600;
  --accent-2: #ff7a1a;
  --accent-soft: #fff0e5;
  --green: #2ba66a;
  --green-soft: #e7f7ef;
  --amber: #d28b13;
  --amber-soft: #fff5df;
  --red: #d94a4a;
  --red-soft: #ffeded;
  --blue: #3278c5;
  --blue-soft: #eaf3ff;
  --shadow: 0 10px 32px rgba(28, 31, 36, .08);
  --radius: 18px;
  --sidebar-width: 250px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: var(--sidebar-width);
  background: linear-gradient(180deg, #181a1f 0%, #131519 100%); color: #fff;
  display: flex; flex-direction: column; padding: 24px 16px 18px;
  box-shadow: 7px 0 24px rgba(16, 18, 22, .12);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 18px rgba(242,102,0,.25); }
.brand-mark svg { width: 25px; height: 25px; }
.brand strong { display: block; font-size: 17px; letter-spacing: .12em; }
.brand span { display: block; margin-top: 1px; font-size: 12px; color: #aeb2ba; letter-spacing: .12em; text-transform: uppercase; }
.main-nav { display: grid; gap: 7px; padding: 24px 0; }
.nav-item { position: relative; width: 100%; border: 0; display: flex; align-items: center; gap: 13px; padding: 13px 14px; border-radius: 12px; background: transparent; color: #afb3bc; text-align: left; transition: .18s ease; }
.nav-item svg { width: 21px; height: 21px; }
.nav-item span { font-weight: 650; }
.nav-item b { margin-left: auto; min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 999px; font-size: 11px; background: rgba(255,255,255,.08); }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(242,102,0,.24), rgba(242,102,0,.05)); }
.nav-item.active::before { content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav-item.active svg { color: var(--accent-2); }
.sidebar-status { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 15px 12px; border-radius: 13px; background: rgba(255,255,255,.055); }
.status-orb { width: 11px; height: 11px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(210,139,19,.15); flex: 0 0 auto; }
.status-orb.online { background: var(--green); box-shadow: 0 0 0 4px rgba(43,166,106,.15); }
.status-orb.offline { background: var(--red); box-shadow: 0 0 0 4px rgba(217,74,74,.15); }
.sidebar-status strong, .sidebar-status span { display: block; }
.sidebar-status strong { font-size: 12px; }
.sidebar-status span { margin-top: 3px; font-size: 10px; color: #9196a0; }
.sidebar-version { color: #666b75; font-size: 10px; text-align: center; padding-top: 15px; letter-spacing: .08em; text-transform: uppercase; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 72px; display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: rgba(255,255,255,.9); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(219,222,226,.85); }
.topbar-title { min-width: 0; }
.topbar-title span { display: block; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.topbar-title h1 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; background: #fff; color: #5d626c; transition: .18s ease; }
.icon-button:hover { border-color: #cfd2d8; color: var(--accent); transform: translateY(-1px); }
.icon-button svg { width: 20px; height: 20px; }
.mobile-menu { display: none; }
.notification-button { position: relative; }
.notification-button span { position: absolute; right: -5px; top: -5px; min-width: 19px; height: 19px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50px; background: var(--red); color: #fff; font-size: 9px; font-weight: 800; }
.presence-chip { height: 42px; min-width: 42px; border: 1px solid var(--line); border-radius: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; background: #fff; color: #4f545e; font-weight: 700; transition: .18s ease; }
.presence-chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.presence-chip.home { color: var(--green); background: var(--green-soft); border-color: rgba(43,166,106,.22); }
.presence-chip.away { color: var(--red); background: var(--red-soft); border-color: rgba(217,74,74,.22); }
.presence-chip.unknown { color: var(--amber); background: var(--amber-soft); border-color: rgba(210,139,19,.22); }

.view { display: none; padding: 28px 30px 48px; animation: viewIn .25s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.card { background: var(--surface); border: 1px solid rgba(224,226,230,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.eyebrow { display: block; margin-bottom: 5px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 31px 0 16px; }
.section-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.card-title-row h3 { margin: 0; font-size: 18px; }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 750; padding: 4px; }
.text-button:hover { text-decoration: underline; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 20px; }
.alarm-card { padding: 25px; color: #fff; overflow: hidden; position: relative; background: radial-gradient(circle at 87% 15%, rgba(255,138,58,.28), transparent 28%), linear-gradient(135deg, #21242a, #15171b); border-color: #2c3037; }
.alarm-card::after { content: ""; position: absolute; width: 190px; height: 190px; right: -75px; bottom: -120px; border: 28px solid rgba(255,255,255,.025); border-radius: 50%; }
.alarm-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.alarm-card h2 { margin: 0; font-size: 29px; letter-spacing: -.035em; }
.alarm-card p { max-width: 520px; margin: 7px 0 0; color: #aeb3bd; font-size: 13px; line-height: 1.5; }
.shield-state { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; background: rgba(43,166,106,.13); color: #53cd8e; border: 1px solid rgba(83,205,142,.2); }
.shield-state svg { width: 34px; height: 34px; }
.shield-state.arm { color: #ff785e; background: rgba(217,74,74,.13); border-color: rgba(217,74,74,.22); }
.shield-state.home { color: #ffb255; background: rgba(242,102,0,.13); border-color: rgba(242,102,0,.2); }
.mode-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 27px; }
.mode-selector button { position: relative; min-height: 75px; border: 1px solid rgba(255,255,255,.09); border-radius: 14px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px; background: rgba(255,255,255,.045); color: #9fa4ae; font-size: 12px; font-weight: 750; transition: .18s ease; }
.mode-selector button:hover { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.075); color: #fff; }
.mode-selector button.active { color: #fff; border-color: var(--accent); background: linear-gradient(145deg, rgba(242,102,0,.29), rgba(242,102,0,.12)); box-shadow: inset 0 0 0 1px rgba(242,102,0,.2); }
.mode-selector button.active::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 3px; background: var(--accent); border-radius: 3px 3px 0 0; }
.mode-selector svg { width: 22px; height: 22px; }
.alarm-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; padding-top: 17px; border-top: 1px solid rgba(255,255,255,.08); }
.alarm-meta div { min-width: 0; }
.alarm-meta span, .alarm-meta strong { display: block; }
.alarm-meta span { color: #7f858f; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.alarm-meta strong { margin-top: 4px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.health-card { padding: 24px; }
.score-ring { --score: 0; width: 62px; height: 62px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--score) * 1%), #eceef1 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; }
.score-ring span { position: relative; font-size: 15px; font-weight: 850; }
.health-list { display: grid; gap: 14px; margin-top: 24px; }
.health-list > div { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; }
.health-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; }
.health-icon svg { width: 20px; height: 20px; }
.health-icon.good { color: var(--green); background: var(--green-soft); }
.health-icon.warning { color: var(--amber); background: var(--amber-soft); }
.health-icon.critical { color: var(--red); background: var(--red-soft); }
.health-list strong, .health-list small { display: block; }
.health-list strong { font-size: 13px; }
.health-list small { color: var(--muted); margin-top: 2px; font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.metric-card { min-height: 107px; display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 6px 20px rgba(28,31,36,.045); transition: .18s ease; cursor: pointer; }
.metric-card:hover { transform: translateY(-2px); border-color: #d4d7dc; box-shadow: var(--shadow); }
.metric-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; }
.metric-icon svg { width: 24px; height: 24px; }
.metric-icon.orange { color: var(--accent); background: var(--accent-soft); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.red { color: var(--red); background: var(--red-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { font-size: 11px; font-weight: 750; color: #646973; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { margin-top: 1px; font-size: 27px; letter-spacing: -.04em; }
.metric-card small { color: var(--muted); font-size: 10px; }
.dashboard-lower-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; margin-top: 20px; }
.issue-card, .activity-card { padding: 22px; min-height: 310px; }
.count-pill { min-width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 850; }
.issue-list, .activity-list { display: grid; gap: 9px; margin-top: 17px; }
.issue-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.issue-item .issue-symbol { width: 35px; height: 35px; border-radius: 10px; display: grid; place-items: center; color: var(--amber); background: var(--amber-soft); }
.issue-item.critical .issue-symbol { color: var(--red); background: var(--red-soft); }
.issue-item svg { width: 18px; height: 18px; }
.issue-item strong, .issue-item small { display: block; }
.issue-item strong { font-size: 12px; }
.issue-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.empty-state { min-height: 170px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.empty-state svg { width: 35px; height: 35px; margin-bottom: 8px; color: var(--green); }
.activity-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--blue); }
.activity-dot.warning { background: var(--amber); }
.activity-dot.critical { background: var(--red); }
.activity-item strong, .activity-item small { display: block; }
.activity-item strong { font-size: 12px; }
.activity-item small { margin-top: 3px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-item time { color: #9a9fa7; font-size: 9px; white-space: nowrap; }

.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.search-box { min-width: 270px; flex: 0 1 420px; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.search-box svg { width: 19px; height: 19px; color: #8a8f98; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.filter-tabs, .event-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-tabs button, .event-filters button { min-height: 37px; border: 1px solid var(--line); border-radius: 10px; padding: 0 13px; background: #fff; color: #686d77; font-size: 11px; font-weight: 700; }
.filter-tabs button.active, .event-filters button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.sensor-summary-strip { display: flex; gap: 16px; padding: 13px 17px; margin-bottom: 17px; border-radius: 13px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sensor-summary-strip strong { color: var(--text); }
.sensor-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.sensor-card { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 6px 18px rgba(27,30,35,.04); overflow: hidden; }
.sensor-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--green); }
.sensor-card.open::before { background: var(--accent); }
.sensor-card.warning::before { background: var(--amber); }
.sensor-card.critical::before { background: var(--red); }
.sensor-card-head { display: flex; align-items: center; gap: 12px; }
.sensor-type-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); color: #656a73; }
.sensor-type-icon svg { width: 22px; height: 22px; }
.sensor-card h3 { margin: 0; font-size: 14px; }
.sensor-card .sensor-type { margin-top: 3px; color: var(--muted); font-size: 10px; }
.sensor-state-pill { margin-left: auto; padding: 6px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.sensor-state-pill.open { background: var(--accent-soft); color: var(--accent); }
.sensor-state-pill.critical { background: var(--red-soft); color: var(--red); }
.sensor-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 16px; }
.sensor-stats div { padding: 9px; border-radius: 10px; background: var(--surface-2); }
.sensor-stats span, .sensor-stats strong { display: block; }
.sensor-stats span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .07em; }
.sensor-stats strong { margin-top: 4px; font-size: 10px; }
.sensor-actions { display: flex; gap: 7px; margin-top: 12px; }
.sensor-actions button { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 7px 5px; background: #fff; color: #6b7079; font-size: 9px; }
.sensor-actions button:hover { border-color: var(--accent); color: var(--accent); }

.rule-heading { margin-top: 0; align-items: center; }
.primary-button, .secondary-button { min-height: 42px; border-radius: 11px; padding: 0 16px; font-weight: 750; font-size: 12px; }
.primary-button { border: 1px solid var(--accent); display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 7px 17px rgba(242,102,0,.2); }
.primary-button svg { width: 17px; height: 17px; }
.secondary-button { border: 1px solid var(--line); background: #fff; color: #5f646e; }
.rule-intro { display: grid; grid-template-columns: 1fr 50px 1fr 50px 1fr; align-items: center; padding: 18px 22px; margin-bottom: 17px; }
.rule-flow-step { padding: 13px; border-radius: 12px; background: var(--surface-2); }
.rule-flow-step span, .rule-flow-step strong { display: block; }
.rule-flow-step span { color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.rule-flow-step strong { margin-top: 4px; font-size: 11px; }
.rule-flow-step.accent { background: var(--accent-soft); color: var(--accent); }
.rule-flow-step.accent span { color: var(--accent); }
.rule-intro i { height: 1px; background: var(--line); position: relative; }
.rule-intro i::after { content: ""; position: absolute; right: 0; top: -3px; width: 7px; height: 7px; border-top: 1px solid #afb3bb; border-right: 1px solid #afb3bb; transform: rotate(45deg); }
.rules-list { display: grid; gap: 12px; }
.rule-card { display: grid; grid-template-columns: minmax(210px,.75fr) 1.5fr auto; align-items: center; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 5px 17px rgba(28,31,36,.04); }
.rule-main { display: flex; align-items: center; gap: 12px; }
.rule-number { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-weight: 850; }
.rule-main strong, .rule-main small { display: block; }
.rule-main strong { font-size: 13px; }
.rule-main small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.rule-logic { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logic-block { min-width: 0; flex: 1; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.logic-block span, .logic-block strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logic-block span { color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.logic-block strong { margin-top: 4px; font-size: 10px; }
.logic-block.action { background: var(--accent-soft); color: var(--accent); }
.rule-arrow { color: #b7bbc2; font-size: 17px; }
.rule-controls { display: flex; align-items: center; gap: 9px; }
.toggle { position: relative; width: 43px; height: 24px; border: 0; border-radius: 999px; background: #cfd2d7; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: .18s ease; }
.toggle.on { background: var(--green); }
.toggle.on::after { left: 22px; }
.rule-menu { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #7b8089; }

.event-table-card { padding: 18px; }
.event-filters { margin-bottom: 14px; }
.event-table { border-top: 1px solid var(--line); }
.event-row { display: grid; grid-template-columns: 145px 95px minmax(160px, .7fr) 1.5fr; gap: 14px; align-items: center; padding: 14px 8px; border-bottom: 1px solid var(--line); }
.event-row time { color: var(--muted); font-size: 10px; }
.event-severity { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 5px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.event-severity::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.event-severity.warning { background: var(--amber-soft); color: var(--amber); }
.event-severity.critical { background: var(--red-soft); color: var(--red); }
.event-title strong, .event-title small { display: block; }
.event-title strong { font-size: 11px; }
.event-title small, .event-message { color: var(--muted); font-size: 10px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-card { display: grid; grid-template-columns: 48px 1fr; gap: 15px; padding: 21px; }
.settings-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); background: var(--accent-soft); }
.settings-icon svg { width: 23px; height: 23px; }
.settings-card h3 { margin: 1px 0 6px; font-size: 14px; }
.settings-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.settings-card code { font-size: 9px; color: #555b65; }
.settings-state { display: flex; align-items: center; gap: 8px; margin-top: 13px; }
.settings-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.settings-state span.ok { background: var(--green); }
.settings-state span.error { background: var(--red); }
.settings-state strong { font-size: 10px; }
.settings-card .secondary-button { min-height: 34px; margin-top: 12px; padding: 0 12px; font-size: 10px; }
.technical-card { margin-top: 17px; padding: 22px; }
.demo-badge { padding: 6px 9px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 9px; font-weight: 850; }
.demo-badge.live { background: var(--green-soft); color: var(--green); }
.technical-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 30px; margin: 16px 0 0; }
.technical-list div { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.technical-list dt { color: var(--muted); font-size: 10px; }
.technical-list dd { margin: 0; font-size: 10px; font-weight: 700; text-align: right; }

.rule-dialog { width: min(640px, calc(100vw - 30px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 30px 90px rgba(15,17,20,.32); }
.rule-dialog::backdrop { background: rgba(17,19,23,.58); backdrop-filter: blur(3px); }
.rule-dialog form { padding: 23px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; }
.rule-dialog label { display: grid; gap: 7px; margin-bottom: 15px; color: #565b64; font-size: 10px; font-weight: 750; }
.rule-dialog input[type="text"], .rule-dialog input:not([type]), .rule-dialog select { width: 100%; height: 43px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; outline: 0; background: #fff; color: var(--text); }
.rule-dialog input:focus, .rule-dialog select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rule-dialog fieldset { border: 1px solid var(--line); border-radius: 13px; padding: 13px; }
.rule-dialog legend { padding: 0 7px; color: var(--muted); font-size: 10px; }
.check-row { display: flex !important; grid-template-columns: 18px 1fr; align-items: center; gap: 8px !important; margin: 7px 0 !important; }
.check-row input { accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; }
.toast { min-width: 270px; max-width: 420px; padding: 13px 15px; border-radius: 12px; background: #1f2227; color: #fff; box-shadow: 0 15px 40px rgba(0,0,0,.22); font-size: 11px; animation: toastIn .2s ease; }
.toast.error { border-left: 4px solid var(--red); }
.toast.success { border-left: 4px solid var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mobile-overlay { display: none; }

@media (max-width: 1180px) {
  .hero-grid { grid-template-columns: 1.4fr .8fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .sensor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-card { grid-template-columns: 1fr auto; }
  .rule-logic { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 920px) {
  :root { --sidebar-width: 225px; }
  .hero-grid, .dashboard-lower-grid { grid-template-columns: 1fr; }
  .health-list { grid-template-columns: repeat(3, 1fr); }
  .health-list > div { padding: 10px; }
  .settings-grid { grid-template-columns: 1fr; }
  .event-row { grid-template-columns: 125px 85px 1fr; }
  .event-message { grid-column: 3; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-overlay { position: fixed; inset: 0; z-index: 45; background: rgba(15,17,20,.5); }
  .mobile-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .mobile-menu { display: grid; }
  .topbar { padding: 10px 12px; min-height: 64px; gap: 10px; }
  .topbar-title span { font-size: 9px; letter-spacing: .12em; }
  .topbar-title h1 { font-size: 17px; }
  .presence-chip { width: 39px; min-width: 39px; padding: 0; justify-content: center; }
  .presence-chip > span:last-child { display: none; }
  .view { padding: 19px 15px 38px; }
  .hero-grid { gap: 14px; }
  .alarm-card, .health-card { padding: 19px; }
  .alarm-card h2 { font-size: 23px; }
  .shield-state { width: 54px; height: 54px; border-radius: 15px; }
  .mode-selector button { min-height: 67px; }
  .health-list { grid-template-columns: 1fr; }
  .metric-grid { gap: 10px; }
  .metric-card { min-height: 91px; padding: 13px; }
  .metric-icon { width: 42px; height: 42px; }
  .page-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; flex-basis: auto; width: 100%; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .filter-tabs button { white-space: nowrap; }
  .sensor-grid { grid-template-columns: 1fr; }
  .rule-intro { grid-template-columns: 1fr; gap: 7px; }
  .rule-intro i { width: 1px; height: 16px; margin-left: 23px; }
  .rule-intro i::after { right: -3px; top: auto; bottom: 0; transform: rotate(135deg); }
  .rule-card { grid-template-columns: 1fr auto; gap: 12px; }
  .rule-logic { overflow-x: auto; padding-bottom: 3px; }
  .logic-block { min-width: 150px; }
  .event-row { grid-template-columns: 1fr auto; gap: 7px; }
  .event-row time { grid-column: 1; grid-row: 1; }
  .event-severity { grid-column: 2; grid-row: 1; }
  .event-title, .event-message { grid-column: 1 / -1; }
  .technical-list { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 460px) {
  .topbar-actions { gap: 6px; }
  .icon-button { width: 39px; height: 39px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 82px; }
  .alarm-meta { grid-template-columns: 1fr 1fr; }
  .alarm-meta div:last-child { grid-column: 1 / -1; }
  .sensor-summary-strip { overflow-x: auto; white-space: nowrap; }
  .section-heading.rule-heading { align-items: flex-start; flex-direction: column; }
  .primary-button { width: 100%; }
}
.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mode-selector button:disabled,
.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.35);
}
.technical-list dd { overflow-wrap: anywhere; }


.sensor-card[data-sensor-history] { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.sensor-card[data-sensor-history]:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(28,31,36,.10); border-color: #c7cbd2; }
.sensor-card[data-sensor-history]:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.sensor-history-dialog { width: min(780px, calc(100vw - 24px)); max-height: min(86vh, 900px); border: 0; border-radius: 19px; padding: 0; background: #fff; box-shadow: 0 30px 90px rgba(15,17,20,.34); }
.sensor-history-dialog::backdrop { background: rgba(17,19,23,.58); backdrop-filter: blur(3px); }
.sensor-history-shell { padding: 23px; }
.sensor-history-dialog .dialog-head p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.sensor-history-current { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 18px; }
.sensor-history-current > div { padding: 12px; border-radius: 12px; background: var(--surface-2); }
.sensor-history-current span, .sensor-history-current strong { display: block; }
.sensor-history-current span { color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.sensor-history-current strong { margin-top: 5px; font-size: 11px; }
.sensor-history-list { max-height: 56vh; overflow: auto; border-top: 1px solid var(--line); }
.sensor-history-entry { display: grid; grid-template-columns: 12px minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 13px 5px; border-bottom: 1px solid var(--line); }
.sensor-history-entry .history-marker { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.sensor-history-entry .history-marker.open-change { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.sensor-history-entry .history-marker.battery-change { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.sensor-history-entry .history-marker.critical-change { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.sensor-history-entry strong, .sensor-history-entry small { display: block; }
.sensor-history-entry strong { font-size: 11px; }
.sensor-history-entry small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.sensor-history-entry time { color: var(--muted); font-size: 9px; text-align: right; }
@media (max-width: 620px) {
  .sensor-history-shell { padding: 18px; }
  .sensor-history-current { grid-template-columns: repeat(2, 1fr); }
  .sensor-history-entry { grid-template-columns: 12px 1fr; }
  .sensor-history-entry time { grid-column: 2; text-align: left; }
}


.sensor-history-actions {
  display: grid;
  gap: .55rem;
  padding: 0 0 1.15rem;
  border-bottom: 1px solid var(--line, #e5e7eb);
  margin-bottom: .35rem;
}
.sensor-history-actions small { color: var(--muted, #737780); line-height: 1.45; }
.battery-replaced-button { width: 100%; min-height: 46px; }
.sensor-history-current { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) {
  .sensor-history-current { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* Active XT1 alarm status */
.active-alarm-banner {
  display: none;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  padding: 15px 17px;
  border: 1px solid rgba(190, 24, 24, .25);
  border-radius: 16px;
  background: rgba(254, 226, 226, .92);
  color: #991b1b;
}
.active-alarm-banner.visible { display: flex; }
.active-alarm-banner[hidden] { display: none !important; }
.active-alarm-icon {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; flex: 0 0 42px;
  background: #dc2626; color: white;
}
.active-alarm-icon svg { width: 22px; height: 22px; }
.active-alarm-banner span { display: block; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.active-alarm-banner strong { display: block; margin-top: 2px; font-size: 17px; }
.active-alarm-banner small { display: block; margin-top: 3px; color: #7f1d1d; }

/* Polling configuration */
.polling-config-card { padding: 22px; margin-top: 20px; }
.polling-config-card .card-title-row { align-items: flex-start; }
.polling-config-card .card-title-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.poll-mode-badge { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.poll-mode-badge.live { color: var(--green); background: var(--green-soft); border-color: rgba(43,166,106,.25); }
.polling-settings-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.polling-settings-form label { display: flex; min-width: 0; flex-direction: column; gap: 5px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.polling-settings-form label > span { font-size: 11px; font-weight: 800; }
.polling-settings-form label > small { min-height: 38px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.seconds-input { display: flex; align-items: center; gap: 7px; margin-top: auto; }
.seconds-input input { width: 100%; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: #fff; color: var(--text); font-weight: 750; }
.seconds-input input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.seconds-input b { color: var(--muted); font-size: 10px; }
.polling-save-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 13px; padding-top: 2px; }
.polling-save-row .primary-button { width: auto; }
.polling-save-row small { color: var(--muted); font-size: 10px; }
@media (max-width: 1050px) { .polling-settings-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .polling-config-card { padding: 18px; }
  .polling-settings-form { grid-template-columns: 1fr; }
  .polling-settings-form label > small { min-height: 0; }
  .polling-save-row { align-items: stretch; flex-direction: column; }
  .polling-save-row .primary-button { width: 100%; }
}


/* v1.5.0 – multi-user and temporary guest access */
[hidden] { display: none !important; }
.logout-form { margin: 0; }
.compact-button { width: auto; min-height: 38px; padding: 0 14px; }
.compact-button svg { width: 16px; height: 16px; }
.user-management { margin-top: 17px; padding: 22px; }
.user-management-head { align-items: flex-start; gap: 20px; }
.user-management-head p { max-width: 720px; margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.access-principle { margin: 16px 0; padding: 12px 14px; border: 1px solid #dfe9ff; border-radius: 11px; background: #f6f9ff; color: #48536a; font-size: 10px; line-height: 1.5; }
.user-list { display: grid; gap: 11px; }
.user-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.user-row.inactive { opacity: .6; }
.user-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-avatar { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.user-avatar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.user-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.user-title-line strong { font-size: 12px; }
.user-title-line span, .user-title-line b { padding: 4px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 8px; font-weight: 800; }
.user-title-line b { background: var(--red-soft); color: var(--red); }
.user-row-main small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.user-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.access-action { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #555b65; font-size: 9px; font-weight: 750; }
.access-action:hover { border-color: var(--accent); color: var(--accent); }
.access-action.danger { color: var(--red); }
.grant-list { grid-column: 1 / -1; display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.grant-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); }
.grant-row strong { display: block; font-size: 9px; }
.grant-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.grant-status.active { color: var(--green); font-weight: 800; }
.grant-empty { color: var(--muted); font-size: 9px; }
.access-dialog input[type="datetime-local"], .access-dialog input[type="text"] { width: 100%; height: 43px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; outline: 0; background: #fff; color: var(--text); }
.access-dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.security-note { margin: 4px 0 0; padding: 11px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 10px; line-height: 1.5; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.credential-dialog { width: min(560px, calc(100vw - 30px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 30px 90px rgba(15,17,20,.32); }
.credential-dialog::backdrop { background: rgba(17,19,23,.58); backdrop-filter: blur(3px); }
.credential-content { padding: 23px; }
.credential-content > p { margin: -5px 0 16px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.credential-box { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.credential-box span { margin-top: 5px; color: var(--muted); font-size: 8px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.credential-box strong { font-size: 14px; }
.credential-box code { padding: 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.credential-box small { margin-top: 7px; color: var(--muted); font-size: 9px; }

.login-page { min-height: 100vh; margin: 0; display: grid; place-items: center; background: #f3f5f8; color: var(--text); }
.login-shell { width: 100%; padding: 24px; }
.login-card { width: min(430px, 100%); margin: auto; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 25px 70px rgba(28,31,36,.10); }
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand img { width: 42px; height: 42px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 12px; letter-spacing: .08em; }
.login-brand span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.login-heading { margin: 28px 0 20px; }
.login-heading h1 { margin: 4px 0 8px; font-size: 27px; }
.login-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.login-error { margin-bottom: 15px; padding: 11px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 10px; line-height: 1.45; }
.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 7px; color: #565b64; font-size: 10px; font-weight: 750; }
.login-form input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; outline: 0; font-size: 14px; }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-button { width: 100%; min-height: 46px; margin-top: 3px; }

  .user-management { padding: 16px; }
  .user-management-head { display: grid; grid-template-columns: 1fr; }
  .compact-button { width: 100%; }
  .user-row { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; flex-wrap: wrap; }
  .grant-row { align-items: flex-start; flex-direction: column; }
  .login-shell { padding: 15px; }
  .login-card { padding: 22px; border-radius: 16px; }
}



/* v1.5.2 – per-user admin notifications for alarm mode changes */
.notification-matrix { display: grid; gap: 6px; margin-top: 4px; }
.notification-matrix > div { display: grid; grid-template-columns: minmax(110px, 1fr) 96px 96px; align-items: center; gap: 8px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.notification-matrix .notification-matrix-head { min-height: 0; border: 0; background: transparent; color: var(--muted); font-size: 8px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.notification-matrix strong { font-size: 10px; }
.notification-matrix label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 9px; font-weight: 700; }
.notification-matrix input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.notification-matrix-dialog { margin: 15px 0 4px; }
.fieldset-hint { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; line-height: 1.45; }
@media (max-width: 520px) {
  .notification-matrix > div { grid-template-columns: minmax(88px, 1fr) 78px 78px; padding: 7px 8px; }
  .notification-matrix label span { display: none; }
  .notification-matrix label { justify-content: center; }
}


/* v1.5.3 – dedicated Benutzer & Gäste main navigation view */
#view-users .section-heading { align-items: center; }
#view-users .user-management { margin-top: 0; }
@media (max-width: 760px) {
  #view-users .section-heading { align-items: stretch; }
  #view-users .section-heading > .primary-button { width: 100%; justify-content: center; }
}
