:root {
  --bg: #f3f5f9;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --success: #12b76a;
  --warning: #f79009;
  --shadow: 0 20px 50px rgba(16, 24, 40, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(18, 183, 106, 0.08), transparent 20%),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.login-title,
.section-title {
  margin: 18px 0 8px;
  font-size: 30px;
  line-height: 1.2;
}

.login-desc,
.section-desc {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.6;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.92);
}

.chip {
  border: 1px solid rgba(228, 231, 236, 0.9);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(16, 24, 40, 0.92);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.chip:hover {
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 10px 18px rgba(16, 24, 40, 0.06);
}

.chip.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.32);
  color: var(--primary);
  box-shadow: none;
}

.status-toggle {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.92);
}

.status-option {
  flex: 1 1 0;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.status-option::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(102, 112, 133, 0.45);
}

.status-run::before {
  background: rgba(18, 183, 106, 0.9);
}

.status-offline::before {
  background: rgba(217, 45, 32, 0.9);
}

.status-option.active {
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  border-color: rgba(228, 231, 236, 0.95);
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.06);
}

.status-option.active.status-run {
  background: rgba(18, 183, 106, 0.1);
  border-color: rgba(18, 183, 106, 0.22);
  color: #067647;
}

.status-option.active.status-offline {
  background: rgba(217, 45, 32, 0.08);
  border-color: rgba(217, 45, 32, 0.18);
  color: #b42318;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.textarea {
  min-height: 112px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

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

.button {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.button-secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.button-danger {
  background: #fff5f5;
  border: 1px solid rgba(217, 45, 32, 0.18);
  color: #b42318;
}

.login-hint,
.helper-text,
.empty-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.error-text {
  min-height: 20px;
  margin-top: 10px;
  color: #d92d20;
  font-size: 13px;
}

.dashboard-view {
  display: grid;
  grid-template-columns: minmax(280px, 296px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  min-height: calc(100vh - 56px);
  width: 100%;
}

.sidebar,
.main-panel,
.summary-card,
.device-card,
.modal-panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 28px;
  border-radius: 32px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 56px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 2px;
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.brand-mark::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 9px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 17px solid #ffffff;
  filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.18));
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #93c5fd;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
}

.brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav-card {
  border-radius: 24px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(244, 247, 255, 0.95), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(228, 231, 236, 0.9);
  margin-bottom: 0;
}

.nav-title {
  margin: 0;
  font-size: 18px;
}

.sidebar .stats-grid {
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}

.sidebar .summary-card {
  grid-column: span 1;
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: none;
  border: 1px solid rgba(228, 231, 236, 0.9);
}

.sidebar .summary-value {
  font-size: 30px;
  margin-bottom: 8px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 8px;
}

.user-card {
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, #0f172a, #172554);
  color: #fff;
  margin-top: 0;
}

.user-label {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  margin-bottom: 4px;
}

.main-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - 56px);
  min-height: calc(100vh - 56px);
}

.workspace-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

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

.workspace-card {
  border-radius: 30px;
  padding: 22px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.device-grid,
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
  grid-auto-rows: minmax(228px, auto);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  align-content: start;
}

.device-grid.empty-mode {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
}

.device-grid::-webkit-scrollbar,
.skeleton-grid::-webkit-scrollbar {
  width: 8px;
}

.device-grid::-webkit-scrollbar-thumb,
.skeleton-grid::-webkit-scrollbar-thumb {
  background: rgba(102, 112, 133, 0.35);
  border-radius: 999px;
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.summary-note {
  font-size: 13px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 0 2px;
}

.search-wrap {
  flex: 1 1 320px;
  position: relative;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-wrap .input {
  min-height: 48px;
  padding-left: 46px;
  background: var(--surface-soft);
}

.content-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 0 2px;
}

.content-title {
  margin: 0 0 6px;
  font-size: 20px;
}

.content-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
}

.device-card,
.skeleton-card {
  border-radius: 24px;
  padding: 20px;
  min-height: 228px;
}

.device-card {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid rgba(228, 231, 236, 0.95);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  display: grid;
  grid-template-rows: auto auto 1fr;
  row-gap: 12px;
}

.device-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 44px rgba(16, 24, 40, 0.12);
  border-color: rgba(37, 99, 235, 0.2);
}

.device-top,
.device-meta,
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.device-top {
  align-items: center;
  margin-bottom: 0;
}

.device-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.device-head {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
}

.device-name {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.35;
  word-break: break-word;
}

.device-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-running {
  background: rgba(18, 183, 106, 0.14);
  color: #067647;
}

.badge-idle {
  background: rgba(247, 144, 9, 0.14);
  color: #b54708;
}

.device-timer-wrap {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));
  border: 1px solid rgba(228, 231, 236, 0.9);
  margin-top: auto;
}

.device-timer {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 6px 0 0;
  line-height: 1;
}

.meta-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.meta-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.empty-state {
  border: 1px dashed rgba(102, 112, 133, 0.28);
  border-radius: 24px;
  padding: 32px 24px;
  min-height: 228px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(248, 250, 252, 0.8);
}

.device-grid.empty-mode .empty-state {
  min-height: 100%;
  height: 100%;
}

.skeleton-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(228, 231, 236, 0.9);
}

.skeleton-line {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eceff3 25%, #f7f8fa 50%, #eceff3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  margin-bottom: 12px;
}

.skeleton-line.large {
  height: 30px;
  margin: 20px 0;
}

.skeleton-line.short {
  width: 42%;
}

.skeleton-line.medium {
  width: 70%;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
  animation: overlayFadeIn 0.2s ease;
}

.modal-panel {
  width: min(100%, 760px);
  border-radius: 28px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.96);
  animation: modalPopIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 24px;
}

.modal-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.close-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
}

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

.field-span-2 {
  grid-column: span 2;
}

.switch-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.9);
}

.switch-wrap span {
  color: var(--muted);
  font-size: 14px;
}

.switch {
  position: relative;
  width: 54px;
  height: 30px;
  appearance: none;
  background: #d0d5dd;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::after {
  transform: translateX(24px);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #101828;
  color: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  z-index: 120;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

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

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

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1180px) {
}

@media (max-width: 940px) {
  .dashboard-view {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main-panel,
  .workspace-card {
    min-height: auto;
    height: auto;
  }
}

@media (max-width: 760px) {
  .device-grid,
  .skeleton-grid {
    max-height: none;
    min-height: auto;
    overflow: visible;
  }

  .app-shell {
    padding: 18px;
  }

  .content-head,
  .modal-header,
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .button {
    flex: 1 1 0;
  }

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

  .device-card {
    min-height: 220px;
  }
}
