:root {
  color-scheme: dark;
  --bg: #121212;
  --panel: #1c1c1c;
  --panel-light: #232323;
  --text: #e6e6e6;
  --muted: #9ea0a3;
  --accent: #d500ff;
  --accent-soft: rgba(213, 0, 255, 0.2);
  --alert: #ff6b5f;
  --warning: #f3b33d;
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.app-shell--single {
  grid-template-columns: 1fr;
}

.sidebar {
  background: #151515;
  padding: 24px 18px;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand__logo {
  background: #0f0f0f;
  border: 1px solid #2c2c2c;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 2px;
}

.brand__title {
  font-weight: 600;
}

.ghost-button {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: var(--text);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-pill {
  background: var(--panel);
  border: 1px solid #2a2a2a;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
}

.nav-pill--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.badge {
  background: #2c2c2c;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.badge--alert {
  background: rgba(255, 107, 95, 0.2);
  color: var(--alert);
}

.sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.object-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  border: 1px solid #2a2a2a;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.object-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.object-card--alarm {
  border-color: rgba(255, 77, 77, 0.6);
  background: rgba(255, 77, 77, 0.16);
}

.object-card--alarm-flash {
  animation: alarm-card 1s steps(2) infinite;
}

.object-card--active {
  background: #0f0f0f;
  border-color: var(--accent);
}

.object-card__title {
  font-weight: 600;
  margin-bottom: 6px;
}

.object-card__meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.object-card__hub-offline {
  color: #ff4d4d;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.log-row--hub-offline {
  color: #ff9f43;
}

.panel__footer--center {
  display: flex;
  justify-content: center;
}

.object-card__status {
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 6px;
}

.status--armed {
  color: #ff4d4d;
  text-shadow: 0 0 8px rgba(255, 77, 77, 0.5);
  animation: status-pulse 1.6s ease-in-out infinite;
}

.status--disarmed {
  color: var(--warning);
  text-shadow: 0 0 8px rgba(77, 255, 143, 0.3);
}

.status--night {
  color: #65a1ff;
}

.main {
  padding: 24px 32px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__title h1 {
  font-size: 24px;
}

.topbar__title p {
  color: var(--muted);
  font-size: 13px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid #2a2a2a;
  padding: 8px 12px;
  border-radius: 12px;
}

.search input,
.device-search {
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  width: 220px;
}

.button {
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  padding: 10px 16px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.button--primary {
  background: var(--accent);
  color: #150f2b;
  border: none;
  font-weight: 600;
}

.button--primary:hover {
  box-shadow: 0 0 12px rgba(213, 0, 255, 0.3);
}

.button--refresh {
  position: relative;
  padding-right: 38px;
  border-color: rgba(101, 161, 255, 0.4);
  color: #8fb7ff;
}

.button--refresh::after {
  content: '⟳';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.8;
  pointer-events: none;
}

.button--refresh.is-loading::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(143, 183, 255, 0.4);
  border-top-color: #8fb7ff;
  animation: spin-refresh 0.8s linear infinite;
  pointer-events: none;
}

.button--refresh.is-loading {
  box-shadow: 0 0 12px rgba(101, 161, 255, 0.3);
}

.button--ghost {
  background: transparent;
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button--locked {
  opacity: 1;
  background: #3a3a3a !important;
  border-color: #4a4a4a !important;
  color: #bdbdbd !important;
  box-shadow: none;
  cursor: not-allowed;
}

.modal--fullscreen {
  padding: 20px;
}

.modal__content--fullscreen {
  width: min(1200px, 95vw);
  height: min(85vh, 900px);
  display: flex;
  flex-direction: column;
}

.modal__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-users {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.admin-users__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  background: #1a1a1a;
}

.admin-users__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-users__name {
  font-weight: 600;
}

.admin-users__meta {
  color: var(--muted);
  font-size: 12px;
}

.admin-users__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-tools {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.admin-tools__row {
  display: grid;
  gap: 12px;
}

.admin-users-search {
  flex: 0 0 auto;
}

.button--link {
  border-color: transparent;
}

.chip--success {
  background: rgba(59, 214, 113, 0.28);
  color: #3bd671;
}

.chip--danger {
  background: rgba(255, 77, 77, 0.28);
  color: #ff4d4d;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.button--danger {
  border-color: rgba(255, 107, 95, 0.5);
  color: var(--alert);
}

.danger-actions {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.attach-hub {
  margin-top: 16px;
}

.status-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  border: 1px solid #2a2a2a;
  flex-wrap: wrap;
  gap: 16px;
}

.status-card__id {
  font-size: 20px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-card__subid {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.status-card__state {
  color: var(--accent);
}

.status-card__state.status--armed {
  color: #ff4d4d;
}

.status-card__meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.status-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.chip {
  background: #2a2a2a;
  border: none;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.status-actions .chip--danger {
  background: rgba(255, 77, 77, 0.4);
  color: #ff4d4d;
}

.status-actions .chip--success {
  background: rgba(59, 214, 113, 0.4);
  color: #3bd671;
}

.status-actions .chip {
  min-width: 56px;
  height: 48px;
  border-radius: 14px;
  padding: 10px 16px;
}

.chip--alert {
  background: rgba(255, 107, 95, 0.2);
  color: var(--alert);
}

.chip--danger:hover {
  box-shadow: 0 0 12px rgba(255, 77, 77, 0.3);
}

.chip--success:hover {
  box-shadow: 0 0 12px rgba(77, 255, 143, 0.3);
}

.chip--info:hover {
  box-shadow: 0 0 12px rgba(101, 161, 255, 0.3);
}

.chip--active {
  border: 1px solid var(--accent);
  color: var(--accent);
}

.content {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid #2a2a2a;
}

.pcn-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(520px, 1.6fr);
  gap: 20px;
}

.pcn-layout__panel {
  height: 100%;
}

.pcn-layout__panel--wide .log-table {
  max-height: 640px;
  overflow: auto;
}

.tiles-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.main-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 12px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  background: var(--panel-light);
}

.main-search input {
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  width: 100%;
}
.tabs {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.tab--active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 6px;
}

.panel {
  display: none;
}

.panel--active {
  display: block;
  animation: fadeIn 0.15s ease;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel__footer {
  margin-top: 18px;
  background: #1b1b1b;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #2a2a2a;
}

.panel__footer h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  background: #222;
  border: 1px solid #2a2a2a;
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
}

.notes-input {
  min-height: 44px;
  resize: vertical;
  overflow: hidden;
}

.form-grid button {
  justify-self: start;
}

.form-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.hidden {
  display: none;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.device-item {
  background: #171717;
  border-radius: 10px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  height: 72px;
  width: 100%;
  text-align: left;
}

.device-item__content {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.device-item > div {
  min-width: 0;
}

.device-item--active {
  border: 1px solid var(--accent);
  background: rgba(213, 0, 255, 0.14);
}

.device-item__title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-item__meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-item__status {
  color: var(--accent);
  font-size: 12px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-details {
  background: var(--panel-light);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 240px;
}

.device-details__header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.device-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #2c2c2c;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: var(--muted);
}

.device-item .device-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.device-avatar svg {
  width: 24px;
  height: 24px;
}

.device-avatar[data-type="zone"] {
  background: rgba(255, 107, 95, 0.15);
  color: var(--alert);
}

.device-avatar[data-type="siren"] {
  background: rgba(243, 179, 61, 0.15);
  color: var(--warning);
}

.device-avatar[data-type="output-light"] {
  background: rgba(213, 0, 255, 0.15);
  color: var(--accent);
}

.device-avatar[data-type="reader"] {
  background: rgba(77, 171, 255, 0.15);
  color: #4dabff;
}

.device-avatar[data-type="key"] {
  background: rgba(77, 255, 143, 0.15);
  color: #4dff8f;
}

.device-avatar[data-type="hub"],
.device-avatar[data-type="hub_extension"] {
  background: rgba(158, 160, 163, 0.15);
  color: var(--muted);
}

.device-details__title {
  font-weight: 600;
}

.device-details__meta {
  color: var(--muted);
  font-size: 12px;
}

.device-details__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat {
  background: #202020;
  padding: 10px;
  border-radius: 12px;
  font-size: 12px;
}

.stat span {
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.object-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.info-card {
  background: var(--panel-light);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

.info-card strong {
  color: var(--text);
}

.empty-state {
  background: var(--panel-light);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-state__icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.profile-menu {
  position: relative;
  margin-left: 4px;
}

.avatar-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.avatar-stack {
  position: relative;
  display: grid;
  place-items: center;
}

.avatar-button__circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(213, 0, 255, 0.2);
  color: #fff;
  font-weight: 600;
  display: grid;
  place-items: center;
  border: 1px solid rgba(213, 0, 255, 0.4);
}

.avatar-button__circle--large {
  width: 44px;
  height: 44px;
}

.avatar-button__image {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(213, 0, 255, 0.4);
  display: none;
}

.avatar-button__image--large {
  width: 44px;
  height: 44px;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 30;
}

.profile-dropdown--open {
  display: grid;
  gap: 12px;
}

.profile-dropdown__header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.profile-dropdown__title {
  font-weight: 600;
  color: var(--text);
}

.profile-dropdown__subtitle {
  font-size: 12px;
  color: var(--muted);
}

.profile-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.profile-field__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-field__row input {
  flex: 1;
}

.profile-field input,
.profile-field select {
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
}

.profile-field input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.profile-logout {
  width: 100%;
  justify-content: center;
}

.tabs--top {
  margin-bottom: 18px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(213, 0, 255, 0.15), transparent 45%), #0d0f12;
  padding: 32px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 16px;
}

.auth-header h1 {
  margin: 12px 0 6px;
  font-size: 24px;
}

.auth-header p {
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  gap: 12px;
}

.auth-error {
  color: #ff6b6b;
  font-size: 13px;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.auth-error--show {
  opacity: 1;
}

.auth-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.auth-discord {
  width: 100%;
  justify-content: center;
}

.auth-note {
  text-align: center;
  font-size: 12px;
}

.object-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 12px;
  border-radius: 14px;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.object-item--alarm {
  border-color: rgba(255, 77, 77, 0.6);
  background: rgba(255, 77, 77, 0.12);
}

.object-item--alarm-flash {
  animation: alarm-card 1s steps(2) infinite;
}

.object-item--active {
  border-color: var(--accent);
  background: rgba(213, 0, 255, 0.12);
}

.object-item__title {
  font-weight: 600;
}

.object-item__meta {
  color: var(--muted);
  font-size: 12px;
}

.object-item__hub-offline {
  color: #ff4d4d;
  font-size: 12px;
  font-weight: 600;
}

.members-panel {
  display: grid;
  gap: 16px;
}

.members-list {
  display: grid;
  gap: 12px;
}

.member-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: var(--panel-light);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
}

.member-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.member-card__title {
  color: var(--text);
  font-weight: 600;
}

.member-card__meta {
  font-size: 12px;
}

.contacts,
.notes,
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.contact-card,
.note-card,
.photo-card {
  background: var(--panel-light);
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
}

.photo-card img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 8px;
}

.contact-card__title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}

.log-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-row {
  display: grid;
  grid-template-columns: 90px 1fr 160px;
  gap: 16px;
  padding: 12px;
  background: var(--panel-light);
  border-radius: 12px;
  font-size: 13px;
}

.log-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-row--alarm {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.12);
}

.log-row--alarm-flash {
  animation: alarm-row 1s steps(2) 15;
}

.log-row--restore {
  color: #3bd671;
  background: rgba(59, 214, 113, 0.12);
}

.log-row--hub {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
}

.log-divider {
  margin: 8px 0 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #1a1a1a;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.device-edit {
  margin-top: 16px;
}

.field-hint {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #ff8f8f;
  margin-top: -4px;
}

.muted {
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.modal--open {
  display: flex;
}

.modal__content {
  background: #1b1b1b;
  border-radius: 16px;
  padding: 20px;
  width: min(560px, 90vw);
  border: 1px solid #2a2a2a;
  position: relative;
  z-index: 1;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.modal__content--small {
  width: min(320px, 90vw);
  text-align: center;
}

.modal--loading .modal__content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid #2a2a2a;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #202020;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast--show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes alarm-row {
  0% {
    background: rgba(255, 77, 77, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 77, 77, 0.3);
  }
  50% {
    background: rgba(255, 77, 77, 0.45);
    box-shadow: inset 0 0 0 1px rgba(255, 77, 77, 0.9);
  }
  100% {
    background: rgba(255, 77, 77, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 77, 77, 0.3);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes alarm-card {
  50% {
    box-shadow: 0 0 0 2px rgba(255, 77, 77, 0.4);
  }
}

@keyframes status-pulse {
  0% {
    text-shadow: 0 0 6px rgba(255, 77, 77, 0.4);
  }
  50% {
    text-shadow: 0 0 12px rgba(255, 77, 77, 0.7);
  }
  100% {
    text-shadow: 0 0 6px rgba(255, 77, 77, 0.4);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-refresh {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.status--partial {
  color: #f3b33d;
  text-shadow: 0 0 8px rgba(243, 179, 61, 0.4);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}

.toggle-switch input {
  width: 36px;
  height: 20px;
  appearance: none;
  background: #3a3a3a;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #aaa;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked {
  background: var(--accent);
}

.toggle-switch input:checked::after {
  transform: translateX(16px);
  background: #fff;
}

.group-card {
  background: var(--panel-light);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.group-card__title {
  font-weight: 600;
}

.group-card__status {
  font-size: 12px;
}

.group-card__devices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.group-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.group-card--muted {
  opacity: 0.6;
  border-style: dashed;
}

.group-assign {
  margin-top: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid #2a2a2a;
  background: #171717;
  display: grid;
  gap: 12px;
}

.group-assign__header h3 {
  margin: 0;
  font-size: 16px;
}

.group-assign__list {
  display: grid;
  gap: 10px;
}

.group-assign__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #1f1f1f;
  border: 1px solid #2a2a2a;
}

.group-assign__info {
  display: grid;
  gap: 4px;
  min-width: 160px;
}

.group-assign__name {
  font-weight: 600;
}

.group-assign__controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.group-assign__controls select {
  min-width: 180px;
}

.group-manage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel-light);
  border-radius: 12px;
  border: 1px solid #2a2a2a;
}

.group-manage-item__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.group-manage-item__name {
  font-weight: 600;
}

.group-manage-item__status {
  font-size: 12px;
}

.group-manage-item__actions {
  display: flex;
  gap: 8px;
}

.tag {
  display: inline-block;
  background: #2a2a2a;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text);
}

.tag--muted {
  opacity: 0.5;
}

.chip--info {
  background: rgba(101, 161, 255, 0.28);
  color: #65a1ff;
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.groups-form {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  align-items: center;
}

.groups-form input {
  flex: 1;
  background: #222;
  border: 1px solid #2a2a2a;
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
}

.group-manage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.group-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.group-checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

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

  .pcn-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 12px;
  }

  .space-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tab-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
  }

  .tab {
    font-size: 12px;
    padding: 6px 10px;
    flex-shrink: 0;
  }

  .chip {
    font-size: 12px;
    padding: 6px 12px;
  }

  .status-actions {
    flex-wrap: wrap;
  }

  .device-details__stats {
    grid-template-columns: 1fr;
  }

  .panel__grid {
    gap: 12px;
  }

  .form-grid {
    gap: 8px;
  }

  .modal__content {
    margin: 8px;
    max-height: calc(100vh - 16px);
    border-radius: 14px;
  }

  .group-card__actions {
    flex-direction: column;
  }

  .sidebar {
    padding: 16px 12px;
  }

  .object-card {
    padding: 12px;
  }

  .log-table {
    font-size: 12px;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .log-row > span:first-child {
    font-size: 12px;
    color: var(--muted);
  }

  .log-row > .muted {
    font-size: 12px;
    overflow-wrap: anywhere;
  }
}
