/* RPC Casa — layout base no padrão RPC Suite (o tema fica em rpc-theme.css) */
:root {
  --bg-dark: #0a0a0f; --bg-card: #15151e; --bg-light: #1e1e2b;
  --primary: #00e68a; --secondary: #00cc77; --accent: #5e8cff;
  --warning: #ffb020; --danger: #ff5252; --success: #00d68f;
  --text: #f5f5f7; --text-muted: #a0a0b0; --border: #2a2a3a;
  --shadow: 0 8px 24px rgba(0, 0, 0, .3);
  --transition: all .25s cubic-bezier(.25, .8, .25, 1);
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --cool: #38bdf8; --heat: #fb923c;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body { font-family: 'Inter', 'Segoe UI', Arial, sans-serif; background: var(--bg-dark); color: var(--text); overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }

/* Cabeçalho */
.header { position: fixed; top: 0; left: 0; right: 0; height: 70px; padding: 0 20px; padding-top: env(safe-area-inset-top); display: flex; justify-content: space-between; align-items: center; z-index: 1000; background: linear-gradient(135deg, var(--bg-card) 0%, #1a1a25 100%); border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { font-size: 20px; }
.demo-badge { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; padding: 1px 8px; border-radius: 3px; color: var(--primary); border: 1px solid rgba(0, 230, 118, .4); background: rgba(0, 230, 118, .12); }
.user-info { display: flex; align-items: center; gap: 18px; }
.clock { font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.conn { display: flex; align-items: center; gap: 8px; font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px rgba(255, 176, 32, .15); }
.conn.ok .dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(0, 230, 118, .18); animation: pulse 2.4s infinite; }
.conn.off .dot { background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(0, 230, 118, 0); } }
.logout-btn { padding: 8px 18px; background: rgba(255, 82, 82, .1); border: 1px solid rgba(255, 82, 82, .3); color: var(--danger); border-radius: 8px; cursor: pointer; font-size: 14px; }

/* Menu lateral */
.sidebar { position: fixed; left: 0; top: 70px; width: 260px; height: calc(100vh - 70px); background: var(--bg-card); border-right: 1px solid var(--border); padding: 20px 0; overflow-y: auto; z-index: 900; }
.nav-section { margin-bottom: 22px; }
.nav-section-title { padding: 0 20px 10px; margin-bottom: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.nav-item { padding: 12px 20px; display: flex; align-items: center; gap: 12px; color: var(--text-muted); text-decoration: none; transition: var(--transition); position: relative; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.nav-item.active { background: rgba(0, 230, 138, .1); color: var(--primary); }
.nav-text { font-size: 14px; font-weight: 500; }
.nav-badge { margin-left: auto; font-family: var(--mono); font-size: 10px; padding: 1px 7px; border-radius: 4px; }
.nav-badge:empty { display: none; }

/* Conteúdo */
.main-content { margin-left: 260px; margin-top: 70px; padding: 26px; min-height: calc(100vh - 70px); max-width: 1500px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.eyebrow { font: 600 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 14px; }
.section-title h3 { font-size: 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.section-title h3 i { color: var(--primary); }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; transition: var(--transition); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title i { color: var(--primary); }

.kpi-card { position: relative; overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { flex-shrink: 0; display: grid; place-items: center; color: var(--primary); width: 48px; height: 48px; border-radius: 10px; background: rgba(0, 230, 118, .1); border: 1px solid rgba(0, 230, 118, .25); font-size: 19px; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Botões */
.action-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--border); background: rgba(255, 255, 255, .04); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500; transition: var(--transition); text-decoration: none; white-space: nowrap; }
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.primary { background: var(--primary); color: #04130a; border-color: var(--primary); font-weight: 700; }
.action-btn.primary:hover { filter: brightness(1.08); color: #04130a; }
.action-btn.danger { color: var(--danger); border-color: rgba(255, 82, 82, .35); background: rgba(255, 82, 82, .06); }
.action-btn.on { color: var(--primary); border-color: rgba(0, 230, 118, .5); background: rgba(0, 230, 118, .12); }
.action-btn.sm { padding: 6px 10px; font-size: 13px; }
.action-btn.icon { width: 38px; height: 38px; padding: 0; }
.action-btn.wide { width: 100%; padding: 12px; }
.action-btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.pill.ok { color: var(--primary); border-color: rgba(0, 230, 118, .35); background: rgba(0, 230, 118, .08); }
.pill.bad { color: var(--danger); border-color: rgba(255, 82, 82, .35); background: rgba(255, 82, 82, .08); }
.pill.warn { color: var(--warning); border-color: rgba(255, 176, 32, .35); background: rgba(255, 176, 32, .08); }
.pill.rec { color: #fff; background: var(--danger); border-color: var(--danger); }
.pill.rec::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 8px; font-size: 13.5px; background: linear-gradient(90deg, rgba(255, 176, 32, .10), rgba(255, 176, 32, .02)); border: 1px solid rgba(255, 176, 32, .22); border-left: 3px solid var(--warning); margin-bottom: 16px; }
.alert i { color: var(--warning); margin-top: 2px; }
.alert.info { background: linear-gradient(90deg, rgba(33, 150, 243, .10), rgba(33, 150, 243, .02)); border-color: rgba(33, 150, 243, .25); border-left-color: var(--accent); }
.alert.info i { color: var(--accent); }

/* Toggle */
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 26px; background: var(--bg-light); border: 1px solid var(--border); transition: var(--transition); cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; border-radius: 50%; background: var(--text-muted); transition: var(--transition); }
.switch input:checked + span { background: rgba(0, 230, 118, .25); border-color: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); background: var(--primary); }

/* Teclas de luz */
.light-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: 16px; min-height: 118px; border-radius: 12px; cursor: pointer; text-align: left; border: 1px solid var(--border); background: var(--bg-light); transition: var(--transition); user-select: none; }
.light-tile .bulb { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; color: var(--text-muted); background: rgba(255, 255, 255, .05); transition: var(--transition); }
.light-tile .lt-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.light-tile .lt-state { font: 600 10px var(--mono); letter-spacing: .12em; color: var(--text-muted); margin-top: 4px; }
.light-tile.on { border-color: rgba(255, 210, 90, .5); background: linear-gradient(160deg, rgba(255, 210, 90, .16), rgba(255, 210, 90, .03)); }
.light-tile.on .bulb { color: #1a1300; background: #ffd25a; box-shadow: 0 0 24px rgba(255, 210, 90, .55); }
.light-tile.on .lt-state { color: #ffd25a; }
.light-tile.busy { opacity: .6; }
.light-tile:active { transform: scale(.97); }

/* Câmeras */
.cam-card { padding: 0; overflow: hidden; }
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; display: block; overflow: hidden; }
.cam-view { max-height: 78vh; margin: 0 auto; }
.cam-card .cam-view { max-height: 520px; }
.cam-view img, .cam-view video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.cam-overlay { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: linear-gradient(180deg, rgba(0, 0, 0, .65), transparent); pointer-events: none; }
.cam-overlay .name { font-weight: 600; font-size: 14px; color: #fff; text-shadow: 0 1px 3px #000; }
.cam-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #8a9ca0; font-size: 13px; pointer-events: none; }
.cam-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; gap: 8px; }
.cam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.player { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.player-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 12px; background: var(--bg-card); border-top: 1px solid var(--border); }
.ptz { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); gap: 8px; justify-content: center; margin: 6px 0 14px; }
.ptz button { border-radius: 12px; border: 1px solid var(--border); background: var(--bg-light); color: var(--text); font-size: 18px; cursor: pointer; touch-action: none; user-select: none; transition: background .15s; }
.ptz button:active, .ptz button.pressing { background: rgba(0, 230, 118, .2); color: var(--primary); border-color: var(--primary); }
.ptz .center { border-radius: 50%; }
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg-light); border: 1px solid var(--border); }
.preset button.go { flex: 1; text-align: left; background: none; border: 0; cursor: pointer; font-weight: 500; }

/* Sliders e formulários */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--text-muted); }
.field > span { font-weight: 600; }
.form-control { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-light); color: var(--text); font-size: 14px; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 230, 118, .12); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.range { width: 100%; accent-color: var(--primary); }
.range-row { display: grid; grid-template-columns: 110px 1fr 38px; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 10px; color: var(--text-muted); }
.range-row b { font-family: var(--mono); color: var(--text); text-align: right; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-light); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted); transition: var(--transition); }
.chip.active { color: var(--primary); border-color: rgba(0, 230, 118, .5); background: rgba(0, 230, 118, .1); }
.chip:disabled { opacity: .4; cursor: not-allowed; }

/* Ar-condicionado */
.ac-wrap { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: center; }
.dial { position: relative; width: 300px; height: 300px; margin: 0 auto; }
.dial svg { width: 100%; height: 100%; transform: rotate(135deg); }
.dial .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dial .t-target { font-size: 68px; font-weight: 800; letter-spacing: -.05em; font-variant-numeric: tabular-nums; line-height: 1; }
.dial .t-target sup { font-size: 26px; font-weight: 600; vertical-align: top; margin-left: 2px; }
.dial .t-mode { font: 600 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.dial .t-room { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.dial-btns { display: flex; justify-content: center; gap: 22px; margin-top: -26px; position: relative; }
.dial-btns button { width: 56px; height: 56px; border-radius: 50%; font-size: 20px; }
.power-btn { width: 64px; height: 64px; border-radius: 50%; font-size: 22px; }
html[data-rpc-theme] .action-btn.power-btn.on { background: var(--primary) !important; color: #04130a !important; border-color: var(--primary) !important; box-shadow: 0 0 30px rgba(0, 230, 118, .35); }
html[data-rpc-theme] .action-btn.danger { color: var(--danger) !important; border-color: rgba(255, 82, 82, .35) !important; background: rgba(255, 82, 82, .06) !important; }
html[data-rpc-theme] .action-btn.on { color: var(--primary) !important; border-color: rgba(0, 230, 118, .5) !important; background: rgba(0, 230, 118, .12) !important; }
.ac-group { margin-bottom: 18px; }
.ac-group h4 { font: 600 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.ac-off .dial, .ac-off .ac-controls { opacity: .55; }
.temps { display: flex; gap: 22px; flex-wrap: wrap; }
.temps div { font-size: 13px; color: var(--text-muted); }
.temps b { display: block; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

/* Cenas */
.scene-btn { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; text-align: left; transition: var(--transition); width: 100%; }
.scene-btn:hover { border-color: rgba(0, 230, 118, .45); transform: translateY(-2px); }
.scene-btn .ic { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: rgba(0, 230, 118, .1); color: var(--primary); font-size: 18px; flex-shrink: 0; }
.scene-btn b { display: block; font-size: 14px; }
.scene-btn small { color: var(--text-muted); font-size: 12px; }
.scene-btn.running .ic { background: var(--primary); color: #04130a; }

/* Listas */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14px; }
.list-item .desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.ev-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-light); color: var(--text-muted); font-size: 14px; }
.ev-ic.motion { color: var(--warning); background: rgba(255, 176, 32, .1); }
.ev-ic.scene, .ev-ic.automation { color: var(--primary); background: rgba(0, 230, 118, .1); }
.ev-ic.error { color: var(--danger); background: rgba(255, 82, 82, .1); }
.ev-time { font: 500 12px var(--mono); color: var(--text-muted); white-space: nowrap; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; font-size: 14px; white-space: nowrap; }
.tab.active { color: var(--primary); border-color: rgba(0, 230, 118, .4); background: rgba(0, 230, 118, .1); }

.rec-card { padding: 0; overflow: hidden; cursor: pointer; }
.rec-thumb { aspect-ratio: 16 / 9; background: #050607; display: grid; place-items: center; color: #3b4a4e; font-size: 30px; position: relative; overflow: hidden; }
.rec-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rec-meta { padding: 10px 12px; font-size: 13px; }

/* Modal e toasts */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-content { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 22px; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); }
.modal-content.wide { width: min(1000px, 100%); }
.modal-content h3 { font-size: 18px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); animation: slidein .25s ease; display: flex; gap: 10px; align-items: center; }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

.action-row { display: grid; grid-template-columns: 1.2fr 1.6fr 90px 38px; gap: 8px; margin-bottom: 8px; align-items: center; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: inline-grid; place-items: center; width: 40px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-light); font-size: 12px; font-weight: 600; color: var(--text-muted); }
.days input:checked + span { color: var(--primary); border-color: var(--primary); background: rgba(0, 230, 118, .1); }

.rpc-theme-picks { display: flex; flex-wrap: wrap; gap: 20px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty i { font-size: 34px; margin-bottom: 12px; display: block; opacity: .5; }
.room-block { margin-bottom: 26px; }

/* Login */
.login-screen { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 520px at 100% -8%, rgba(0, 230, 118, .09), transparent), radial-gradient(700px 420px at 0% 110%, rgba(0, 184, 148, .07), transparent), var(--bg-dark); }
.login-card { width: min(380px, 100%); background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 32px 26px; text-align: center; box-shadow: 0 24px 64px rgba(0, 0, 0, .45); }
.login-card h1 { font-size: 24px; margin: 12px 0 4px; }
.login-card .muted { margin-bottom: 22px; font-size: 14px; }
.login-card .field { text-align: left; }
.login-logo { width: 64px; height: 64px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* Barra inferior (celular) */
.bottom-nav { display: none; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cam-layout { grid-template-columns: minmax(0, 1fr); }
  .ac-wrap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .clock { display: none; }
  .conn .conn-text { display: none; }
  .main-content { padding: 16px 14px calc(86px + env(safe-area-inset-bottom)) !important; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 950; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(9, 11, 13, .94); backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--text-muted); font-size: 10.5px; font-weight: 500; }
  .bottom-nav a i { font-size: 18px; }
  .bottom-nav a.active { color: var(--primary); }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: minmax(0, 1fr); }
  .page-head h2 { font-size: 22px !important; }
  .action-row { grid-template-columns: 1fr 1fr; }
  .dial { width: 260px; height: 260px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .main-content #kpis.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .main-content .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .kpi-card { padding: 14px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; font-size: 15px; }
  .kpi-value { font-size: 22px; }
}
html[data-rpc-theme="light"] .bottom-nav { background: rgba(244, 246, 251, .95); }
html[data-rpc-theme="light"] .light-tile { background: #fff; }
html[data-rpc-theme="light"] .light-tile.on { background: linear-gradient(160deg, #fff4cf, #fffaf0); border-color: #f2c94c; }
html[data-rpc-theme="light"] .light-tile.on .lt-state { color: #a16207; }
html[data-rpc-theme="light"] .header .logo h1, html[data-rpc-theme="light"] .rpc-nav-toggle { color: var(--text) !important; -webkit-text-fill-color: var(--text); }
html[data-rpc-theme="light"] .scene-btn, html[data-rpc-theme="light"] .kpi-card { background: #fff; }
html[data-rpc-theme="light"] .chip, html[data-rpc-theme="light"] .preset, html[data-rpc-theme="light"] .ptz button, html[data-rpc-theme="light"] .form-control { background: #fff; }
html[data-rpc-theme="light"] .login-screen { background: linear-gradient(165deg, #d2dae8 0%, #bcc7db 100%); }
html[data-rpc-theme="ocean"] .header { background: linear-gradient(135deg, #0d1626, #111b2e); }
html[data-rpc-theme="ocean"] .sidebar { background: #0c1424; }

/* ---------------- Casa 3D (planta isométrica) ---------------- */
.house-wrap { display: flex; flex-direction: column; gap: 14px; }
.house-stage { position: relative; background: radial-gradient(120% 90% at 50% 8%, rgba(94, 140, 255, .09), transparent 60%), var(--bg-card); border: 1px solid var(--border); border-radius: 16px; height: 460px; max-height: 62vh; overflow: auto; cursor: grab; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.house-stage.grabbing { cursor: grabbing; }
.house-svg { display: block; overflow: visible; }
.cam-pin { cursor: pointer; }
.cp-dot { fill: #213a5e; stroke: #5e8cff; stroke-width: 2; transition: stroke-width .15s; }
.cam-pin.on .cp-dot { fill: #2563c9; stroke: #bcd3ff; filter: drop-shadow(0 0 7px rgba(94, 140, 255, .85)); }
.cam-pin.rec .cp-dot { fill: var(--danger); stroke: #fff; }
.cam-pin:hover .cp-dot, .cam-pin:focus .cp-dot { stroke-width: 3.5; }
.cp-i { fill: #fff; font: 700 10px var(--mono, monospace); text-anchor: middle; pointer-events: none; }
.hroom { cursor: pointer; }
.hroom:focus { outline: none; }
.hr-top { fill: #242436; stroke: rgba(255, 255, 255, .10); stroke-width: 1; transition: fill .25s, filter .25s; }
.hr-right { fill: #14141d; stroke: rgba(0, 0, 0, .3); stroke-width: 1; transition: fill .25s; }
.hr-front { fill: #1b1b28; stroke: rgba(0, 0, 0, .3); stroke-width: 1; transition: fill .25s; }
.hroom.garden .hr-top { fill: #163220; stroke: rgba(0, 230, 138, .20); }
.hlot { fill: #0f1016; stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.hroom.ground .hr-top { fill: #1a241d; stroke: rgba(0, 230, 138, .14); stroke-width: 1; }
.hroom.ground:hover .hr-top, .hroom.ground:focus .hr-top { fill: #233528; filter: none; }
.hroom.ground.on .hr-top { fill: rgba(0, 230, 138, .16); }
.hdecor { pointer-events: none; }
.hgrass { fill: #2f7d4f; stroke: rgba(255, 255, 255, .12); stroke-width: 1; }
.hgrass-t { fill: #eafff2; font: 700 11px 'Inter', sans-serif; text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, .4); stroke-width: 2.5px; }
.hgrass-s { fill: #d4f5e1; font: 600 9px var(--mono, monospace); text-anchor: middle; }
.hr-front-lbl { fill: var(--text-muted); font: 600 9.5px var(--mono, monospace); text-anchor: middle; letter-spacing: .12em; text-transform: uppercase; }
.hroom:hover .hr-top, .hroom:focus .hr-top { fill: #30304a; filter: drop-shadow(0 0 10px rgba(94, 140, 255, .55)); }
.hroom.on .hr-top { fill: rgba(0, 230, 138, .22); filter: drop-shadow(0 0 16px rgba(0, 230, 138, .55)); }
.hroom.on .hr-right { fill: #0f3a28; }
.hroom.on .hr-front { fill: #134c33; }
.hr-name { fill: var(--text); font: 700 12px 'Inter', sans-serif; text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 3px; pointer-events: none; }
.hr-area { fill: var(--text-muted); font: 500 9.5px var(--mono, monospace); text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 2.5px; pointer-events: none; }
.hr-marks .mk { fill: #2a2a3a; stroke: var(--border); stroke-width: 1; }
.hr-marks .mk.on { fill: var(--primary); stroke: var(--primary); filter: drop-shadow(0 0 6px rgba(0, 230, 138, .75)); }
.hr-marks .mk-t { fill: #fff; font: 700 10px var(--mono, monospace); text-anchor: middle; pointer-events: none; }
.hr-marks .mk.on + .mk-t { fill: #04130a; }
.house-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; font-size: 13px; }
.house-legend span { display: inline-flex; align-items: center; gap: 7px; }
.modal-content { position: relative; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-light); color: var(--text-muted); cursor: pointer; z-index: 2; }
.modal-close:hover { color: var(--primary); border-color: var(--primary); }
.room-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding-right: 44px; }
.room-ic { flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: var(--primary); background: rgba(0, 230, 118, .1); border: 1px solid rgba(0, 230, 118, .25); }
.room-head h3 { margin: 0; font-size: 19px; display: block; }
.room-body { display: flex; flex-direction: column; gap: 14px; }
.room-cam { position: relative; display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 16 / 9; background: #000; }
.room-cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-cam-lbl { position: absolute; left: 8px; bottom: 8px; font-size: 12px; color: #fff; background: rgba(0, 0, 0, .55); padding: 3px 8px; border-radius: 6px; display: flex; gap: 6px; align-items: center; }
html[data-rpc-theme="light"] .hr-top { fill: #e8ecf5; stroke: rgba(0, 0, 0, .08); }
html[data-rpc-theme="light"] .hr-right { fill: #c6cfe0; }
html[data-rpc-theme="light"] .hr-front { fill: #d6ddeb; }
html[data-rpc-theme="light"] .hr-name { fill: #1a2233; stroke: rgba(255, 255, 255, .7); }
html[data-rpc-theme="light"] .hroom.garden .hr-top { fill: #cfe8d5; }
html[data-rpc-theme="light"] .hroom.on .hr-top { fill: rgba(0, 190, 115, .32); }

/* edícula como bloco único + cômodos (pisos) */
.hr-top.block { fill: #1d1d28; stroke: rgba(255, 255, 255, .08); }
.hr-top.brita { fill: url(#brita) !important; stroke: rgba(255, 255, 255, .05); }
.hr-sub { fill: var(--text-muted); font: 500 9px var(--mono, monospace); text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 2.5px; }
.hmuro { fill: #2b2b34; stroke: rgba(0, 0, 0, .35); }
.ed-outline { fill: none; stroke: rgba(255, 255, 255, .28); stroke-width: 2; pointer-events: none; }
.cp-cam rect, .cp-cam path { fill: #fff; }
.hconcreto { fill: #6d6d75; stroke: rgba(255, 255, 255, .14); stroke-width: 1; }
.hgate { pointer-events: none; }
.hgate-panel { fill: rgba(6, 6, 9, .9); stroke: #43434e; stroke-width: 1.5; }
.hgate-bar { stroke: #33333d; stroke-width: 2.5; stroke-linecap: round; }
.hgate-lbl { fill: var(--text-muted); font: 600 10px var(--mono, monospace); text-anchor: middle; letter-spacing: .12em; text-transform: uppercase; paint-order: stroke; stroke: rgba(0, 0, 0, .5); stroke-width: 2.5px; }
/* câmeras no poste */
.cp-pole { stroke: #5e8cff; stroke-width: 2; opacity: .5; }
.cam-pin.on .cp-pole { stroke: #8aa6ff; opacity: .8; }
/* veículos 3D */
.vehicle { pointer-events: none; }
.vehicle.absent { opacity: .25; }
.veh-top { stroke: rgba(0, 0, 0, .22); stroke-width: .5; }
.veh-side { stroke: rgba(0, 0, 0, .3); stroke-width: .5; }
.veh-wheel { fill: #16161a; stroke: #000; stroke-width: .5; }
.car-body { fill: #9aa0a6; } .car-body-sr { fill: #70767c; } .car-body-sf { fill: #7f858b; }
.car-cab { fill: #c2c9d0; } .car-cab-sr { fill: #878d95; } .car-cab-sf { fill: #9ba1a9; }
.veh-glass { fill: #2a3845; stroke: rgba(255,255,255,.08); stroke-width: .5; }
.veh-bed { fill: #5f656b; stroke: rgba(0,0,0,.3); stroke-width: .5; }
.moto-body { fill: #caa02a; } .moto-body-sr { fill: #8c6e16; } .moto-body-sf { fill: #a2801c; }
.moto-tank { fill: #edc652; } .moto-tank-sr { fill: #b58e20; } .moto-tank-sf { fill: #cfa42b; }
.moto-seat { fill: #2b2b30; } .moto-seat-sr { fill: #1c1c20; } .moto-seat-sf { fill: #232327; }
.moto-bar { stroke: #c9ced4; stroke-width: 2; stroke-linecap: round; }
.veh-ic .vi { fill: #d7dbe0; } .veh-ic .vi-w { fill: #16161a; }
.moto .veh-ic .vi { fill: #edc652; }
.veh-lbl rect { fill: #14141f; stroke: var(--border); stroke-width: 1; }
.veh-dot { fill: var(--primary); }
.veh-lbl.off .veh-dot { fill: var(--text-muted); }
.veh-lbl text { fill: #fff; font: 700 10px 'Inter', sans-serif; }
.veh-lbl.off text { fill: var(--text-muted); }
.rt { fill: #262636; stroke: rgba(255, 255, 255, .14); stroke-width: 1; transition: fill .25s; }
.tile { cursor: pointer; transition: transform .18s ease; }
.tile:hover, .tile:focus { transform: translateY(-10px); }
.tile:hover .rt, .tile:focus .rt { fill: #32324a; }
.tile.on .rt { fill: rgba(0, 230, 138, .16); }
.tile.acc-light .rt { fill: rgba(245, 196, 81, .2); }
.tile.acc-cool .rt { fill: rgba(56, 189, 248, .22); }
.tile.acc-heat .rt { fill: rgba(251, 146, 60, .24); }
.tile.acc-dry .rt { fill: rgba(167, 139, 250, .24); }
.tile.acc-fan .rt { fill: rgba(94, 234, 212, .22); }
.tile.acc-auto .rt { fill: rgba(52, 211, 153, .22); }
.tile.acc-eco .rt { fill: rgba(74, 222, 128, .26); }
.tile.on { filter: drop-shadow(0 0 13px rgba(0, 230, 138, .5)); }
.tile.acc-cool { filter: drop-shadow(0 0 13px rgba(56, 189, 248, .6)); }
.tile.acc-heat { filter: drop-shadow(0 0 13px rgba(251, 146, 60, .6)); }
.tile.acc-dry { filter: drop-shadow(0 0 13px rgba(167, 139, 250, .6)); }
.tile.acc-fan { filter: drop-shadow(0 0 13px rgba(94, 234, 212, .55)); }
.tile.acc-eco { filter: drop-shadow(0 0 13px rgba(74, 222, 128, .6)); }
.tile.acc-auto { filter: drop-shadow(0 0 13px rgba(52, 211, 153, .55)); }
/* emblemas (ar / luz) sobre o cômodo */
.hbadge .hb-bg { fill: #16161f; stroke: var(--border); stroke-width: 1.3; }
.hbadge.acc-cool .hb-bg { fill: #0f2b3e; stroke: #38bdf8; }
.hbadge.acc-heat .hb-bg { fill: #37220f; stroke: #fb923c; }
.hbadge.acc-dry .hb-bg { fill: #241a3f; stroke: #a78bfa; }
.hbadge.acc-fan .hb-bg { fill: #0f332f; stroke: #5eead4; }
.hbadge.acc-eco .hb-bg { fill: #103219; stroke: #4ade80; }
.hbadge.acc-auto .hb-bg { fill: #0f3324; stroke: #34d399; }
.hbadge.acc-light .hb-bg { fill: #332a0e; stroke: #f5c451; }
.hbadge.acc-off .hb-bg { fill: #16161f; stroke: var(--border); }
.hb-t { fill: #fff; font: 800 14px 'Inter', sans-serif; text-anchor: middle; }
.hb-i .gi-s { stroke: #fff; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hb-i .gi-f { fill: #fff; stroke: none; }
.hb-i .gi-s2 { stroke: #15351d; stroke-width: 1.2; fill: none; stroke-linecap: round; }
.hb-i .gi-t { fill: #fff; font: 800 11px var(--mono, monospace); text-anchor: middle; }
.hbadge.acc-off .hb-i .gi-s, .hbadge.acc-off .hb-t { opacity: .6; }
/* ícone de câmera no pino */
.cp-cam rect { fill: #fff; }
.cp-lens { fill: #213a5e; }
.cam-pin.on .cp-lens { fill: #2563c9; }
.cp-rec { fill: var(--danger); }
