:root {
  color-scheme: light;
  --canvas: #ffffff;
  --paper: #ffffff;
  --sky: #eff6ff;
  --sky-line: #1d4ed8;
  --ink: #171613;
  --ink-soft: #4e4b45;
  --line: #292722;
  --blue: #1d4ed8;
  --jade: #0f766e;
  --jade-soft: #f0fdfa;
  --green: #166534;
  --green-soft: #e5f4e9;
  --amber: #854d0e;
  --amber-soft: #fff1df;
  --red: #991b1b;
  --red-soft: #fff1f0;
  --shadow: 0 12px 30px rgba(40, 34, 24, .08);
  --ease: cubic-bezier(.2,.75,.25,1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); scroll-behavior: smooth; scrollbar-color: var(--blue) var(--sky); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--ink); background: var(--canvas); font-size: 16px; line-height: 1.5; }
::selection { color: var(--ink); background: #dbeafe; }
button, input, select { font: inherit; }
input, select { caret-color: var(--blue); }
button, a, summary, select, input[type="checkbox"] { touch-action: manipulation; }
button { color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; flex: none; }

.app-loader { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 24px; color: var(--ink); background: linear-gradient(155deg, #f5f9ff 0%, #fff 58%, #edf4ff 100%); opacity: 1; visibility: visible; transition: opacity .22s var(--ease), visibility .22s var(--ease); }
.app-loader.is-hiding { opacity: 0; visibility: hidden; pointer-events: none; }
.app-loader-content { display: grid; justify-items: center; text-align: center; }
.app-loader-mark { display: grid; width: 68px; height: 68px; place-items: center; margin-bottom: 18px; color: var(--blue); border: 1px solid #d5e4ff; border-radius: 20px; background: #fff; box-shadow: 0 8px 22px rgba(29, 78, 216, .09); }
.app-loader-mark svg { width: 38px; height: 38px; }
.app-loader-brand { color: var(--ink); font-size: 14px; font-weight: 800; letter-spacing: .16em; }
.app-loader-message { margin-top: 8px; color: #4b5563; font-size: 14px; }
.app-loader-spinner { width: 22px; height: 22px; margin-top: 24px; border: 2px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: app-loader-spin .85s linear infinite; }
@keyframes app-loader-spin { to { transform: rotate(360deg); } }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; transform: translateY(-160%); padding: 10px 14px; color: var(--paper); background: var(--ink); border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px; padding: calc(10px + env(safe-area-inset-top)) max(24px, calc((100vw - 1120px) / 2)) 10px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(14px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; color: var(--blue); border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg,var(--sky),var(--paper)); }
.brand-mark svg { width: 25px; height: 25px; }
.brand-copy { display: grid; line-height: 1.15; letter-spacing: .13em; }
.brand-copy strong { font-size: 12px; letter-spacing: .16em; }
.brand-copy small { margin-top: 4px; color: var(--ink-soft); font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.brand-copy i, .app-footer i { color: var(--jade); font-style: normal; }
.navigation-menu { position: relative; }
.navigation-menu > summary { display: inline-flex; min-height: 44px; align-items: center; gap: 9px; padding: 0 12px; list-style: none; cursor: pointer; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: var(--paper); font-size: 14px; font-weight: 650; }
.navigation-menu > summary::-webkit-details-marker { display: none; }
.navigation-menu > summary > svg:first-child { color: var(--blue); }
.navigation-menu .chevron { width: 16px; height: 16px; transition: transform .18s var(--ease); }
.navigation-menu[open] .chevron { transform: rotate(180deg); }
.nav-popover { position: absolute; z-index: 50; top: calc(100% + 8px); left: 0; display: grid; width: min(280px, calc(100vw - 32px)); gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); animation: menu-in .16s var(--ease) both; }
.nav-popover a { display: flex; min-height: 48px; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav-popover a:hover, .nav-popover a[aria-current="page"] { background: var(--sky); color: var(--blue); }
.nav-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: var(--paper); border: 1px solid rgba(41,39,34,.2); }
.nav-icon svg { width: 19px; height: 19px; }
.topbar-actions { gap: 9px; }
.account-menu { position: relative; }
.account-menu > summary { display: inline-flex; max-width: 145px; min-height: 40px; align-items: center; gap: 8px; overflow: hidden; padding: 0 12px; list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--paper); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary::before { display: grid; width: 24px; height: 24px; flex: none; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); background: var(--sky); content: "•"; }
.account-popover { position: absolute; z-index: 50; top: calc(100% + 8px); right: 0; width: max-content; max-width: calc(100vw - 24px); padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.account-popover button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; cursor: pointer; color: var(--ink); background: transparent; text-align: left; font-size: 13px; }
.account-popover button:hover { background: var(--sky); }
.status-badge { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-badge.vulnerable { color: #713b12; background: var(--amber-soft); }
.status-badge.connection-lost { color: var(--red); background: var(--red-soft); }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(22,101,52,.12); }
.status-dot.is-offline { background: var(--red); box-shadow: 0 0 0 3px rgba(153,27,27,.11); }
.status-dot.is-simulation { background: var(--blue); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.status-dot.is-live { animation: live-breathe 3.2s ease-in-out infinite; }

.main-shell { width: min(1120px, 100%); min-height: calc(100vh - 76px); margin: 0 auto; padding: 32px 24px calc(40px + env(safe-area-inset-bottom)); }
.gate-layout { display: grid; max-width: 990px; min-height: min(680px, calc(100vh - 140px)); grid-template-columns: 1.05fr .95fr; align-items: center; gap: clamp(28px, 6vw, 74px); margin: 0 auto; padding: clamp(22px, 5vw, 58px); border: 1.5px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.gate-intro { max-width: 410px; }
.gate-art { display: grid; width: min(100%, 320px); aspect-ratio: 1.55; place-items: center; margin: 0 0 24px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, var(--sky), var(--paper)); }
.gate-art svg { width: 80%; height: auto; max-height: 220px; }
.eyebrow { margin: 0; color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.gate-intro h1 { margin: 12px 0; font-size: clamp(38px, 5vw, 56px); line-height: 1.06; letter-spacing: -.045em; }
.gate-intro h1 span { color: var(--blue); }
.gate-description { max-width: 390px; margin: 0; color: var(--ink-soft); font-size: 16px; }
.auth-card { padding: clamp(22px, 3vw, 34px); border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.auth-heading h2 { margin: 4px 0 3px; font-size: 25px; letter-spacing: -.02em; }
.auth-heading p:last-child { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }
.form-stack { display: grid; gap: 9px; }
label { color: var(--ink); font-size: 14px; font-weight: 650; }
input:not([type="checkbox"]), select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #706d64; border-radius: 9px; color: var(--ink); background: #fff; font-size: 16px; }
input::placeholder { color: #5b5750; opacity: 1; }
input:focus, select:focus { border-color: var(--blue); outline: 3px solid rgba(29,78,216,.2); outline-offset: 1px; }
.field-hint { margin: 0; color: #4e4b45; font-size: 12px; }
.form-error { margin: 0; padding: 10px 12px; border: 1px solid var(--red); border-radius: 9px; color: #7f1d1d; background: var(--red-soft); font-size: 13px; }
.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--ink); background: var(--paper); font-size: 14px; font-weight: 700; text-decoration: none; transition: background .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease; }
.button:hover { background: var(--sky); border-color: var(--blue); }
.button:active { opacity: .82; }
.button:disabled { cursor: wait; opacity: .55; }
.button.is-loading::after { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; content: ""; animation: spin .8s linear infinite; }
.button svg { width: 18px; height: 18px; }
.button-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button-primary:hover { background: #1e40af; border-color: #1e40af; }
.button-secondary { color: var(--jade); background: var(--jade-soft); border-color: var(--jade); }
.button-secondary:hover { background: #ccfbf1; border-color: var(--jade); }
.button-danger { color: #7f1d1d; background: var(--red-soft); border-color: #991b1b; }
.button-danger:hover { background: #fee2e2; }
.door-actions .button-danger { color: var(--blue); background: var(--sky); border-color: var(--blue); }
.door-actions .button-danger:hover { background: #dbeafe; border-color: var(--blue); }
.button-quiet { min-height: 40px; padding: 0 13px; }
.button-wide { width: 100%; min-height: 50px; margin-top: 8px; }
.notice { display: flex; align-items: flex-start; gap: 11px; margin: 18px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--sky); }
.notice p { margin: 0; color: var(--ink); font-size: 13px; }
.notice strong { display: inline-block; margin-bottom: 2px; }
.notice code { font-size: 13px; font-weight: 700; }
.notice-warning { color: #713b12; border-color: #8a541a; background: var(--amber-soft); }
.notice-warning p { color: #593210; }
.notice-symbol { display: grid; width: 24px; height: 24px; flex: none; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-weight: 800; }

.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 4px 0 28px; }
.dashboard-heading h1 { margin: 5px 0 2px; font-size: clamp(29px, 4vw, 40px); line-height: 1.13; letter-spacing: -.04em; }
.dashboard-heading h1 span { color: var(--blue); }
.dashboard-heading > div > p:last-child { margin: 0; color: var(--ink-soft); }
.connection-card { display: flex; min-width: 190px; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.connection-card > div { display: grid; line-height: 1.35; }
.connection-card span { color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.connection-card strong { font-size: 14px; }
.connection-card small { color: var(--ink-soft); font-size: 12px; }
.notice-lab { margin: -9px 0 22px; }
.section-heading { display: flex; min-height: 58px; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading h2 { margin: 4px 0 0; font-size: clamp(23px, 3vw, 30px); line-height: 1.15; letter-spacing: -.025em; }
.updated-label { color: var(--ink-soft); font-size: 12px; }
.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.device-card { min-width: 0; padding: 19px; border: 1.5px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: var(--shadow); transition: border-color .2s ease, box-shadow .2s ease; }
.device-card:hover { border-color: var(--blue); box-shadow: 0 14px 32px rgba(40,34,24,.11); }
.device-card.is-busy { border-color: var(--blue); }
.device-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device-icon { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--blue); background: var(--sky); }
.device-icon svg { width: 22px; height: 22px; }
.device-label { color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.device-card h3 { margin: 13px 0 2px; font-size: 19px; line-height: 1.22; }
.device-card .device-description { margin: 0; color: var(--ink-soft); font-size: 13px; }
.device-state-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 12px; }
.state-pill { display: inline-flex; min-height: 30px; align-items: center; gap: 8px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; }
.state-pill::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.state-pill.open { color: #713b12; border-color: #854d0e; background: var(--amber-soft); }
.state-pill.on { color: var(--jade); border-color: var(--jade); background: var(--jade-soft); }
.state-pill.closed, .state-pill.off { color: #36332d; background: #efede7; }
.state-pill.unknown { color: var(--blue); border-color: var(--blue); background: var(--sky); }
.state-caption { color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.door-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.door-actions .button { min-height: 46px; padding: 0 10px; }
.door-actions .button svg { width: 16px; height: 16px; }
.light-control { display: flex; align-items: center; gap: 12px; margin-top: 17px; padding-top: 15px; border-top: 1px solid #b9b5aa; }
.light-control:first-of-type { margin-top: 14px; }
.light-room-icon { display: grid; width: 36px; height: 36px; flex: none; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--blue); background: var(--sky); }
.light-room-icon svg { width: 19px; height: 19px; }
.light-copy { display: grid; flex: 1; min-width: 0; }
.light-copy strong { font-size: 14px; }
.light-copy small { color: var(--ink-soft); font-size: 11px; }
.switch-button { position: relative; width: 64px; height: 44px; flex: none; padding: 3px; border: 1px solid #706d64; border-radius: 999px; cursor: pointer; background: #ddd8ce; transition: background .22s ease, border-color .22s ease; }
.switch-button::before { position: absolute; top: 10px; left: 5px; width: 22px; height: 22px; border: 1px solid #706d64; border-radius: 50%; background: #fff; content: ""; transition: transform .22s var(--ease); }
.switch-button[aria-checked="true"] { border-color: var(--jade); background: var(--jade); }
.switch-button[aria-checked="true"]::before { transform: translateX(30px); border-color: var(--jade); }
.switch-button:disabled { cursor: wait; opacity: .55; }
.state-note { display: flex; align-items: flex-start; gap: 9px; max-width: 800px; margin: 18px 0 0; color: var(--ink-soft); font-size: 12px; }
.state-note svg { width: 17px; height: 17px; margin-top: 2px; color: var(--blue); }

.info-strip { display: flex; min-height: 62px; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--sky); }
.info-icon { display: grid; width: 35px; height: 35px; flex: none; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.info-icon svg { color: var(--blue); }
.info-strip p { flex: 1; margin: 0; color: var(--ink-soft); font-size: 13px; }
.info-strip strong { min-width: 30px; text-align: right; font-size: 20px; }
.event-list { display: grid; gap: 9px; }
.event-row { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; gap: 12px; align-items: start; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.event-mark { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--blue); }
.event-mark.warning, .event-mark.high { background: #a85c00; }
.event-mark.error { background: var(--red); }
.event-copy { display: grid; gap: 3px; min-width: 0; }
.event-copy strong { font-size: 14px; }
.event-copy p { margin: 0; color: var(--ink-soft); font-size: 13px; overflow-wrap: anywhere; }
.event-copy small, .event-time { color: var(--ink-soft); font-size: 11px; }
.event-time { white-space: nowrap; }
.empty-state { display: grid; min-height: 150px; place-content: center; gap: 4px; padding: 20px; border: 1px dashed #706d64; border-radius: 13px; background: var(--paper); text-align: center; }
.empty-state p { margin: 0; color: var(--ink-soft); }

.user-layout { display: grid; grid-template-columns: minmax(260px,.85fr) minmax(0,1.15fr); gap: 14px; align-items: start; }
.users-list { display: grid; gap: 8px; }
.user-row { display: grid; width: 100%; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; color: var(--ink); background: var(--paper); text-align: left; transition: background .18s ease, border-color .18s ease; }
.user-row:hover, .user-row[aria-pressed="true"] { border-color: var(--blue); background: var(--sky); }
.avatar { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); background: var(--paper); font-weight: 750; }
.user-row-copy { display: grid; min-width: 0; }
.user-row-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.user-row-copy small { color: var(--ink-soft); font-size: 11px; }
.user-row-status { padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 700; white-space: nowrap; }
.user-row-status.expired, .user-row-status.inactive { color: #713b12; background: var(--amber-soft); }
.user-detail { min-height: 220px; padding: 17px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid #b9b5aa; }
.detail-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.detail-identity h3 { margin: 0; overflow-wrap: anywhere; font-size: 19px; }
.detail-identity p { margin: 1px 0 0; color: var(--ink-soft); font-size: 12px; }
.detail-status { color: var(--green); font-size: 12px; font-weight: 700; }
.detail-status.expired, .detail-status.inactive { color: #713b12; }
.detail-section { padding-top: 13px; }
.detail-section h4 { margin: 0 0 9px; font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-item { display: grid; gap: 2px; min-width: 0; }
.detail-item span { color: var(--ink-soft); font-size: 11px; }
.detail-item strong { overflow-wrap: anywhere; font-size: 12px; font-weight: 600; }
.permission-list { display: flex; flex-wrap: wrap; gap: 6px; }
.permission-chip { padding: 4px 8px; border: 1px solid var(--blue); border-radius: 999px; color: var(--blue); background: var(--sky); font-size: 11px; font-weight: 650; }
.detail-editor { display: grid; gap: 11px; margin-top: 15px; padding-top: 13px; border-top: 1px solid #b9b5aa; }
.check-row { display: flex; min-height: 43px; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 550; }
.check-row input { width: 18px; height: 18px; flex: none; accent-color: var(--blue); }
.detail-permissions { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 9px 10px; border: 1px solid #706d64; border-radius: 10px; }
.detail-permissions legend, .permission-fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 750; }
.detail-editor select { min-height: 44px; font-size: 14px; }
.account-active { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-active label { display: flex; min-height: 44px; align-items: center; gap: 9px; font-size: 13px; }
.account-active input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); }
.detail-actions { display: flex; justify-content: flex-end; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; }
.permission-fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; margin: 3px 0 0; padding: 8px 10px; border: 1px solid #706d64; border-radius: 10px; }
.duration-field { display: grid; gap: 8px; }

.app-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 14px; border-top: 1px solid #b9b5aa; color: var(--ink-soft); font-size: 11px; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; color: var(--blue); background: var(--paper); }
.icon-button:hover { background: var(--sky); }
.icon-button svg { width: 19px; height: 19px; }
.app-dialog { width: min(520px, calc(100vw - 24px)); max-height: min(90vh, 850px); padding: 0; overflow: auto; border: 1.5px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 70px rgba(23,22,19,.25); }
.app-dialog::backdrop { background: rgba(23,22,19,.43); backdrop-filter: blur(3px); }
.dialog-content { display: grid; gap: 8px; padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.dialog-heading h2 { margin: 3px 0 0; font-size: 24px; }
.dialog-close { font-size: 24px; line-height: 1; }
.toast-region { position: fixed; z-index: 100; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: grid; width: min(380px, calc(100vw - 32px)); gap: 8px; }
.toast { padding: 12px 14px; border: 1px solid var(--green); border-radius: 11px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s var(--ease) both; }
.toast.error { border-color: var(--red); background: var(--red-soft); }
.toast.warning { border-color: var(--amber); background: var(--amber-soft); }
.screen-view.view-enter { animation: view-in .18s var(--ease) both; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
button, a, summary, select { cursor: pointer; }

@keyframes view-in { from { opacity: .45; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes live-breathe { 50% { box-shadow: 0 0 0 5px rgba(22,101,52,.08); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  .main-shell { padding-top: 40px; }
  .device-card { padding: 22px; }
  .user-detail { padding: 21px; }
}
@media (max-width: 720px) {
  .topbar { min-height: 68px; padding-right: 16px; padding-left: 16px; }
  .topbar-left { gap: 10px; }
  .brand { gap: 8px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-copy strong { font-size: 10px; }
  .brand-copy small { font-size: 8px; }
  .topbar-actions { gap: 7px; }
  .account-menu > summary { max-width: 100px; min-height: 36px; gap: 5px; padding: 0 8px; font-size: 11px; }
  .account-menu > summary::before { width: 20px; height: 20px; }
  .status-badge { min-height: 34px; gap: 6px; padding: 0 8px; font-size: 10px; }
  .status-dot { width: 7px; height: 7px; }
  .button-quiet { min-height: 36px; padding: 0 9px; font-size: 12px; }
  .navigation-menu > summary { min-height: 40px; gap: 6px; padding: 0 9px; font-size: 12px; }
  .navigation-menu > summary > svg:first-child { width: 18px; height: 18px; }
  .navigation-menu .chevron { display: none; }
  .main-shell { padding: 22px 16px calc(30px + env(safe-area-inset-bottom)); }
  .gate-layout { min-height: auto; grid-template-columns: 1fr; gap: 22px; padding: 18px; border-radius: 17px; }
  .gate-intro { display: grid; grid-template-columns: 112px 1fr; align-items: center; column-gap: 16px; max-width: none; }
  .gate-art { grid-row: span 3; width: 112px; aspect-ratio: 1; margin: 0; border-radius: 14px; }
  .gate-art svg { width: 100%; height: auto; }
  .gate-intro .eyebrow { font-size: 9px; }
  .gate-intro h1 { margin: 5px 0; font-size: 30px; }
  .gate-description { grid-column: 1 / -1; margin-top: 14px; font-size: 14px; }
  .auth-card { padding: 18px; }
  .dashboard-heading { align-items: flex-start; margin-bottom: 20px; }
  .dashboard-heading > div > p:last-child { max-width: 420px; font-size: 14px; }
  .connection-card { min-width: 0; padding: 9px; }
  .connection-card span { font-size: 8px; }
  .connection-card strong { font-size: 12px; }
  .connection-card small { font-size: 10px; }
  .device-grid { gap: 10px; }
  .device-card { padding: 14px; }
  .device-card h3 { font-size: 17px; }
  .device-card .device-description { font-size: 12px; }
  .door-actions { gap: 6px; }
  .door-actions .button { min-height: 44px; padding: 0 7px; font-size: 12px; }
  .device-icon { width: 37px; height: 37px; }
  .device-label { font-size: 9px; }
  .user-layout { grid-template-columns: 1fr; }
  .users-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 410px) {
  .topbar { gap: 7px; padding-right: 10px; padding-left: 10px; }
  .topbar-left { gap: 7px; }
  .brand-copy { letter-spacing: .08em; }
  .brand-copy strong { font-size: 9px; }
  .brand-copy small { font-size: 7px; letter-spacing: .12em; }
  .navigation-menu > summary { gap: 0; padding: 0 8px; }
  .navigation-menu > summary span { display: none; }
  .status-badge { width: 34px; max-width: 34px; justify-content: center; overflow: hidden; padding: 0; font-size: 0; }
  .account-menu > summary { width: 34px; max-width: 34px; justify-content: center; gap: 0; padding: 0; font-size: 0; }
  .account-menu > summary::before { width: 22px; height: 22px; }
  .button-quiet { padding: 0 7px; font-size: 11px; }
  .main-shell { padding-right: 12px; padding-left: 12px; }
  .gate-layout { padding: 14px; }
  .gate-intro { grid-template-columns: 88px 1fr; column-gap: 11px; }
  .gate-art { width: 88px; }
  .gate-intro h1 { font-size: 25px; }
  .gate-intro .eyebrow { font-size: 8px; letter-spacing: .08em; }
  .dashboard-heading { gap: 8px; }
  .dashboard-heading h1 { font-size: 27px; }
  .connection-card { gap: 7px; }
  .connection-card > div { max-width: 75px; }
  .device-grid { grid-template-columns: 1fr; }
  .device-card { padding: 16px; }
  .device-card h3 { font-size: 18px; }
  .door-actions .button { font-size: 13px; }
  .users-list { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .app-footer { flex-direction: column; gap: 3px; font-size: 10px; }
}
@media (max-width: 350px) {
  .brand-copy { display: none; }
  .dashboard-heading { flex-direction: column; }
  .connection-card { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .app-loader { transition: none; }
  .app-loader-spinner { animation: none; border-top-color: var(--blue); opacity: .72; }
}

.push-controls{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:12px 0;padding:16px 18px;border:1px solid var(--line);border-radius:14px;background:var(--paper)}
.push-controls>div:first-child{display:grid;gap:5px;min-width:0}
.push-controls strong{font-size:13px;color:var(--ink)}
.push-controls p{margin:0;color:var(--ink-soft);font-size:11px;line-height:1.5}
.push-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;flex:none}
@media(max-width:650px){.push-controls{align-items:stretch;flex-direction:column;padding:14px}.push-actions{justify-content:stretch}.push-actions .button{flex:1}}
