:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-soft: #eef3f8;
  --sidebar-bg: #142033;
  --sidebar-bg-2: #142033;
  --sidebar-line: #2a3948;
  --sidebar-text: #edf4fc;
  --sidebar-muted: #9aabba;
  --text: #142033;
  --text-2: #64748b;
  --muted: #64748b;
  --line: #d9e2ec;
  --line-strong: #d9e2ec;
  --primary: #2563eb;
  --primary-2: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --on-primary: #ffffff;
  --ok: #047857;
  --warn: #b45309;
  --warning: #b45309;
  --danger: #b91c1c;
  --toast-ok: #047857;
  --toast-warn: #92400e;
  --toast-danger: #b91c1c;
  --toast-info: #1d4ed8;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.05);
  --radius-lg: 8px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --gap: 16px;
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Segoe UI', Arial, sans-serif;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b1118;
  --bg-elevated: #111922;
  --bg-soft: #17212c;
  --sidebar-bg: #0b1118;
  --sidebar-bg-2: #0b1118;
  --sidebar-line: #2a3948;
  --sidebar-text: #edf4fc;
  --sidebar-muted: #9aabba;
  --text: #edf4fc;
  --text-2: #9aabba;
  --muted: #9aabba;
  --line: #2a3948;
  --line-strong: #2a3948;
  --primary: #60a5fa;
  --primary-2: #60a5fa;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --on-primary: #07111f;
  --ok: #4ade80;
  --warn: #fbbf24;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  --shadow-soft: 0 10px 22px rgba(0, 0, 0, 0.16);
}

* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
[data-boot-hidden='true'] {
  visibility: hidden;
}
.admin-boot-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
}
.admin-boot-screen img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}
.admin-boot-screen div {
  display: grid;
  gap: 4px;
}
.admin-boot-screen strong {
  font-size: 14px;
}
.admin-boot-screen span {
  color: var(--muted);
  font-size: 12px;
}
button,
select,
input,
a {
  font: inherit;
}
button {
  cursor: pointer;
}
.text-danger {
  color: var(--danger);
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 8px;
  padding: 14px 14px 8px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-line);
  box-shadow: var(--shadow);
  z-index: 20;
}

.brand {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}
.brand-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.18;
}
.brand-title .brand-line {
  display: block;
  white-space: nowrap;
}
.brand-version {
  margin-top: 4px;
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 700;
}
.brand-subtitle {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.25;
}

.icon-slot,
.lucide-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.icon-slot {
  display: inline-grid;
  place-items: center;
  line-height: 0;
}

.lucide-icon {
  display: block;
}

.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.sidebar-body {
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
  padding-bottom: 8px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 4px 4px 1px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-group-items {
  display: grid;
  gap: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(241, 236, 255, 0.84);
  text-align: left;
  min-height: 36px;
  padding: 8px 10px;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: translateY(-1px);
}

.nav-item.active {
  background: rgba(37, 99, 235, 0.24);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.nav-item:focus:not(.active) {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.nav-item:focus-visible:not(.active) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-icon {
  width: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.nav-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.nav-group[data-group='system'] .nav-badge {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-footer {
  margin-top: 0;
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid var(--sidebar-line);
  display: grid;
  gap: 6px;
}

.profile-entry {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 16px;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text);
  padding: 4px 8px;
  text-align: left;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(96, 165, 250, 0.18);
  color: #fff;
  font-weight: 800;
}

.profile-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.profile-name {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
}
.profile-role {
  display: none;
}
.profile-arrow {
  color: var(--sidebar-muted);
  font-size: 16px;
  justify-self: end;
}

.sidebar-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-muted);
  font-size: 12px;
  padding: 0 4px;
}

.main {
  min-width: 0;
  padding: 18px 18px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.topbar-copy {
  min-width: 0;
}
.topbar-kicker {
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.topbar-version {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 800;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 12px;
}

.topbar-tools,
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions .icon-button {
  border-color: var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text-2);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.topbar-actions .icon-button:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.12);
}

html[data-theme='dark'] .topbar-actions .icon-button {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  box-shadow: none;
}

html[data-theme='dark'] .topbar-actions .icon-button:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(96, 165, 250, 0.16);
  color: var(--primary);
}

.topbar-select {
  display: grid;
  gap: 5px;
  min-width: 160px;
  color: var(--text-2);
  font-size: 12px;
}

.topbar-select span {
  font-weight: 700;
}
.topbar-select select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 8px 10px;
}

.button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-md);
  padding: 9px 13px;
  min-height: 36px;
  font-weight: 800;
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.button.ghost {
  background: var(--bg-elevated);
  color: var(--primary-2);
  border-color: var(--line);
}
.button.compact {
  padding: 7px 11px;
  min-height: 32px;
  font-size: 13px;
}
.button.subtle {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--line);
}
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.button.sm {
  padding: 5px 9px;
  min-height: 28px;
  font-size: 12px;
}

.panel {
  display: none;
}
.panel.active {
  display: grid;
  gap: 16px;
}

.block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.block h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-soft));
  box-shadow: var(--shadow-soft);
  padding: 16px;
  min-height: 114px;
  position: relative;
}

.metric-icon {
  font-size: 18px;
  margin-bottom: 8px;
}
.metric-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
}
.metric-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
}
.metric-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.metric-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  max-width: calc(100% - 24px);
  overflow-wrap: anywhere;
  text-align: right;
}
.metric-badge.up {
  background: rgba(0, 180, 42, 0.12);
  color: var(--ok);
}
.metric-badge.down {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}
.metric-badge.flat {
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
}

.metric.ok .metric-value {
  color: var(--ok);
}
.metric.warn .metric-value {
  color: var(--warn);
}
.metric.danger .metric-value {
  color: var(--danger);
}

.dashboard-alert-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.alert-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.alert-card.danger {
  border-color: rgba(245, 63, 63, 0.22);
}
.alert-card.warn {
  border-color: rgba(255, 125, 0, 0.22);
}
.alert-card.ok {
  border-color: rgba(0, 180, 42, 0.18);
}

.alert-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.alert-title {
  font-size: 14px;
  font-weight: 800;
}
.alert-count {
  font-size: 22px;
  font-weight: 900;
}
.alert-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dashboard-chart-grid,
.dashboard-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
}

.segmented button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.segmented button.active {
  background: var(--primary);
  color: #fff;
}

.dashboard-chart,
.dashboard-panel {
  display: grid;
  gap: 12px;
}

#dashboard-trend-chart,
#dashboard-school-chart,
#dashboard-recent-students,
#dashboard-device-state {
  min-height: 188px;
}

#dashboard-alerts {
  min-height: 112px;
}

.chart-bars,
.dashboard-list,
.dashboard-device-list,
.dashboard-empty {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.chart-label,
.dashboard-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.chart-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(135, 140, 170, 0.14);
  overflow: hidden;
  min-width: 0;
}

.chart-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  max-width: 100%;
}

.chart-value {
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-2);
}

.dashboard-item,
.device-list-item {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.dashboard-item:hover,
.device-list-item:hover {
  background: rgba(37, 99, 235, 0.035);
}

.dashboard-item:last-child,
.device-list-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.dashboard-item-meta,
.device-item-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-item-actions,
.device-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.dashboard-item-meta span,
.device-item-meta span {
  white-space: nowrap;
}

.dashboard-empty {
  place-items: center;
  text-align: center;
  min-height: 180px;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed rgba(135, 140, 170, 0.28);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}

.dashboard-empty-compact {
  grid-column: 1 / -1;
  min-height: 104px;
  gap: 6px;
}

.dashboard-empty-chart {
  min-height: 188px;
}

.dashboard-empty-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.dashboard-empty small {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.5;
}

.placeholder-illustration {
  width: 120px;
  height: 88px;
  border-radius: 8px;
  border: 1px dashed var(--line-strong);
  background: var(--primary-soft);
}

.placeholder-illustration.small {
  width: 94px;
  height: 72px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(135, 140, 170, 0.12), rgba(135, 140, 170, 0.24), rgba(135, 140, 170, 0.12));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s linear infinite;
}

.skeleton-line.xs {
  height: 10px;
}
.skeleton-line.sm {
  height: 12px;
}
.skeleton-line.lg {
  height: 18px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton .metric-label,
.skeleton .metric-value,
.skeleton .alert-title,
.skeleton .alert-count,
.skeleton .chart-label,
.skeleton .chart-value,
.skeleton .dashboard-item-title {
  color: transparent;
}

.skeleton .chart-track > span {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.12), rgba(15, 118, 110, 0.18), rgba(37, 99, 235, 0.12));
}

.skeleton .dashboard-item-meta,
.skeleton .alert-desc {
  color: transparent;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-soft);
  color: var(--text-2);
  font-weight: 800;
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(135, 140, 170, 0.12);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  background: rgba(0, 180, 42, 0.12);
  color: var(--ok);
}
.pill.warn {
  background: rgba(255, 125, 0, 0.12);
  color: var(--warn);
}
.pill.danger {
  background: rgba(245, 63, 63, 0.12);
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.inline-input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--bg-elevated);
  color: var(--text);
}

.inline-input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.search-box input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.58);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.form-grid .button {
  height: 38px;
}

.form-field {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 750;
}

.form-field > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.search-box input {
  max-width: 280px;
}
.result-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 5px 10px;
}

.pagination button.active,
.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-2);
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.page-info {
  color: var(--muted);
  font-size: 12px;
}

.status-strip,
.two-column,
.screen-layout,
.school-data-grid,
.topology-counts,
.screen-two,
.screen-hero-grid,
.screen-important,
.screen-compact-grid {
  display: grid;
  gap: 12px;
}

.two-column,
.screen-two,
.screen-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.key-list {
  display: grid;
  gap: 8px;
}

.key-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.key-row:last-child {
  border-bottom: 0;
}
.key {
  color: var(--text-2);
}
.value {
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.screen-stage {
  min-height: calc(100vh - 146px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.05), rgba(15, 118, 110, 0.025)),
    linear-gradient(180deg, var(--bg-elevated), var(--bg-soft));
  color: var(--text);
  padding: 18px;
  overflow: hidden;
}

.screen-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.screen-kicker {
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.screen-top h2 {
  margin: 6px 0 0;
  font-size: 22px;
}

.screen-top p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.screen-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.screen-nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.screen-nav button {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-2);
  text-align: left;
  padding: 10px 12px;
}

.screen-nav button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--text);
}

.screen-nav span {
  display: block;
  color: var(--primary-2);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 4px;
}

.screen-nav strong {
  font-size: 13px;
  line-height: 1.35;
}

.screen-content {
  display: grid;
  gap: 16px;
}

.screen-metric,
.screen-panel,
.screen-camera {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.screen-metric {
  min-height: 104px;
  padding: 14px;
  display: grid;
  align-content: center;
  border-top: 3px solid var(--primary);
}

.screen-metric:nth-child(2n) {
  border-top-color: #2dd4bf;
}
.screen-metric:nth-child(3n) {
  border-top-color: #f59e0b;
}
.screen-metric:nth-child(5n) {
  border-top-color: #64748b;
}

.screen-metric span {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
}
.screen-metric strong {
  font-size: 28px;
  line-height: 1.05;
  margin-top: 8px;
}
.screen-metric em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  margin-top: 6px;
}

.screen-panel {
  padding: 14px;
}
.screen-panel-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 12px;
}

.screen-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.screen-bars,
.screen-list {
  display: grid;
  gap: 10px;
}

.screen-bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 60px;
  gap: 10px;
  align-items: center;
}

.screen-bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(135, 140, 170, 0.14);
}

.screen-bar-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.screen-bar-label,
.screen-bar-value {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 700;
}

.screen-ring-row,
.screen-camera-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.screen-ring {
  min-height: 124px;
  border-radius: 50%;
  border: 10px solid rgba(37, 99, 235, 0.14);
  display: grid;
  place-items: center;
  text-align: center;
}

.screen-ring strong {
  display: block;
  font-size: 28px;
}
.screen-ring span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.screen-camera {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.screen-camera-live {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  display: grid;
  place-items: center;
  color: #fff;
}

.screen-camera-live img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-container {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  margin-bottom: 10px;
}

.camera-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.camera-container[data-frame-state='playing'] img {
  display: block;
}

.camera-container .camera-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.camera-container .camera-placeholder,
.screen-camera em {
  color: var(--muted);
  font-size: 12px;
}

.camera-container .camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  background: #090d16;
}

.camera-container[data-frame-state='playing'] .camera-placeholder {
  display: none;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.device-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.device-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.device-name {
  font-size: 14px;
  font-weight: 800;
}
.device-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.device-status.online {
  background: rgba(0, 180, 42, 0.12);
  color: var(--ok);
}
.device-status.running {
  background: rgba(0, 180, 42, 0.12);
  color: var(--ok);
}
.device-status.offline {
  background: rgba(245, 63, 63, 0.12);
  color: var(--danger);
}
.device-status.waiting {
  background: rgba(22, 93, 255, 0.1);
  color: var(--primary);
}
.device-status.no-frame {
  background: rgba(250, 173, 20, 0.14);
  color: var(--warning);
}

.device-card-body {
  padding: 12px 14px 14px;
}

.device-info {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 10px;
}

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

.device-monitor-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}

.device-monitor-summary.warn {
  color: var(--warning);
  background: rgba(250, 173, 20, 0.1);
  border-color: rgba(250, 173, 20, 0.28);
}

.log-container {
  background: #111827;
  color: #e5eefb;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 14px;
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  min-height: 200px;
}

.log-line {
  padding: 2px 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line.error {
  color: #fda4af;
}
.log-line.success {
  color: #86efac;
}
.log-line.warning {
  color: #fcd34d;
}
.log-line.info {
  color: #93c5fd;
}

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: #fff;
  box-shadow: var(--shadow);
  animation: toast-slide-up 180ms ease-out;
}

.toast.success {
  background: var(--toast-ok);
}
.toast.error {
  background: var(--toast-danger);
}
.toast.info {
  background: var(--toast-info);
}
.toast.warning {
  background: var(--toast-warn);
}
.toast-message {
  min-width: 0;
  flex: 1;
  text-align: left;
  overflow-wrap: anywhere;
}
.toast-close {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.toast-close:hover {
  background: rgba(0, 0, 0, 0.26);
}
.toast.fade-out {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

@keyframes toast-slide-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(13, 15, 28, 0.52);
  display: grid;
  place-items: center;
}

.modal-box {
  width: min(520px, calc(100vw - 24px));
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 22px;
}

.code-modal .modal-box {
  width: min(920px, calc(100vw - 24px));
}

.modal-box h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.modal-box p {
  margin: 0 0 16px;
  color: var(--text-2);
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
}

.login-layout {
  width: min(880px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 40px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.login-brand-lockup {
  display: flex;
  gap: 16px;
  align-items: center;
}

.login-brand-mark {
  display: block;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 8px;
}

.login-brand-name {
  display: block;
  color: var(--sidebar-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.login-brand-lockup strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.login-brand-meta {
  display: grid;
  margin-top: auto;
  border-top: 1px solid var(--sidebar-line);
}

.login-brand-meta span {
  padding: 11px 0;
  border-bottom: 1px solid var(--sidebar-line);
  color: var(--sidebar-muted);
  font-size: 13px;
}

.login-brand-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.login-auth-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
  background: var(--bg-elevated);
}

.login-auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.login-auth-head p {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-auth-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
}

.login-theme-toggle {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-color: var(--line);
  background: var(--bg-soft);
  color: var(--text);
}

.login-theme-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.login-panel {
  width: 100%;
  display: grid;
  gap: 18px;
  margin-top: 32px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--bg-elevated);
  color: var(--text);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.login-panel input::placeholder {
  color: var(--muted);
}

.login-panel .button {
  width: 100%;
  min-height: 44px;
}

.login-error {
  border: 1px solid rgba(245, 63, 63, 0.2);
  background: rgba(245, 63, 63, 0.08);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
}

.login-auth-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.settings-summary {
  min-height: 120px;
}
.settings-summary .dashboard-list {
  gap: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.settings-card .dashboard-item-actions {
  margin-top: 10px;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.dashboard-alert-block,
.dashboard-chart-grid > .block,
.dashboard-lower-grid > .block {
  min-height: 100%;
}

.badge-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.notification-button {
  position: relative;
}

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.notice {
  border: 1px solid rgba(255, 125, 0, 0.22);
  background: rgba(255, 125, 0, 0.08);
  color: var(--warning);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  line-height: 1.65;
}

.topology-grid,
.student-group-class {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.school-card,
.platform-card,
.mini-list,
.import-zone {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text);
  padding: 12px;
}

.school-card,
.platform-card {
  display: grid;
  gap: 9px;
}
.mini-list {
  display: grid;
  gap: 7px;
}
.mini-list > * + * {
  border-top: 1px solid var(--line);
  padding-top: 7px;
}
.import-zone {
  display: grid;
  gap: 10px;
}
.import-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.import-row select {
  min-width: min(260px, 100%);
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 7px 9px;
}
.import-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.import-result {
  display: grid;
  gap: 6px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.dashboard-empty .button {
  margin-top: 4px;
}

.loading-row td,
.empty-row td {
  text-align: center;
  padding: 38px 0;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .sidebar-footer-meta,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-group-head,
.sidebar-collapsed .profile-meta,
.sidebar-collapsed .profile-arrow {
  display: none;
}

.sidebar-collapsed .sidebar {
  padding-right: 6px;
  padding-left: 6px;
}
.sidebar-collapsed .brand {
  grid-template-columns: 40px 32px;
  gap: 4px;
  padding-right: 0;
  padding-left: 0;
}

.sidebar-collapsed .sidebar-body {
  display: grid;
  padding-right: 0;
}
.sidebar-collapsed .nav-group {
  gap: 2px;
}
.sidebar-collapsed .nav-group-items {
  gap: 3px;
}
.sidebar-collapsed .nav-item {
  justify-content: center;
  min-height: 42px;
  padding: 8px 4px;
}
.sidebar-collapsed .nav-item-main {
  justify-content: center;
  gap: 0;
}
.sidebar-collapsed .nav-badge {
  display: none;
}

.sidebar-collapsed .profile-entry {
  grid-template-columns: 36px;
  justify-content: center;
  padding: 4px;
}

.sidebar-collapsed .profile-avatar {
  justify-self: center;
}

@media (max-width: 760px) {
  .login-shell {
    padding: 12px;
  }
  .login-layout {
    min-height: 0;
    grid-template-columns: 1fr;
  }
  .login-brand-panel,
  .login-auth-panel {
    padding: 24px;
  }
  .login-brand-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 28px;
  }
  .login-brand-meta span {
    padding: 10px 6px;
    border-right: 1px solid var(--sidebar-line);
    border-bottom: 0;
    text-align: center;
  }
  .login-brand-meta span:last-child {
    border-right: 0;
  }
  .login-brand-footer {
    margin-top: 18px;
  }
  .login-panel {
    margin-top: 26px;
  }
}

@media (max-width: 980px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar,
  body.sidebar-collapsed .sidebar {
    position: static;
    height: auto;
    padding: 10px;
  }
  .sidebar-body,
  body.sidebar-collapsed .sidebar-body {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 4px;
  }
  .nav-group {
    min-width: max-content;
  }
  .nav-group-head,
  body.sidebar-collapsed .nav-group-head {
    display: none;
  }
  .nav-group-items {
    display: flex;
  }
  .nav-item,
  body.sidebar-collapsed .nav-item {
    width: auto;
    min-height: 40px;
    justify-content: flex-start;
    padding: 8px 10px;
  }
  .nav-item-main,
  body.sidebar-collapsed .nav-item-main {
    justify-content: flex-start;
    gap: 8px;
  }
  body.sidebar-collapsed .nav-label {
    display: inline;
  }
  .sidebar-footer {
    display: none;
  }
  .brand,
  body.sidebar-collapsed .brand {
    grid-template-columns: 40px minmax(0, 1fr) 32px;
    gap: 10px;
  }
  body.sidebar-collapsed .brand-copy {
    display: block;
  }
  .topbar {
    grid-template-columns: 1fr;
  }
  .topbar-actions,
  .topbar-tools {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 10px 10px 20px;
  }
  .topbar {
    position: relative;
    padding: 12px;
    margin-bottom: 10px;
  }
  .topbar-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .topbar-select {
    min-width: 0;
  }
  .topbar-actions {
    width: 100%;
    gap: 7px;
  }
  .topbar-actions .button {
    flex: 1 1 auto;
  }
  .block {
    padding: 12px;
  }
  .block-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .block-head > div {
    display: flex;
    flex-wrap: wrap;
  }
  .screen-actions,
  .import-row {
    width: 100%;
  }
  .screen-actions .button,
  .import-row .button,
  .import-row select {
    flex: 1 1 140px;
  }
}

@media (max-width: 980px) {
  .dashboard-alert-grid,
  .dashboard-chart-grid,
  .dashboard-lower-grid,
  .metric-grid,
  .two-column,
  .screen-two,
  .screen-layout,
  .screen-ring-row,
  .screen-camera-grid,
  .screen-hero-grid,
  .screen-important,
  .screen-compact-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }
  .screen-top {
    flex-direction: column;
  }
  .screen-actions {
    justify-content: flex-start;
  }
  .search-box input {
    max-width: none;
  }
}

.empty-state-card {
  max-width: 520px;
  margin: 72px auto;
  padding: 40px 32px;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}
.empty-state-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
  color: var(--text);
}
.empty-state-card p {
  margin: 0;
  color: var(--text-2);
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
