:root {
  --app-sidebar-w: 220px;
  --app-chrome-h: 44px;
  --app-topbar-h: 56px;
  --app-mobile-nav-h: 62px;
  --app-bg: #f4f6f9;
  --app-surface: #ffffff;
  --app-sidebar-bg: #0f1419;
  --app-sidebar-text: rgba(255, 255, 255, 0.72);
  --app-sidebar-active: #ffffff;
  --app-accent: #3b82f6;
  --app-accent-soft: rgba(59, 130, 246, 0.12);
  --app-radius: 12px;
  --app-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--app-bg);
  color: #1e293b;
}

.session-expiry-banner {
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  text-align: center;
}

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59, 130, 246, 0.15), transparent),
    var(--app-bg);
}

.login-screen-inner {
  min-height: calc(100vh - 2rem);
  min-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.login-screen-inner .login-card {
  width: 100%;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--app-radius);
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.login-logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--app-accent);
}

/* ── App shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--app-sidebar-w);
  flex-shrink: 0;
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.app-brand:hover {
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
}

.app-brand .login-logo {
  font-size: 1.05rem;
  color: #60a5fa;
}

.app-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-brand-text {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.25;
  color: #fff;
  letter-spacing: -0.02em;
}

.app-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.65rem;
  overflow-y: auto;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--app-sidebar-text);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.app-nav-item i {
  font-size: 1.15rem;
  opacity: 0.85;
}

.app-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-nav-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: var(--app-sidebar-active);
}

.app-nav-item.active i {
  opacity: 1;
  color: #60a5fa;
}

.app-sidebar-foot {
  padding: 1rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.app-user-label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-body {
  flex: 1;
  margin-left: var(--app-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.app-chrome {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--app-chrome-h);
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top, 0px);
  background: linear-gradient(105deg, #0f172a 0%, #1e293b 55%, #0f172a 100%);
  color: #f8fafc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 1035;
}

.app-chrome-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.app-chrome-brand:hover {
  color: #fff;
}

.app-chrome-brand .login-logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #60a5fa;
}

.app-chrome-brand-text {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.app-chrome-product {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.app-brand-mark--chrome {
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
  border-radius: 8px;
}

.app-chrome-tagline {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  flex-shrink: 0;
}

.app-chrome-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.app-chrome-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.35);
  white-space: nowrap;
}

.app-chrome-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(248, 250, 252, 0.75);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.app-chrome-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.app-chrome-user {
  font-size: 0.8125rem;
  color: rgba(248, 250, 252, 0.55);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar {
  height: var(--app-topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--app-surface);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  position: sticky;
  top: var(--app-chrome-h);
  z-index: 1020;
}

.app-topbar-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.app-page-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.app-topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 480px;
}

.app-topbar-end {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-ghost {
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

.btn-ghost:hover {
  background: var(--app-bg);
  color: #1e293b;
}

.global-search-input {
  padding-left: 2.25rem;
  border-radius: 999px;
  border-color: rgba(15, 23, 42, 0.1);
  background: var(--app-bg);
  font-size: 0.875rem;
}

.global-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  z-index: 1;
}

.app-main {
  flex: 1;
  padding: 1.25rem;
  overflow-x: hidden;
}

.app-panel {
  animation: panel-in 0.2s ease;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #64748b;
  font-size: 0.9rem;
}

/* ── Centro de comando ── */
.command-center {
  max-width: 1400px;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: left;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-card-sub {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.5;
}

.stat-card-label {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

.stat-card-success .stat-card-value { color: #16a34a; }
.stat-card-info .stat-card-value { color: #0284c7; }
.stat-card-accent .stat-card-value { color: #7c3aed; }

.command-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.command-panel {
  background: var(--app-surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--app-radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--app-shadow);
}

.command-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.command-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin: 0 0 0.75rem;
}

.command-panel-head .command-panel-title {
  margin-bottom: 0;
}

.command-space-filter {
  max-width: 160px;
  font-size: 0.8rem;
}

.command-events {
  max-height: 360px;
  overflow-y: auto;
}

.command-attention {
  background: var(--app-surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--app-radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--app-shadow);
}

.command-attention-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.attention-count {
  background: #dc2626;
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 1.5rem;
}

.attention-empty {
  padding: 0.25rem 0;
}

.attention-empty-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
  font-size: 0.875rem;
}

.attention-empty-inner i {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.attention-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
}

.attention-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  align-items: center;
  gap: 0.65rem 0.85rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: var(--app-bg);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.attention-row:hover {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  transform: translateX(2px);
}

.attention-row.is-offline {
  opacity: 0.85;
  background: rgba(220, 38, 38, 0.04);
}

.attention-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.attention-row-danger .attention-row-icon {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.attention-row-warning .attention-row-icon {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
}

.attention-row-info .attention-row-icon {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.attention-row-neutral .attention-row-icon {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

.attention-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.attention-row-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attention-row-space {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attention-row-kind {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #94a3b8;
  white-space: nowrap;
}

.attention-row-reason {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.attention-row-danger .attention-row-reason {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.attention-row-warning .attention-row-reason {
  background: rgba(234, 179, 8, 0.15);
  color: #a16207;
}

.attention-row-info .attention-row-reason {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.attention-row-neutral .attention-row-reason {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.attention-row-status {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.attention-row-status.is-online {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.attention-row-status.is-offline {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

@media (max-width: 768px) {
  .attention-row {
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto auto;
  }

  .attention-row-kind,
  .attention-row-reason,
  .attention-row-status {
    grid-column: 2;
  }

  .attention-row-kind {
    justify-self: start;
  }

  .attention-row-reason {
    justify-self: start;
  }

  .attention-row-status {
    position: absolute;
    right: 0.85rem;
    top: 0.65rem;
  }

  .attention-row {
    position: relative;
    padding-right: 4.5rem;
  }
}

/* ── Notificações animadas ── */
.notification-stack {
  position: fixed;
  top: calc(var(--app-chrome-h, 44px) + var(--app-topbar-h, 56px) + 0.75rem);
  right: 0.75rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(360px, calc(100vw - 1.5rem));
  pointer-events: none;
}

.notify-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 0 0.65rem;
  padding: 0.75rem 0.85rem 0.65rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateX(110%);
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  position: relative;
}

.notify-toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.notify-toast.is-leaving {
  opacity: 0;
  transform: translateX(110%);
  transition-duration: 0.22s;
}

.notify-toast-icon {
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.notify-toast-error .notify-toast-icon {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.notify-toast-warning .notify-toast-icon {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
}

.notify-toast-info .notify-toast-icon {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.notify-toast-success .notify-toast-icon {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

.notify-toast-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.notify-toast-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.notify-toast-msg {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.35;
  color: #1e293b;
}

.notify-toast-close {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 0.15rem;
  cursor: pointer;
  align-self: start;
}

.notify-toast-close:hover {
  color: #475569;
}

.notify-toast-progress {
  grid-column: 1 / -1;
  height: 3px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 0 0 12px 12px;
  margin: 0.45rem -0.85rem -0.65rem;
  overflow: hidden;
  position: relative;
}

.notify-toast-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: left;
  animation: notify-progress linear forwards;
}

.notify-toast.is-paused .notify-toast-progress::after {
  animation-play-state: paused;
}

.notify-toast-error .notify-toast-progress::after { background: #dc2626; }
.notify-toast-warning .notify-toast-progress::after { background: #eab308; }
.notify-toast-info .notify-toast-progress::after { background: #3b82f6; }
.notify-toast-success .notify-toast-progress::after { background: #16a34a; }

@keyframes notify-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 991px) {
  .notification-stack {
    top: auto;
    bottom: calc(var(--app-mobile-nav-h, 62px) + 0.75rem);
    right: 0.65rem;
    left: 0.65rem;
    width: auto;
  }
}

.attention-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attention-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: var(--app-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  max-width: 220px;
}

.attention-chip:hover {
  border-color: var(--app-accent);
  background: var(--app-accent-soft);
}

.attention-chip.is-offline {
  opacity: 0.65;
  border-style: dashed;
}

.attention-chip-kind {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.attention-chip-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.attention-chip-reason {
  font-size: 0.72rem;
  color: #dc2626;
  font-weight: 500;
}

/* ── Dispositivos ── */
.devices-toolbar {
  margin-bottom: 1rem;
}

.space-tabs-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.space-tabs-wrap::-webkit-scrollbar {
  display: none;
}

.space-tabs {
  display: flex;
  gap: 0.4rem;
  min-width: min-content;
}

.space-tab {
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--app-surface);
  color: #475569;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.space-tab:hover {
  border-color: var(--app-accent);
  color: var(--app-accent);
}

.space-tab.active {
  background: var(--app-accent);
  border-color: var(--app-accent);
  color: #fff;
}

.devices-filters {
  margin-bottom: 0.5rem;
}

.devices-meta {
  margin-top: 0.35rem;
}

.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.device-grid-item {
  background: var(--app-surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.devices-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

#favorites-section {
  margin-bottom: 1rem;
}

/* ── Automação ── */
.automation-view {
  max-width: 1200px;
}

.automation-tabs .nav-link {
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  color: #64748b;
}

.automation-tabs .nav-link.active {
  background: var(--app-accent);
}

.automation-pane {
  background: var(--app-surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--app-radius);
  padding: 1.25rem;
  box-shadow: var(--app-shadow);
}

/* ── Mobile nav ── */
.app-mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  display: flex;
  background: var(--app-surface);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  padding: 0.3rem 0;
  padding-bottom: max(0.3rem, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
}

.app-mobile-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  border: none;
  background: transparent;
  font-size: 0.62rem;
  font-weight: 500;
  color: #94a3b8;
  padding: 0.35rem 0.2rem;
}

.app-mobile-btn i {
  font-size: 1.2rem;
}

.app-mobile-btn.active {
  color: var(--app-accent);
}

/* ── Sync indicator (topbar claro) ── */
.app-topbar .sync-indicator {
  color: #64748b;
  font-size: 0.75rem;
}

.app-topbar .sync-label {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsivo ── */
@media (max-width: 991px) {
  .app-sidebar {
    display: none;
  }

  .app-body {
    margin-left: 0;
  }

  .app-main {
    padding-bottom: calc(var(--app-mobile-nav-h) + 0.5rem);
  }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .command-grid {
    grid-template-columns: 1fr;
  }

  .app-topbar-center {
    display: none;
  }

  .app-chrome {
    gap: 0.45rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .app-chrome-badge {
    display: none;
  }

  .app-chrome-user {
    display: none !important;
  }
}

@media (max-width: 575px) {
  .app-chrome-brand .app-brand-mark--chrome {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .app-chrome-brand .login-logo {
    font-size: 1.05rem;
  }

  .app-chrome-product {
    font-size: 0.9rem;
  }
}

@media (max-width: 575px) {
  .stat-cards {
    grid-template-columns: 1fr 1fr;
  }

  .devices-grid {
    grid-template-columns: 1fr;
  }

  .app-main {
    padding: 0.85rem;
  }
}

/* ── Modo imersivo (câmeras / locks) ── */
body.app-immersive .app-body {
  margin-left: 0;
}

body.camera-wall-mode #view-camera-wall,
body.lock-wall-mode #view-lock-wall {
  position: fixed;
  top: var(--app-chrome-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  padding: 0;
}

body.camera-wall-mode .app-topbar {
  display: none;
}

body.camera-wall-mode .notification-stack {
  top: calc(var(--app-chrome-h, 44px) + 0.75rem);
}

body.camera-wall-mode .app-main,
body.lock-wall-mode .app-main {
  padding: 0;
}

@media (max-width: 991px) {
  body.app-immersive .app-mobile-nav {
    display: none;
  }
}

.qr-image {
  max-width: 240px;
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}

.space-item.active {
  background-color: var(--bs-primary-bg-subtle);
  border-left: 3px solid var(--bs-primary);
  font-weight: 600;
}

.section-title {
  color: var(--bs-secondary-color);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

/* ── Device avatar ── */
.device-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
}

.device-avatar-md {
  width: 44px;
  height: 44px;
}

.device-avatar-lg {
  width: 56px;
  height: 56px;
}

.device-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
  background: #fff;
}

.device-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px;
}

.device-avatar-fallback svg {
  width: 100%;
  height: 100%;
}

.device-avatar.tone-info { background: rgba(var(--bs-info-rgb), 0.12); color: var(--bs-info); border-color: rgba(var(--bs-info-rgb), 0.25); }
.device-avatar.tone-dark { background: rgba(var(--bs-dark-rgb), 0.1); color: var(--bs-dark); border-color: rgba(var(--bs-dark-rgb), 0.2); }
.device-avatar.tone-warning { background: rgba(var(--bs-warning-rgb), 0.15); color: #b8860b; border-color: rgba(var(--bs-warning-rgb), 0.3); }
.device-avatar.tone-primary { background: rgba(var(--bs-primary-rgb), 0.1); color: var(--bs-primary); border-color: rgba(var(--bs-primary-rgb), 0.25); }
.device-avatar.tone-success { background: rgba(var(--bs-success-rgb), 0.1); color: var(--bs-success); border-color: rgba(var(--bs-success-rgb), 0.25); }
.device-avatar.tone-secondary { background: var(--bs-secondary-bg); color: var(--bs-secondary); }

/* ── Device cards ── */
.device-card {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
}

.device-card:hover {
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.09);
  transform: translateY(-1px);
}

.device-offline {
  opacity: 0.72;
}

.device-card-header {
  padding: 0.875rem 0.875rem 0.5rem;
}

.device-card-name {
  font-size: 0.925rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.device-card-category {
  display: block;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  margin-top: 0.1rem;
}

.device-card-status {
  flex-shrink: 0;
}

.device-card-body {
  padding: 0 0.875rem 0.625rem;
  flex-grow: 1;
}

.device-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem 0.875rem;
  margin-top: auto;
  border-top: 1px solid var(--bs-border-color-translucent);
}

.device-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.device-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 2rem;
  line-height: 1.4;
}

.device-chip-online { background: rgba(var(--bs-success-rgb), 0.12); color: var(--bs-success); }
.device-chip-offline { background: var(--bs-secondary-bg); color: var(--bs-secondary); }
.device-chip-locked { background: rgba(var(--bs-secondary-rgb), 0.15); color: var(--bs-secondary); }
.device-chip-unlocked { background: rgba(var(--bs-success-rgb), 0.12); color: var(--bs-success); }
.device-chip-neutral { background: var(--bs-tertiary-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color-translucent); }
.device-chip-battery { background: rgba(var(--bs-warning-rgb), 0.12); color: #9a7b00; }
.device-chip-live { background: rgba(var(--bs-info-rgb), 0.12); color: var(--bs-info); }

/* Power toggle on card */
.device-card-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.device-power-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color-translucent);
}

.device-power-label {
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.device-power-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.device-power-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.device-power-track {
  display: block;
  width: 2.4rem;
  height: 1.35rem;
  background: var(--bs-secondary-bg);
  border-radius: 1rem;
  border: 1px solid var(--bs-border-color);
  position: relative;
  transition: background 0.2s;
}

.device-power-btn.is-on .device-power-track {
  background: var(--bs-success);
  border-color: var(--bs-success);
}

.device-power-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.35rem - 6px);
  height: calc(1.35rem - 6px);
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.device-power-btn.is-on .device-power-thumb {
  transform: translateX(1rem);
}

.device-power-state {
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
  min-width: 3.2rem;
  text-align: right;
}

.device-power-btn.is-on .device-power-state {
  color: var(--bs-success);
  font-weight: 600;
}

/* ── Detail header ── */
.device-detail-type {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.35rem;
}

.device-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ── Sensor grid ── */
.sensor-grid-items {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

@media (max-width: 400px) {
  .sensor-grid-items {
    grid-template-columns: 1fr;
  }
}

.sensor-grid-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color-translucent);
  min-width: 0;
}

.sensor-grid-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bs-secondary-color);
}

.sensor-grid-value {
  font-size: 0.85rem;
  font-weight: 500;
  word-break: break-word;
}

.control-readonly {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

.control-readonly-label {
  color: var(--bs-secondary-color);
}

.control-readonly-value {
  font-weight: 500;
}

.control-item .form-range {
  cursor: pointer;
}

.json-editor {
  font-size: 0.8rem;
}

#device-offcanvas {
  width: min(420px, 100vw);
}

#device-offcanvas.offcanvas-camera {
  width: min(560px, 100vw);
}

#device-offcanvas.offcanvas-lock {
  width: min(480px, 100vw);
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.ptz-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  max-width: 180px;
}

.ptz-btn {
  aspect-ratio: 1;
  font-size: 1rem;
  line-height: 1;
  padding: 0.35rem;
}

.ptz-btn:active {
  background-color: var(--bs-primary);
  color: #fff;
  border-color: var(--bs-primary);
}

.lock-status-card {
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

.lock-state-locked {
  border-color: var(--bs-secondary);
  background: var(--bs-secondary-bg);
}

.lock-state-unlocked {
  border-color: var(--bs-success);
  background: rgba(var(--bs-success-rgb), 0.08);
}

.lock-state-unknown {
  border-color: var(--bs-warning);
  background: rgba(var(--bs-warning-rgb), 0.08);
}

.lock-counter {
  font-weight: normal;
}

.enum-group .btn.active {
  font-weight: 600;
}

/* ── Monitor imersivo de câmeras ── */
body.camera-wall-mode {
  overflow: hidden;
  background: #0a0a0a;
}

body.camera-wall-mode #main-nav {
  background: #111 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.camera-wall-mode #main-nav .navbar-brand {
  font-size: 0.85rem;
  opacity: 0.7;
}

#view-camera-wall {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0a0a0a;
}

#camera-wall-root {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.camera-wall-header {
  flex-shrink: 0;
  background: #111;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.camera-wall-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
}

.camera-wall-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.camera-wall-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
}

.camera-wall-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.camera-wall-picker-panel {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  max-height: 40vh;
  overflow-y: auto;
  background: #161616;
}

.camera-wall-picker-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.camera-wall-picker-toolbar .form-control {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.camera-wall-picker-toolbar .form-control::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.camera-wall-picker-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.camera-picker-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.35rem;
}

.camera-wall-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.camera-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.camera-picker-chip.is-selected {
  background: rgba(var(--bs-primary-rgb), 0.25);
  border-color: var(--bs-primary);
}

.camera-picker-chip.is-offline {
  opacity: 0.5;
}

.camera-picker-check {
  margin: 0;
  cursor: pointer;
}

.camera-picker-name {
  font-weight: 500;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-picker-status {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
}

.camera-wall-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.camera-wall-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.camera-wall-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.95rem;
}

.camera-wall-grid-immersive {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
  gap: 3px;
  padding: 3px;
  background: #000;
}

@media (min-width: 1600px) {
  .camera-wall-grid-immersive {
    grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
  }
}

.camera-wall-tile-immersive {
  position: relative;
  background: #111;
  overflow: hidden;
}

.camera-wall-tile-immersive.is-offline .camera-wall-video-wrap {
  background: #1a1a1a;
}

.camera-wall-tile-immersive .camera-wall-video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.camera-wall-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-wall-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 25%, transparent 75%, rgba(0,0,0,0.5) 100%);
}

.camera-wall-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.camera-wall-space {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.camera-wall-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

.camera-wall-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
}

.camera-wall-badge.online {
  background: rgba(25, 135, 84, 0.9);
  color: #fff;
}

.camera-wall-badge.offline {
  background: rgba(108, 117, 125, 0.85);
  color: #fff;
}

.camera-wall-hover-actions {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.35rem;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.camera-wall-tile-immersive:hover .camera-wall-hover-actions {
  opacity: 1;
  pointer-events: auto;
}

.camera-wall-hover-actions .btn {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  opacity: 0.9;
}

/* Layout presets monitor */
.camera-wall-grid-immersive.layout-2 {
  grid-template-columns: repeat(2, 1fr);
}

.camera-wall-grid-immersive.layout-3 {
  grid-template-columns: repeat(3, 1fr);
}

body.camera-wall-chrome-hidden #view-camera-wall {
  top: 0;
}

body.camera-wall-chrome-hidden #main-nav {
  display: none;
}

/* Modo foco 1-up */
.camera-wall-focus {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.camera-wall-focus-video-wrap {
  flex: 1;
  position: relative;
  background: #000;
}

.camera-wall-focus-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-wall-focus-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.camera-wall-focus-bar {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem;
  background: #111;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* Sync indicator */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255,255,255,0.75);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #28a745;
}

.sync-dot.is-stale {
  background: #ffc107;
}

.sync-dot.is-live {
  background: #0dcaf0;
  box-shadow: 0 0 6px rgba(13, 202, 240, 0.7);
}

/* Global search */
.global-search-wrap {
  max-width: 420px;
}

.global-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.25rem;
}

.global-search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}

.global-search-item:hover {
  background: var(--bs-tertiary-bg);
}

.global-search-item.is-offline {
  opacity: 0.7;
}

.global-search-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.global-search-meta {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

.global-search-empty {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

/* Ops home */
.ops-stat {
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  text-align: center;
  border: 1px solid var(--bs-border-color-translucent);
}

.ops-stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.ops-stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bs-secondary-color);
  margin-top: 0.15rem;
}

.ops-attention-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ops-attention-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
  width: 100%;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--bs-body-bg);
  text-align: left;
  transition: background 0.15s;
}

.ops-attention-item:hover {
  background: var(--bs-tertiary-bg);
}

.ops-attention-item.is-offline {
  border-left: 3px solid var(--bs-secondary);
}

.ops-attention-kind {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.ops-attention-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.ops-attention-space {
  font-size: 0.75rem;
}

.ops-attention-reason {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bs-danger);
}

@media (max-width: 768px) {
  .ops-attention-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

/* Lock wall */
body.lock-wall-mode {
  background: var(--bs-body-bg);
}

#view-lock-wall {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background: var(--bs-body-bg);
}

.lock-wall-header {
  background: #fff;
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.lock-wall-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.lock-wall-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.lock-wall-subtitle {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

.lock-wall-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.lock-wall-search {
  width: 160px;
}

.lock-wall-body {
  padding: 1rem;
}

.lock-wall-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
}

.lock-wall-empty {
  text-align: center;
  color: var(--bs-secondary-color);
  padding: 3rem 1rem;
}

.lock-wall-group {
  margin-bottom: 1.5rem;
}

.lock-wall-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.65rem;
}

.lock-wall-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 0.75rem;
}

.lock-wall-card {
  background: #fff;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: 0.75rem;
  padding: 0.85rem;
  box-shadow: 0 0.125rem 0.35rem rgba(0,0,0,0.04);
}

.lock-wall-card.is-offline {
  opacity: 0.75;
}

.lock-wall-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.lock-wall-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.lock-wall-card-state {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.lock-wall-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

/* Offcanvas tabs */
.device-detail-tabs .nav-link {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

/* Shortcuts modal */
.shortcut-list dt {
  font-weight: 600;
  margin-top: 0.35rem;
}

.shortcut-list dd {
  margin-left: 0;
  margin-bottom: 0.25rem;
  color: var(--bs-secondary-color);
}

/* Mobile bottom nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--bs-border-color);
  padding: 0.35rem 0;
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  border: none;
  background: transparent;
  font-size: 0.65rem;
  color: var(--bs-secondary-color);
  padding: 0.35rem;
}

.mobile-nav-btn i {
  font-size: 1.15rem;
}

.mobile-nav-btn.active {
  color: var(--bs-primary);
  font-weight: 600;
}

.pb-mobile-safe {
  padding-bottom: calc(1rem + var(--app-mobile-nav-h)) !important;
}

@media (min-width: 992px) {
  .pb-mobile-safe {
    padding-bottom: 1rem !important;
  }
}

body.lock-wall-mode #view-lock-wall,
body.camera-wall-mode #view-camera-wall {
  padding-bottom: 0;
}

@media (max-width: 991px) {
  body:not(.app-immersive) .app-main {
    padding-bottom: calc(var(--app-mobile-nav-h) + 0.5rem);
  }
}

/* Ops home — eventos e movimento */
.ops-events-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ops-event-item.is-warning {
  border-color: rgba(255, 193, 7, 0.6);
  background: rgba(255, 193, 7, 0.08);
}

.ops-event-item.is-danger {
  border-color: rgba(220, 53, 69, 0.5);
  background: rgba(220, 53, 69, 0.06);
}

.ops-event-item.is-info {
  border-color: rgba(13, 202, 240, 0.4);
}

.ops-event-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
  padding: 0.1rem 0.45rem;
}

.ops-history-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem;
  font-size: 0.8125rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.ops-live-badge {
  font-size: 0.7rem;
  font-weight: 500;
}

.ops-presets-bar .ops-preset-btn {
  min-width: 7rem;
}

.ops-event-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  background: #fff;
  cursor: pointer;
}

.ops-event-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 0.25rem;
}

.ops-event-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ops-event-type {
  font-weight: 600;
  font-size: 0.85rem;
}

.ops-motion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}

.ops-motion-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.35rem;
  background: #fff;
  text-align: left;
}

.ops-motion-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 0.35rem;
  margin-bottom: 0.25rem;
}

.ops-motion-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16/9;
  background: var(--bs-light);
  border-radius: 0.35rem;
  font-size: 1.5rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.25rem;
}

.ops-scenes-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ops-scene-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  max-width: 220px;
}

.ops-scene-space {
  display: block;
  font-size: 0.7rem;
  opacity: 0.75;
}

.ops-audit-row {
  font-size: 0.8rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}

.lock-wall-card.is-readonly {
  opacity: 0.92;
  border-style: dashed;
}

.lock-wall-batch {
  padding-left: 0.25rem;
}

.lock-wall-tier {
  max-width: 140px;
}

.favorite-btn {
  line-height: 1;
}

.section-title {
  font-weight: 600;
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
}

/* Atalhos associados à câmera */
.camera-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.camera-action-bar.compact .camera-action-btn {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  color: #212529;
}

.camera-action-btn .camera-action-label {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.camera-actions-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--bs-border-color-translucent);
  font-size: 0.85rem;
}

.camera-associate-results {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.camera-associate-result-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.35rem;
  padding: 0.45rem 0.6rem;
  background: #fff;
  width: 100%;
}

.camera-associate-result-item:hover {
  border-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.04);
}

.camera-wall-associated-actions {
  position: absolute;
  left: 0.4rem;
  bottom: 2.5rem;
  z-index: 2;
  pointer-events: none;
}

.camera-wall-associated-actions .camera-action-bar {
  pointer-events: none;
}

.camera-wall-associated-actions .camera-action-btn {
  pointer-events: auto;
}

.camera-wall-focus-actions {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.camera-wall-focus-actions .camera-action-btn {
  font-size: 0.8rem;
}

/* ── Site home (pública) ── */
.site-home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 70% 50% at 50% -5%, rgba(59, 130, 246, 0.12), transparent),
    var(--app-bg);
}

.site-home-body {
  flex: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 200;
}

.site-nav-brand {
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.site-seo-line {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.25rem 1rem 0.5rem;
  margin: 0;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-switcher-select {
  width: auto;
  min-width: 7rem;
  font-size: 0.8125rem;
}

.site-nav-lang .lang-switcher-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-nav-lang .lang-switcher-select {
  min-width: 5.5rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.site-nav-links .lang-switcher {
  margin-right: 0;
}

.app-sidebar-foot .lang-switcher {
  width: 100%;
}

.app-sidebar-foot .lang-switcher-select {
  width: 100%;
}

.docs-topbar-nav .lang-switcher {
  margin-right: 0.5rem;
}

.site-nav-links {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  flex-shrink: 0;
}

.site-nav-links a:not(.btn) {
  text-decoration: none;
  color: #475569;
  font-size: 0.875rem;
  white-space: nowrap;
  padding: 0.35rem 0.15rem;
}

.site-nav-links a:not(.btn):hover {
  color: var(--app-accent);
}

.site-nav-link-signup {
  font-size: 0.8125rem !important;
  padding: 0.35rem 0.75rem !important;
  white-space: nowrap;
}

.site-nav-link-login {
  font-size: 0.8125rem;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
  color: var(--app-muted, #64748b);
  text-decoration: none;
}

.site-nav-link-login:hover {
  color: var(--app-accent);
}

.site-hero {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 1.5rem;
  text-align: center;
}

.site-eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.site-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.site-hero-lead {
  font-size: 1rem;
  line-height: 1.55;
  color: #475569;
  margin-bottom: 1.5rem;
}

.site-hero-lead code {
  font-size: 0.85em;
  word-break: break-word;
}

.site-hero-cta {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
}

.site-hero-btn {
  width: 100%;
  margin: 0;
}

.site-section {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.site-section .container {
  padding-left: 1rem;
  padding-right: 1rem;
}

.site-section-cta {
  width: 100%;
  max-width: 20rem;
}

.site-panel-banner {
  margin-top: 1.25rem;
  margin-bottom: 0;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.site-section-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-docs-list {
  padding-left: 1.15rem;
  margin-bottom: 0;
}

.site-docs-list li + li {
  margin-top: 0.5rem;
}

.site-docs-preview {
  background: linear-gradient(145deg, #f8fafc, #fff);
}

.site-endpoint-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.site-endpoint-row:last-of-type {
  margin-bottom: 0;
}

.site-endpoint-row .badge {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.site-docs-preview code {
  font-size: 0.75rem;
  line-height: 1.35;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

.site-footer {
  flex-shrink: 0;
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: var(--app-surface);
}

.site-footer--auth {
  margin-top: 1.5rem;
  padding-left: 0;
  padding-right: 0;
  background: transparent;
  border-top: none;
}

.site-footer--docs {
  margin-top: auto;
}

.site-footer-text {
  font-size: 0.8125rem;
  color: #64748b;
}

.site-footer-link {
  color: var(--app-accent);
  text-decoration: none;
  font-weight: 500;
  margin-left: 0.25rem;
}

.site-footer-link:hover {
  text-decoration: underline;
}

.site-usecase-card .card-body {
  padding: 1.25rem;
}

.site-integrations-card {
  background: linear-gradient(145deg, #f8fafc 0%, #fff 55%, rgba(59, 130, 246, 0.04) 100%);
  border-radius: 1rem;
}

.site-integrations-eyebrow {
  letter-spacing: 0.06em;
  color: var(--app-accent);
}

.site-integrations-list {
  padding-left: 1.15rem;
  margin-bottom: 0;
}

.site-integrations-list li + li {
  margin-top: 0.5rem;
}

.site-integration-tile {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.site-integration-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.07);
}

.site-integration-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  height: 1.75rem;
  padding: 0 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.site-integration-badge-n8n {
  background: #ff6d5a;
  color: #fff;
}

.site-integration-badge-zapier {
  background: #ff4a00;
  color: #fff;
}

.site-integration-badge-make {
  background: #6d00cc;
  color: #fff;
}

.site-integration-badge-backend,
.site-integration-badge-pms,
.site-integration-badge-more {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.9rem;
}

.site-feature-icon {
  font-size: 1.5rem;
  color: var(--app-accent);
  margin-bottom: 0.5rem;
  display: block;
}

.site-pricing {
  background: linear-gradient(180deg, rgba(var(--app-accent-rgb, 13, 110, 253), 0.04) 0%, transparent 100%);
  border-radius: 1rem;
}

.site-pricing-intro {
  max-width: 32rem;
}

.site-pricing-pillar-icon {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
  display: block;
}

.site-pricing-scenario {
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.site-pricing-scenario:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.08) !important;
}

.site-pricing-scenario-active {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.site-pricing-scenario-price {
  color: var(--app-accent);
}

.site-pricing-hero {
  max-width: 28rem;
  background: var(--bs-body-bg);
}

.site-pricing-hero-price {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--app-accent);
  line-height: 1.1;
}

.site-pricing-story {
  max-width: 26rem;
  color: var(--bs-secondary-color);
}

.site-pricing-details {
  max-width: 36rem;
}

@media (min-width: 576px) {
  .site-nav {
    padding: 1rem 1.5rem;
  }

  .site-nav-links {
    gap: 1rem;
  }

  .site-hero {
    padding: 3.5rem 1.5rem 2rem;
  }

  .site-hero-cta {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    max-width: none;
  }

  .site-hero-btn {
    width: auto;
    min-width: 11rem;
  }

  .site-section-cta {
    width: auto;
  }

  .site-section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }
}

@media (min-width: 992px) {
  .site-hero {
    padding: 4rem 1.5rem 2.5rem;
  }

  .site-hero-lead {
    font-size: 1.05rem;
    margin-bottom: 2rem;
  }

  .site-section .container {
    padding-left: calc(var(--bs-gutter-x) * 0.5);
    padding-right: calc(var(--bs-gutter-x) * 0.5);
  }
}

.app-nav-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  padding: 0.5rem 1.1rem 0.25rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.1rem;
  color: var(--app-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.app-nav-link:hover {
  color: var(--app-sidebar-active);
  background: rgba(255, 255, 255, 0.05);
}

/* ── API docs ── */
.docs-body {
  background: var(--app-bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.docs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--app-surface);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.docs-brand {
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.docs-topbar-brand-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.docs-seo-line {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.docs-topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.docs-layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1200px) {
  .docs-layout {
    grid-template-columns: 240px 1fr;
  }
  .docs-try-panel,
  .docs-try-login {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
  }
}

@media (max-width: 768px) {
  .docs-topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  }

  .docs-brand {
    font-size: 0.95rem;
  }

  .docs-topbar-nav {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
  }

  .docs-topbar-nav .badge {
    font-size: 0.65rem;
  }

  .docs-topbar-nav .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .docs-topbar-nav #docs-login-cta,
  .docs-topbar-nav #docs-panel-cta {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  .docs-layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }

  .docs-sidebar {
    max-height: 12rem;
    border-right: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  }

  .docs-main {
    padding: 1rem;
  }

  .docs-try-panel,
  .docs-try-login {
    border-left: none;
    max-height: none;
  }

  .docs-try-login {
    margin: 0 0.75rem 0.75rem;
    border-radius: var(--app-radius);
  }

  .docs-response {
    max-height: 240px;
  }
}

.docs-sidebar {
  background: var(--app-surface);
  border-right: 1px solid rgba(15, 23, 42, 0.06);
  overflow-y: auto;
  padding: 0.75rem 0;
  max-height: calc(100vh - 52px);
}

.docs-tag-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 0.5rem 1rem 0.25rem;
}

.docs-endpoint-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.35rem 1rem;
  font-size: 0.78rem;
}

.docs-endpoint-btn:hover,
.docs-endpoint-btn.active {
  background: var(--app-accent-soft);
}

.docs-method {
  font-size: 0.65rem;
  flex-shrink: 0;
}

.docs-path-text {
  word-break: break-all;
  color: #334155;
}

.docs-main {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.docs-detail-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.docs-path-full {
  font-size: 0.95rem;
}

.docs-try-panel,
.docs-try-login {
  background: var(--app-surface);
  border-left: 1px solid rgba(15, 23, 42, 0.06);
  padding: 1rem;
  overflow-y: auto;
}

.docs-response {
  background: #0f1419;
  color: #e2e8f0;
  font-size: 0.72rem;
  padding: 0.75rem;
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
