body.theme-dark {
  --bg-color: #0d1726;
  --panel-bg: #131f31;
  --text-main: #ebf3ff;
  --text-sub: #8ea0be;
  --line-color: #22344c;
  --shadow-main: 0 16px 40px rgba(0, 0, 0, 0.28);
}

body.auth-pending {
  visibility: hidden;
}

.admin-layout {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(47, 140, 255, 0.14), transparent 30%),
    var(--bg-color);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(219, 226, 238, 0.9);
  backdrop-filter: blur(16px);
}

body.theme-dark .topbar {
  background: rgba(10, 18, 30, 0.88);
  border-bottom-color: rgba(34, 52, 76, 0.95);
}

.topbar-left,
.topbar-right,
.user-panel,
.sidebar-header,
.menu-item-button,
.menu-child,
.metric-card-head,
.info-row,
.overview-head,
.toolbar-row {
  display: flex;
  align-items: center;
}

.topbar-left {
  gap: 14px;
}

.brand-mark,
.card-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2f8cff, #18c0ff);
  box-shadow: 0 10px 24px rgba(47, 140, 255, 0.28);
}

.brand-text strong,
.user-meta strong {
  display: block;
  font-size: 16px;
}

.brand-text span,
.user-meta span,
.sidebar-header,
.breadcrumb,
.section-subtitle,
.empty-copy,
.table-sub,
.card-head p,
.login-message {
  color: var(--text-sub);
}

.topbar-right {
  gap: 12px;
}

.topbar-logout-btn {
  min-width: 96px;
}

.topbar-action {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-main);
}

.switch-wrap {
  position: relative;
  width: 52px;
  height: 30px;
}

.switch-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d3e2;
  transition: 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s ease;
}

.switch-wrap input:checked + .switch-slider {
  background: linear-gradient(135deg, #2f8cff, #18c0ff);
}

.switch-wrap input:checked + .switch-slider::before {
  transform: translateX(22px);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #ff9f43, #ffcd70);
}

.user-panel {
  gap: 10px;
  padding-left: 8px;
}

.sidebar {
  position: fixed;
  top: 68px;
  left: 0;
  bottom: 0;
  width: 236px;
  padding: 18px 0;
  overflow-y: auto;
  background: linear-gradient(180deg, #16283d 0%, #102034 100%);
  color: rgba(255, 255, 255, 0.92);
}

.sidebar-header {
  height: 40px;
  padding: 0 22px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.menu-group {
  margin-bottom: 4px;
}

.menu-item-button {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border: 0;
  color: inherit;
  background: transparent;
}

.menu-item-button:hover,
.menu-child a:hover,
.menu-child a.active {
  background: rgba(47, 140, 255, 0.2);
}

.menu-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-icon {
  width: 18px;
  text-align: center;
  color: #8bc0ff;
}

.menu-arrow {
  color: rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease;
}

.menu-group.open .menu-arrow {
  transform: rotate(90deg);
}

.menu-child {
  flex-direction: column;
  align-items: stretch;
  padding: 4px 0 8px;
}

.menu-child a {
  padding: 12px 22px 12px 52px;
  color: rgba(255, 255, 255, 0.78);
  transition: background 0.2s ease, color 0.2s ease;
}

.content-shell {
  margin-top: 68px;
  margin-left: 236px;
  min-height: calc(100vh - 68px);
  padding: 18px;
}

.primary-btn {
  min-width: 112px;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #2f8cff, #18c0ff);
  box-shadow: 0 12px 26px rgba(47, 140, 255, 0.26);
}

.content-frame-wrap {
  height: calc(100vh - 68px - 36px);
  min-height: calc(100vh - 104px);
  border: 1px solid var(--line-color);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel-bg);
  box-shadow: var(--shadow-main);
}

.content-frame {
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
}

.page-shell {
  min-height: 100vh;
  padding: 22px;
  background: var(--bg-color);
}

.overview-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.overview-head h2,
.panel-card h3,
.table-card h3 {
  margin: 0;
  font-size: 22px;
}

.toolbar-row {
  gap: 12px;
}

.light-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

.light-chip {
  color: #1f67dc;
  background: rgba(47, 140, 255, 0.12);
}

.status-chip.success {
  color: #0e8d64;
  background: rgba(22, 180, 127, 0.14);
}

.status-chip.warn {
  color: #c97710;
  background: rgba(255, 159, 67, 0.16);
}

.metric-grid,
.panel-grid,
.info-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.panel-grid {
  grid-template-columns: 1.5fr 1fr;
  margin-bottom: 18px;
}

.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card,
.panel-card,
.table-card,
.placeholder-card {
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-main);
}

.metric-card {
  padding: 18px;
}

.metric-card-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.metric-title,
.field-label,
.detail-label,
.table-sub,
.placeholder-tip {
  color: var(--text-sub);
}

.metric-value {
  font-size: 34px;
  font-weight: 700;
}

.metric-trend {
  margin-top: 8px;
  font-size: 13px;
}

.metric-trend.up {
  color: var(--success-color);
}

.metric-trend.down {
  color: var(--danger-color);
}

.panel-card,
.table-card,
.placeholder-card {
  padding: 20px;
}

.device-list,
.alert-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.device-item,
.alert-item {
  padding: 14px 16px;
  border: 1px solid var(--line-color);
  border-radius: 10px;
  background: rgba(47, 140, 255, 0.03);
}

.device-item strong,
.alert-item strong {
  display: block;
  margin-bottom: 6px;
}

.info-row {
  gap: 14px;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line-color);
}

.info-row:last-child {
  border-bottom: 0;
}

.detail-value {
  text-align: right;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
}

.search-input {
  width: 280px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-main);
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line-color);
  border-radius: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel-bg);
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-color);
}

.data-table th {
  background: rgba(47, 140, 255, 0.06);
  font-weight: 600;
}

.empty-copy {
  padding: 36px 0 12px;
  text-align: center;
}

.placeholder-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 420px;
}

.placeholder-card h2 {
  margin: 0 0 12px;
  font-size: 28px;
}

.placeholder-card p {
  max-width: 720px;
  margin: 0 0 20px;
  line-height: 1.75;
}

.placeholder-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar-right {
    gap: 8px;
  }

  .sidebar {
    width: 210px;
  }

  .content-shell {
    margin-left: 210px;
    padding: 14px;
  }

  .content-frame-wrap {
    height: calc(100vh - 68px - 28px);
    min-height: calc(100vh - 96px);
  }

  .brand-text span,
  .user-meta span {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-right {
    flex-wrap: wrap;
  }

  .topbar-logout-btn {
    min-width: 84px;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 10px 0;
    overflow: visible;
  }

  .content-shell {
    margin-top: 0;
    margin-left: 0;
    min-height: auto;
    padding: 12px;
  }

  .admin-layout {
    display: block;
    padding-top: 96px;
  }

  .content-frame-wrap {
    height: calc(100vh - 220px);
    min-height: 520px;
    border-radius: 12px;
  }

  .menu-item-button {
    padding: 12px 16px;
  }

  .menu-child a {
    padding: 10px 16px 10px 42px;
  }

  .metric-grid,
  .panel-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .detail-value {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .admin-layout {
    padding-top: 110px;
  }

  .topbar-left {
    gap: 10px;
  }

  .brand-text strong {
    font-size: 14px;
  }

  .topbar-action,
  .user-avatar {
    width: 34px;
    height: 34px;
  }

  .content-frame-wrap {
    height: calc(100vh - 230px);
    min-height: 460px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .data-table {
    min-width: 720px;
  }

  .page-shell {
    padding: 14px;
  }
}
