:root {
  color: var(--tg-theme-text-color, #eef3ff);
  background: var(--tg-theme-bg-color, #071637);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }
body { margin: 0; min-width: 280px; height: 100vh; height: var(--magmon-viewport-height, var(--tg-viewport-stable-height, 100dvh)); background: var(--tg-theme-bg-color, #071637); }

#app { display: flex; flex-direction: column; height: 100%; margin: 0 auto; max-width: 700px; overflow: hidden; padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }

.app-header { align-items: center; display: flex; flex: 0 0 auto; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
.identity { min-width: 0; }
.identity-name { font-size: 1rem; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-role { color: var(--tg-theme-hint-color, #aab9d6); font-size: .86rem; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; }

.action-button, .device-card { font: inherit; }
.action-button { background: var(--tg-theme-secondary-bg-color, #193b82); border: 0; border-radius: 10px; color: inherit; min-height: 40px; padding: 8px 12px; }
.action-button:focus-visible, .device-card:focus-visible { outline: 3px solid var(--tg-theme-button-color, #4385ff); outline-offset: 2px; }

.screen-content { display: flex; flex: 1 1 auto; flex-direction: column; gap: 9px; min-height: 0; overflow: hidden; }
.section-heading { font-size: .78rem; font-weight: 800; letter-spacing: .08em; margin: 0 0 8px; text-transform: uppercase; }
.list-title { align-items: center; display: flex; justify-content: space-between; margin-bottom: 8px; }
.list-title .section-heading { margin: 0; }
.add-device-button { min-height: 36px; padding: 6px 10px; }
.device-list { align-content: start; display: grid; flex: 1 1 auto; gap: 9px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.admin-user-list { align-content: start; display: grid; flex: 1 1 auto; gap: 9px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.admin-user-card { background: var(--tg-theme-secondary-bg-color, #17418f); border: 1px solid rgba(143, 208, 255, .34); border-radius: 12px; color: inherit; font: inherit; padding: 10px; text-align: left; width: 100%; }
button.admin-user-card { cursor: pointer; }
.admin-user-card.restricted { opacity: .68; }
.device-card { background: var(--tg-theme-secondary-bg-color, #17418f); border: 1px solid rgba(143, 208, 255, .34); border-radius: 15px; color: inherit; cursor: pointer; padding: 12px; text-align: left; width: 100%; }
.device-card.blocked { border-color: rgba(238, 169, 78, .72); }
.device-card-top { align-items: start; display: flex; gap: 8px; justify-content: space-between; }
.device-name { font-size: 1rem; font-weight: 750; line-height: 1.2; }
.hwsn { color: var(--tg-theme-hint-color, #bed0f2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; margin-top: 3px; }
.connectivity, .blocked-state { border-radius: 999px; font-size: .75rem; font-weight: 750; padding: 5px 8px; white-space: nowrap; }
.online { background: #188e61; }.delayed { background: #b57b19; }.offline { background: #a83f54; }.no-data { background: #586477; }.blocked-state { background: #9a6c20; }
.telemetry { display: grid; gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
.metric { background: rgba(4, 21, 61, .56); border-radius: 9px; min-width: 0; padding: 7px 8px; }
.metric-label { color: var(--tg-theme-hint-color, #b9c8e9); font-size: .72rem; }
.metric-value { font-size: .92rem; font-weight: 720; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-message { background: var(--tg-theme-secondary-bg-color, #12316d); border-radius: 12px; line-height: 1.45; margin: 0; padding: 14px; }
.error { border-left: 4px solid #d65162; }.activation { border-left: 4px solid #df9a32; }.placeholder { border-left: 4px solid #5594ff; }
.device-detail { display: flex; flex: 1 1 auto; flex-direction: column; gap: 9px; min-height: 0; overflow: hidden; }
.device-detail > .connectivity { align-self: start; }
.property-list { align-content: start; display: grid; flex: 1 1 auto; gap: 7px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.property-row { background: var(--tg-theme-secondary-bg-color, #17418f); border: 1px solid rgba(143, 208, 255, .27); border-radius: 11px; display: grid; gap: 3px; padding: 9px 10px; }
.property-title { font-size: .92rem; font-weight: 720; }
.property-code { color: var(--tg-theme-hint-color, #b9c8e9); font-size: .74rem; }
.property-value { font-size: 1rem; font-weight: 750; }
.property-observed { color: var(--tg-theme-hint-color, #b9c8e9); font-size: .74rem; }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.settings-section { background: var(--tg-theme-secondary-bg-color, #17418f); border: 1px solid rgba(143, 208, 255, .27); border-radius: 12px; display: grid; gap: 9px; padding: 11px; }
.settings-section-title { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.settings-section-title .section-heading { margin: 0; }
.settings-content { overflow-y: auto; padding-right: 2px; }
.settings-current-state, .settings-timezone { color: var(--tg-theme-hint-color, #b9c8e9); font-size: .78rem; }
.settings-label { color: var(--tg-theme-hint-color, #b9c8e9); font-size: .78rem; font-weight: 700; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.choice-button { background: rgba(4, 21, 61, .56); border: 1px solid rgba(143, 208, 255, .34); border-radius: 9px; color: inherit; font: inherit; min-height: 38px; padding: 7px 10px; }
.choice-button.selected { background: var(--tg-theme-button-color, #4385ff); border-color: var(--tg-theme-button-color, #4385ff); }
.save-report { justify-self: start; }
.time-input { background: rgba(4, 21, 61, .56); border: 1px solid rgba(143, 208, 255, .34); border-radius: 9px; color: inherit; font: inherit; min-height: 40px; padding: 7px 9px; }
.add-device-form { display: grid; gap: 8px; min-height: 0; overflow-y: auto; }
.text-input { background: rgba(4, 21, 61, .56); border: 1px solid rgba(143, 208, 255, .34); border-radius: 9px; color: inherit; font: inherit; min-height: 40px; padding: 7px 9px; }
.add-device-error { margin: 0; }
.success { border-left: 4px solid #188e61; }

@media (max-width: 360px) { .telemetry { grid-template-columns: 1fr; } #app { padding-inline: 10px; } }
