:root {
    color-scheme: dark;
    --bg: #0b1119;
    --panel: #121a24;
    --card: #151f2b;
    --field: #0d151f;
    --border: #253346;
    --text: #f4f7f9;
    --muted: #9aabba;
    --green: #36d878;
    --green-dark: #0eaa56;
    --red: #ff7777;
    --blue: #55b7ff;
    --radius: 16px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
}
button, input, select, textarea, a { font: inherit; touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; line-height: 1.2; }

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--border);
    background: rgba(11, 17, 25, .96);
}
.logo { display: flex; align-items: center; gap: 14px; min-width: 0; font-weight: 750; }
.logo img { display: block; width: 104px; height: 48px; object-fit: contain; }
.app-title { padding-left: 14px; border-left: 1px solid var(--border); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.room-tabs { border-bottom: 1px solid var(--border); background: #0e1620; }
.room-tabs-inner { display: flex; gap: 8px; width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 10px 0; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.room-tabs-inner::-webkit-scrollbar { display: none; }
.room-tab { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 7px; min-height: 40px; border: 1px solid var(--border); border-radius: 999px; padding: 8px 13px; background: transparent; color: var(--muted); font-weight: 750; cursor: pointer; }
.room-tab span { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 999px; padding: 0 6px; background: var(--panel); color: #cbd6dd; font-size: .72rem; }
.room-tab.active { border-color: rgba(54,216,120,.55); background: rgba(54,216,120,.11); color: #d9f8e5; }
.room-tab.active span { background: var(--green); color: #07150c; }
.room-section[hidden] { display: none; }
.ghost, .primary, .icon-danger, .rf-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
}
.ghost { border-color: var(--border); background: transparent; color: #d7e0e7; }
.ghost:hover { background: var(--panel); }
.danger-text { color: #ff9a9a; }
.primary { background: var(--green); color: #06140b; }
.primary:hover { background: #55e68f; }
.primary:disabled, button:disabled { cursor: not-allowed; opacity: .45; }
.full { width: 100%; }

.container {
    width: min(1160px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 max(44px, env(safe-area-inset-bottom));
}
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.compact-hero { margin-bottom: 22px; }
.eyebrow { margin-bottom: 8px; color: var(--green); font-size: .78rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.muted { margin-bottom: 0; color: var(--muted); }
.summary-pill { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; padding: 8px 12px; color: #c9d5de; background: var(--panel); font-size: .88rem; }
.pulse, .status-dot, .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #607184; }
.pulse, .status-dot.online, .dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(54, 216, 120, .12); }
.dot.bad { background: var(--red); }

.alert { margin: 0 0 18px; border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; background: var(--panel); }
.alert.success { border-color: rgba(54,216,120,.4); color: #aef2c9; }
.alert.error { border-color: rgba(255,119,119,.45); color: #ffb5b5; }
.compact-alert { margin-top: 12px; margin-bottom: 0; padding: 9px 11px; font-size: .82rem; }
.room-section { margin-top: 30px; }
.room-heading, .section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.room-heading h2, .section-title h2 { margin: 0; font-size: 1.2rem; }
.room-heading > span, .section-title p { margin: 0; color: var(--muted); font-size: .88rem; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; }
.device-card, .connect-card, .empty-card, .settings-section, .device-setting-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}
.device-card { min-width: 0; padding: 17px; }
.vehicle-card { grid-column: 1 / -1; overflow: hidden; }
.device-card.offline { opacity: .65; }
.device-head, .device-setting-head { display: flex; align-items: center; gap: 12px; }
.device-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; background: rgba(54,216,120,.12); color: var(--green); font-size: 1.3rem; }
.device-title { min-width: 0; flex: 1; }
.device-title h2 { overflow-wrap: anywhere; font-size: 1rem; }
.device-title p, .device-setting-head small { display: block; margin: 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.single-control, .channel-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.single-control small { display: block; color: var(--muted); }
.channels { margin-top: 10px; }
.channel-row { margin-top: 0; }
.switch { position: relative; flex: 0 0 auto; width: 56px; height: 32px; border: 0; border-radius: 999px; padding: 3px; background: #3a4857; cursor: pointer; }
.switch span { display: block; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.switch.active { background: var(--green-dark); }
.switch.active span { transform: translateX(24px); }
.switch.small { width: 50px; height: 30px; }
.switch.small span { width: 24px; height: 24px; }
.switch.small.active span { transform: translateX(20px); }
.unsupported { margin-top: 15px; border-radius: 10px; padding: 11px; background: var(--field); color: var(--muted); font-size: .86rem; }
.sensor-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
.sensor-chip { display: flex; align-items: center; gap: 8px; min-width: 0; border: 1px solid var(--border); border-radius: 11px; padding: 10px; background: var(--field); }
.sensor-chip small { display: block; color: var(--muted); font-size: .7rem; }
.sensor-chip strong { font-size: 1rem; }
.sensor-chip strong span { margin-left: 2px; color: var(--muted); font-size: .75rem; }
.sensor-icon { font-size: 1.2rem; }
.vehicle-visual { position: relative; display: grid; place-items: center; min-height: 190px; margin: 14px -17px 0; overflow: hidden; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: radial-gradient(circle at 50% 72%, rgba(54,216,120,.22), transparent 38%), linear-gradient(180deg, #101a25 0%, #0d151f 100%); isolation: isolate; }
.vehicle-visual::before { content: ""; position: absolute; z-index: -1; width: 72%; height: 32%; bottom: 11%; border-radius: 50%; background: rgba(0,0,0,.46); filter: blur(18px); }
.vehicle-visual img { position: relative; z-index: 1; display: block; width: min(88%, 760px); height: auto; max-height: 265px; object-fit: contain; filter: drop-shadow(0 18px 20px rgba(0,0,0,.35)); }
.vehicle-visual-glow { position: absolute; inset: auto 8% 0; height: 2px; background: linear-gradient(90deg, transparent, var(--green), transparent); opacity: .75; }
.vehicle-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.vehicle-stats > div { min-width: 0; border: 1px solid var(--border); border-radius: 11px; padding: 10px; background: var(--field); }
.vehicle-stats small { display: block; color: var(--muted); font-size: .7rem; }
.vehicle-stats strong { display: block; margin-top: 2px; font-size: 1rem; overflow-wrap: anywhere; }
.vehicle-stats strong span { color: var(--muted); font-size: .75rem; }
.vehicle-status-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; color: #dbe5eb; font-size: .82rem; }
.tyre-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.tyre-grid > strong { grid-column: 1 / -1; font-size: .82rem; }
.tyre-grid span { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: .74rem; }
.tyre-grid b { color: #dce7ed; white-space: nowrap; }
.vehicle-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.vehicle-footer small { color: var(--muted); font-size: .72rem; }
.map-link { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 9px; padding: 7px 9px; color: #bdebd0; font-size: .76rem; font-weight: 700; }
.rf-controls { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.rf-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.rf-title small { color: var(--muted); }
.rf-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rf-button { width: 100%; min-width: 0; border-color: var(--border); background: var(--field); color: #dbe5eb; overflow-wrap: anywhere; }
.rf-button span { margin-right: 6px; color: var(--green); }
.connect-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 22px; }
.connect-card p, .empty-card p { margin: 0; color: var(--muted); }
.connect-icon { font-size: 2rem; color: var(--green); }
.empty-card { padding: 28px; text-align: center; }

.auth-page { display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.auth-card { width: min(100%, 470px); border: 1px solid var(--border); border-radius: 20px; padding: clamp(22px, 5vw, 36px); background: var(--card); }
.install-card { width: min(100%, 720px); }
.auth-logo { display: block; width: 168px; height: 78px; margin-bottom: 22px; object-fit: contain; object-position: left center; }
form label { display: block; color: #cbd5dc; font-size: .87rem; font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-height: 48px;
    margin-top: 6px;
    border: 1px solid #34465b;
    border-radius: 11px;
    padding: 11px 12px;
    background: var(--field);
    color: var(--text);
    font-size: 16px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(54,216,120,.12); }
.auth-card form { display: grid; gap: 16px; margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.requirements { display: grid; gap: 8px; margin-top: 20px; border-radius: 12px; padding: 14px; background: var(--field); color: #cbd6dd; }
.requirements > div { display: flex; align-items: center; gap: 9px; }

.organize-container { max-width: 980px; }
.settings-section { margin-bottom: 16px; padding: 18px; }
.tuya-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.tuya-form .primary, .tuya-form .security-note { grid-column: 1 / -1; }
.security-note { border-radius: 11px; padding: 12px; background: var(--field); color: var(--muted); font-size: .84rem; }
.add-room-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.add-room-form input { margin: 0; }
.room-editor { display: grid; gap: 10px; }
.room-edit-row { display: grid; grid-template-columns: 1fr 110px auto; align-items: end; gap: 10px; }
.order-field { max-width: 110px; }
.icon-danger { border-color: rgba(255,119,119,.35); background: transparent; color: #ff9c9c; }
.device-settings-list { display: grid; gap: 12px; }
.device-setting-card { padding: 16px; background: var(--panel); }
.device-setting-head > div:nth-child(2) { min-width: 0; flex: 1; }
.visibility-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.visibility-toggle input[type="checkbox"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.visibility-toggle span { width: 42px; height: 24px; border-radius: 999px; padding: 3px; background: #3a4857; }
.visibility-toggle span::after { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; content: ""; transition: transform .18s ease; }
.visibility-toggle input:checked + span { background: var(--green-dark); }
.visibility-toggle input:checked + span::after { transform: translateX(18px); }
.visibility-toggle em { color: var(--muted); font-style: normal; font-size: .82rem; }
.device-setting-fields { display: grid; grid-template-columns: 1.3fr 1fr 100px; gap: 10px; margin-top: 14px; }
.channel-name-editor { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.channel-name-editor p { margin: 2px 0 12px; color: var(--muted); font-size: .82rem; }
.channel-name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.save-bar { position: sticky; z-index: 10; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: rgba(18,26,36,.97); }
.save-bar span { color: var(--muted); font-size: .82rem; }

.admin-container { max-width: 1080px; }
.compact-hero { padding-bottom: 22px; }
.user-create-form { display: grid; grid-template-columns: 1fr 1fr .75fr; gap: 14px; }
.user-create-form .permission-editor, .user-create-form > .primary { grid-column: 1 / -1; }
.permission-editor { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: rgba(8,14,21,.35); }
.permission-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 2px 2px 7px; }
.permission-heading small, .permission-row small, .user-summary small, .log-table small { display: block; color: var(--muted); }
.permission-row { display: grid; grid-template-columns: minmax(180px, 1fr) 120px 120px; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding: 10px 2px 2px; }
.permission-row label { display: flex; align-items: center; gap: 8px; min-height: 38px; cursor: pointer; }
.permission-row input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--green); }
.permission-row input:disabled + span, .permission-row label:has(input:disabled) { cursor: not-allowed; opacity: .5; }
.permission-save { justify-self: end; margin-top: 6px; }
.user-list { display: grid; gap: 14px; }
.user-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--panel); }
.user-summary { display: flex; align-items: center; gap: 10px; }
.user-summary .dot { flex: 0 0 auto; }
.saved-permissions { margin-top: 14px; }
.user-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 14px; }
.user-actions form { margin: 0; }
.password-form { display: grid; grid-template-columns: minmax(180px, 280px) auto; align-items: end; gap: 8px; margin-right: auto !important; }
.password-form input { margin: 0; }
.log-filter { display: flex; align-items: end; gap: 10px; }
.log-filter label { width: min(100%, 340px); }
.log-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.log-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.log-table th, .log-table td { border-bottom: 1px solid var(--border); padding: 11px 9px; text-align: left; vertical-align: top; }
.log-table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.log-table td { min-width: 110px; }
.log-result { display: inline-block; border-radius: 999px; padding: 3px 7px; font-size: .7rem; font-weight: 800; }
.log-result.success { background: rgba(54,216,120,.14); color: #8cf0b5; }
.log-result.error { background: rgba(255,119,119,.14); color: #ffaaaa; }

.passkey-login { margin-top: 18px; }
.remember-device { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; cursor: pointer; }
.remember-device input { flex: 0 0 auto; width: 20px; min-height: 20px; height: 20px; margin: 1px 0 0; padding: 0; accent-color: var(--green); }
.remember-device span { min-width: 0; }
.remember-device strong, .remember-device small { display: block; }
.remember-device small { margin-top: 2px; color: var(--muted); font-size: .76rem; font-weight: 400; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: .78rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.passkey-error[hidden] { display: none; }
.passkey-setup > label { max-width: 480px; margin-bottom: 14px; }
.passkey-list { display: grid; gap: 10px; }
.passkey-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--panel); }
.passkey-item small { display: block; margin-top: 3px; color: var(--muted); }
.passkey-item form { margin: 0; }

.command-toast { position: fixed; z-index: 50; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); max-width: calc(100% - 28px); transform: translate(-50%, 20px); border: 1px solid rgba(54,216,120,.45); border-radius: 12px; padding: 11px 15px; background: #153122; color: #c7f6d9; opacity: 0; pointer-events: none; transition: .18s ease; }
.command-toast.error { border-color: rgba(255,119,119,.45); background: #3b1b20; color: #ffd0d0; }
.command-toast.visible { transform: translate(-50%, 0); opacity: 1; }
.command-feedback { animation: commandPulse .32s ease; }
@keyframes commandPulse { 50% { transform: scale(.94); } }

@supports (content-visibility: auto) {
    .device-card { content-visibility: auto; contain-intrinsic-size: auto 250px; }
    .vehicle-card { contain-intrinsic-size: auto 700px; }
}

@media (max-width: 720px) {
    .topbar { align-items: stretch; flex-direction: column; gap: 7px; min-height: 0; padding: max(9px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
    .logo { min-height: 40px; }
    .logo img { width: 78px; height: 40px; }
    .app-title { padding-left: 10px; font-size: .9rem; }
    .top-actions { width: 100%; gap: 6px; padding-bottom: 2px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .top-actions::-webkit-scrollbar { display: none; }
    .top-actions .ghost { flex: 0 0 auto; min-height: 40px; padding: 7px 11px; font-size: .78rem; }
    .room-tabs-inner { width: calc(100% - 24px); padding: 9px 0; }
    .room-tab { min-height: 38px; padding: 7px 12px; font-size: .82rem; }
    .container { width: min(100% - 24px, 1160px); padding-top: 28px; }
    .hero { align-items: flex-start; flex-direction: column; gap: 14px; }
    h1 { font-size: 2.15rem; }
    .device-grid { grid-template-columns: 1fr; }
    .vehicle-visual { min-height: 145px; }
    .vehicle-visual img { width: 96%; max-height: 210px; }
    .vehicle-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .connect-card { grid-template-columns: auto 1fr; }
    .connect-card form { grid-column: 1 / -1; }
    .connect-card .primary { width: 100%; }
    .form-grid, .channel-name-grid, .device-setting-fields, .tuya-form { grid-template-columns: 1fr; }
    .user-create-form { grid-template-columns: 1fr; }
    .user-create-form .permission-editor, .user-create-form > .primary { grid-column: auto; }
    .permission-heading { align-items: flex-start; flex-direction: column; }
    .permission-row { grid-template-columns: 1fr 1fr; }
    .permission-row > div { grid-column: 1 / -1; }
    .permission-save { justify-self: stretch; width: 100%; }
    .user-actions { align-items: stretch; flex-direction: column; }
    .user-actions form, .user-actions button { width: 100%; }
    .password-form { grid-template-columns: 1fr; margin-right: 0 !important; }
    .log-filter { align-items: stretch; flex-direction: column; }
    .log-filter label, .log-filter button { width: 100%; }
    .passkey-item { align-items: stretch; flex-direction: column; }
    .passkey-item button { width: 100%; }
    .order-field { max-width: none; }
    .room-edit-row { grid-template-columns: 1fr 86px; }
    .room-edit-row .icon-danger { grid-column: 1 / -1; }
    .add-room-form { grid-template-columns: 1fr; }
    .section-title { align-items: flex-start; flex-direction: column; }
    .save-bar { align-items: stretch; flex-direction: column; }
    .save-bar .primary { width: 100%; }
    input, select, textarea { font-size: 16px !important; }
}

@media (max-width: 390px) {
    .app-title { display: none; }
    .top-actions .ghost { padding-inline: 8px; }
    .rf-buttons { grid-template-columns: 1fr; }
    .vehicle-footer { align-items: flex-start; flex-direction: column; }
    .tyre-grid { grid-template-columns: 1fr; }
    .device-setting-head { flex-wrap: wrap; }
    .visibility-toggle { margin-left: 54px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Visual 2.0 — acabamento inspirado no design da Apple, sem alterar a camada funcional. */
:root {
    color-scheme: dark;
    --bg: #050506;
    --panel: rgba(29, 29, 31, .72);
    --card: rgba(28, 28, 30, .88);
    --field: rgba(118, 118, 128, .12);
    --border: rgba(255, 255, 255, .11);
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --green: #30d158;
    --green-dark: #28b84d;
    --red: #ff453a;
    --blue: #0a84ff;
    --radius: 22px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
}

html { background: #050506; scroll-behavior: smooth; }
body {
    position: relative;
    background:
        radial-gradient(circle at 16% -8%, rgba(10, 132, 255, .15), transparent 32rem),
        radial-gradient(circle at 92% 12%, rgba(94, 92, 230, .11), transparent 28rem),
        linear-gradient(180deg, #09090b 0%, #050506 55%, #09090b 100%);
    background-attachment: fixed;
    font-weight: 430;
    letter-spacing: -.01em;
}
body::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.013) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.013) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    content: "";
}

h1 { font-weight: 720; letter-spacing: -.055em; }
h2, h3 { font-weight: 650; letter-spacing: -.025em; }

.topbar {
    min-height: 68px;
    border-bottom-color: rgba(255,255,255,.08);
    background: rgba(10, 10, 12, .76);
    box-shadow: 0 1px 0 rgba(0,0,0,.24);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
}
.logo { font-weight: 640; letter-spacing: -.02em; }
.logo img { width: 94px; }
.app-title { border-left-color: rgba(255,255,255,.14); color: #e8e8ed; }
.top-actions { gap: 8px; }

.room-tabs {
    position: sticky;
    z-index: 15;
    top: 68px;
    border-bottom-color: rgba(255,255,255,.07);
    background: rgba(10,10,12,.68);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
}
.room-tab {
    min-height: 38px;
    border-color: transparent;
    background: rgba(118,118,128,.16);
    color: #c7c7cc;
    font-size: .85rem;
    font-weight: 590;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}
.room-tab:hover { background: rgba(118,118,128,.25); color: #fff; }
.room-tab:active { transform: scale(.97); }
.room-tab span { background: rgba(255,255,255,.08); color: #aeaeb2; }
.room-tab.active { border-color: rgba(10,132,255,.22); background: #0a84ff; color: #fff; box-shadow: 0 6px 20px rgba(10,132,255,.22); }
.room-tab.active span { background: rgba(255,255,255,.2); color: #fff; }

.ghost, .primary, .icon-danger, .rf-button {
    min-height: 44px;
    border-radius: 13px;
    font-weight: 600;
    letter-spacing: -.01em;
    transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ghost { border-color: rgba(255,255,255,.1); background: rgba(118,118,128,.13); color: #f5f5f7; }
.ghost:hover { border-color: rgba(255,255,255,.17); background: rgba(118,118,128,.24); }
.primary { background: #0a84ff; color: #fff; box-shadow: 0 8px 24px rgba(10,132,255,.2); }
.primary:hover { background: #2492ff; box-shadow: 0 10px 28px rgba(10,132,255,.28); }
.ghost:active, .primary:active, .icon-danger:active, .rf-button:active { transform: scale(.975); }
.danger-text { color: #ff6961; }

.container { width: min(1180px, calc(100% - 40px)); padding-top: 54px; }
.hero { margin-bottom: 34px; }
.hero h1 { max-width: 860px; }
.eyebrow { color: #64d2ff; font-size: .74rem; font-weight: 700; letter-spacing: .12em; }
.muted { color: var(--muted); }
.summary-pill {
    border-color: rgba(255,255,255,.1);
    background: rgba(44,44,46,.72);
    color: #d1d1d6;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.alert { border-radius: 16px; background: rgba(44,44,46,.74); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.alert.success { border-color: rgba(48,209,88,.28); background: rgba(48,209,88,.09); color: #8eeaa5; }
.alert.error { border-color: rgba(255,69,58,.3); background: rgba(255,69,58,.09); color: #ff9f9a; }

.device-grid { gap: 18px; }
.device-card, .connect-card, .empty-card, .settings-section, .device-setting-card, .user-card {
    border-color: rgba(255,255,255,.1);
    background: linear-gradient(145deg, rgba(36,36,39,.94), rgba(22,22,24,.9));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 18px 50px rgba(0,0,0,.2);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
}
.device-card { padding: 20px; transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease; }
.device-card:hover { border-color: rgba(255,255,255,.16); transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 24px 64px rgba(0,0,0,.3); }
.device-card.offline { opacity: .58; filter: saturate(.6); }
.device-icon { border: 1px solid rgba(100,210,255,.14); border-radius: 14px; background: rgba(10,132,255,.13); color: #64d2ff; }
.single-control, .channel-row, .vehicle-footer, .tyre-grid, .rf-controls { border-top-color: rgba(255,255,255,.09); }
.switch { background: rgba(118,118,128,.42); box-shadow: inset 0 1px 2px rgba(0,0,0,.2); }
.switch span { box-shadow: 0 2px 5px rgba(0,0,0,.35); }
.switch.active { background: #30d158; }
.sensor-chip, .vehicle-stats > div, .unsupported, .rf-button, .security-note {
    border-color: rgba(255,255,255,.08);
    background: rgba(118,118,128,.09);
}
.vehicle-visual {
    margin-inline: -20px;
    border-color: rgba(255,255,255,.08);
    background: radial-gradient(circle at 50% 78%, rgba(10,132,255,.22), transparent 38%), linear-gradient(180deg, #16161a, #0d0d0f);
}
.vehicle-visual-glow { background: linear-gradient(90deg, transparent, #64d2ff, transparent); }
.map-link { border-color: rgba(10,132,255,.22); background: rgba(10,132,255,.1); color: #64d2ff; }

input, select, textarea {
    min-height: 50px;
    border-color: rgba(255,255,255,.12);
    border-radius: 14px;
    background: rgba(118,118,128,.12);
    color: #f5f5f7;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.12);
}
input:hover, select:hover, textarea:hover { border-color: rgba(255,255,255,.19); }
input:focus, select:focus, textarea:focus { border-color: #0a84ff; box-shadow: 0 0 0 4px rgba(10,132,255,.18); }
form label { color: #d1d1d6; font-weight: 560; }

.auth-page {
    overflow: auto;
    background:
        radial-gradient(circle at 50% 18%, rgba(10,132,255,.2), transparent 25rem),
        radial-gradient(circle at 10% 85%, rgba(94,92,230,.13), transparent 22rem),
        #050506;
}
.auth-card {
    position: relative;
    overflow: hidden;
    width: min(100%, 456px);
    border-color: rgba(255,255,255,.13);
    border-radius: 30px;
    padding: clamp(28px, 6vw, 42px);
    background: linear-gradient(145deg, rgba(38,38,41,.86), rgba(18,18,20,.86));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 40px 100px rgba(0,0,0,.48);
    -webkit-backdrop-filter: saturate(150%) blur(30px);
    backdrop-filter: saturate(150%) blur(30px);
}
.auth-card::before { position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); content: ""; }
.auth-card h1 { margin-bottom: 8px; font-size: clamp(2.25rem, 9vw, 3.25rem); }
.auth-logo { width: 148px; height: 66px; margin-bottom: 28px; }
.passkey-login { position: relative; min-height: 54px; margin-top: 24px; border-radius: 16px; font-size: 1rem; }
.passkey-login::before { width: 18px; height: 18px; margin-right: 10px; border: 2px solid currentColor; border-radius: 6px; content: ""; box-shadow: inset 0 0 0 4px #0a84ff; }
.app-footer { display: flex; justify-content: center; padding-top: 8px; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.footer-alert-button { border: 0; padding: 8px 12px; background: transparent; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.footer-alert-button:hover, .footer-alert-button:focus-visible { color: #fff; text-decoration: underline; }
.remember-device { border-radius: 14px; padding: 12px; background: rgba(118,118,128,.08); }
.auth-divider { color: #8e8e93; }
.auth-divider::before, .auth-divider::after { background: rgba(255,255,255,.1); }
.auth-card form { margin-top: 18px; }
.permission-editor, .passkey-item { border-color: rgba(255,255,255,.09); background: rgba(118,118,128,.08); }
.save-bar { border-color: rgba(255,255,255,.12); background: rgba(28,28,30,.86); box-shadow: 0 16px 46px rgba(0,0,0,.34); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.command-toast { border-radius: 16px; background: rgba(24,73,40,.92); box-shadow: 0 16px 50px rgba(0,0,0,.4); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

@media (max-width: 720px) {
    .topbar { background: rgba(8,8,10,.86); }
    .room-tabs { top: 95px; }
    .container { width: min(100% - 28px, 1180px); padding-top: 34px; }
    .hero { margin-bottom: 26px; }
    .device-grid { gap: 14px; }
    .device-card { padding: 18px; }
    .vehicle-visual { margin-inline: -18px; }
    .auth-card { border-radius: 26px; }
}

@media (max-width: 390px) {
    .auth-page { padding-inline: 12px; }
    .auth-card { padding: 25px 20px; }
}
