/* ==========================================================================
   云枢路由管理系统 —— 外壳布局、登录页、响应式
   ========================================================================== */

/* --------------------------------------------------------------------------
   启动屏
   -------------------------------------------------------------------------- */
.app-boot {
  min-height: 100vh;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: radial-gradient(1200px 600px at 50% 0%, #e8efff 0%, var(--bg) 55%);
}

.boot-logo {
  filter: drop-shadow(0 12px 24px rgba(37, 99, 235, 0.28));
  margin-bottom: 6px;
}

.boot-title {
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 1px;
}

.boot-sub {
  font-size: 13px;
  color: var(--muted);
}

.boot-spinner {
  margin-top: 14px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* --------------------------------------------------------------------------
   应用外壳
   -------------------------------------------------------------------------- */
.app {
  display: flex;
  min-height: 100vh;
  overflow-x: clip;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-width);
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  border-right: 1px solid #182338;
  transition: transform 0.22s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 19px 18px 16px;
}

.brand-logo {
  display: inline-flex;
  flex: none;
  filter: drop-shadow(0 6px 14px rgba(37, 99, 235, 0.42));
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 650;
  color: #f1f5fb;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--sidebar-muted);
  letter-spacing: 0.3px;
  margin-top: 1px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 11px 16px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  background-clip: content-box;
}

.nav-group {
  margin-top: 14px;
}

.nav-group:first-child {
  margin-top: 2px;
}

.nav-group-title {
  padding: 0 11px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: #5b6b84;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: 9px;
  font-size: 13.5px;
  color: #b6c3d6;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(148, 163, 184, 0.09);
  color: #eef3fb;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.28) 0%, rgba(59, 130, 246, 0.08) 100%);
  color: #fff;
  font-weight: 500;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #3b82f6;
}

.nav-icon {
  display: inline-flex;
  color: #7f92ad;
  flex: none;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  color: #93c5fd;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-foot {
  padding: 12px 14px 15px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user-name {
  font-size: 13px;
  color: #e5ecf7;
  line-height: 1.3;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-muted);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.sidebar-version {
  margin-top: 9px;
  text-align: center;
  font-size: 10.5px;
  color: #475569;
  letter-spacing: 0.3px;
}

.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--nav-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   顶栏
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--top-height);
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-menu {
  display: none;
}

.topbar-crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.crumb-group {
  color: #94a3b8;
}

.crumb-page {
  color: var(--text);
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.mode-badge .dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.mode-badge.mock {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #f6dfb8;
}

.mode-badge.mock .dot {
  background: #d97706;
}

.mode-badge.device {
  background: var(--success-soft);
  color: var(--success);
  border-color: #c9efd8;
}

.mode-badge.device .dot {
  background: #16a34a;
}

.topbar-refresh {
  display: inline-flex;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 9px 0 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.user-menu-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.user-menu-name {
  font-size: 13px;
  color: var(--text-soft);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: 45px;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  animation: menu-in 0.14s ease both;
}

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

.user-menu-info {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}

.user-menu-info strong {
  display: block;
  font-size: 13.5px;
  color: var(--text);
}

.user-menu-info span {
  font-size: 11.5px;
  color: var(--muted);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}

.menu-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: var(--danger-soft);
}

/* --------------------------------------------------------------------------
   内容区 / 待确认条
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px 26px 40px;
}

.pending-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #fff7e6, #fffdf7);
  border: 1px solid #f5d9a3;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.pending-banner .banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fdf0d5;
  color: #b45309;
  flex: none;
}

.pending-banner .banner-text {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
  color: #8a5b0b;
  line-height: 1.55;
}

.pending-banner .banner-text strong {
  color: #92400e;
}

.pending-banner .banner-count {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: #b45309;
  min-width: 62px;
  text-align: center;
}

.pending-banner .banner-actions {
  display: flex;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   登录页
   -------------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(400px, 1fr);
  background: var(--bg);
}

.login-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 38px 52px 34px;
  color: #e2e8f5;
  background:
    radial-gradient(900px 500px at 85% 100%, rgba(37, 99, 235, 0.35) 0%, transparent 60%),
    radial-gradient(700px 420px at 10% 0%, rgba(14, 165, 233, 0.22) 0%, transparent 55%),
    linear-gradient(150deg, #0b1220 0%, #101b34 55%, #0e1a30 100%);
  overflow: hidden;
}

.login-brand-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}

.login-brand-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: #f1f5fb;
  z-index: 1;
}

.login-brand-top small {
  font-size: 11px;
  font-weight: 400;
  color: #7c8ba3;
  letter-spacing: 0.4px;
  margin-left: 2px;
}

.login-hero {
  position: relative;
  margin-top: auto;
  margin-bottom: auto;
  padding: 48px 0 28px;
  z-index: 1;
}

.login-hero h1 {
  font-size: clamp(28px, 3.1vw, 38px);
  font-weight: 650;
  line-height: 1.34;
  letter-spacing: 1px;
  color: #f4f7fc;
}

.login-hero h1 em {
  font-style: normal;
  background: linear-gradient(90deg, #60a5fa, #38bdf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-hero p {
  margin-top: 18px;
  max-width: 460px;
  font-size: 13.5px;
  line-height: 1.9;
  color: #93a4bd;
}

.login-features {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 22px;
  max-width: 480px;
  margin-top: 8px;
  z-index: 1;
}

.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: #a9b8cd;
  line-height: 1.6;
}

.login-feature svg {
  flex: none;
  margin-top: 2px;
  color: #38bdf8;
}

.login-brand-foot {
  position: relative;
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 11.5px;
  color: #64748b;
  z-index: 1;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  background:
    radial-gradient(700px 500px at 90% 10%, #eaf1ff 0%, transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 396px;
  padding: 34px 32px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login-card-head {
  margin-bottom: 24px;
}

.login-card-head h2 {
  font-size: 22px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.3px;
}

.login-card-head p {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-form .field-label {
  font-size: 12.5px;
}

.login-form .input {
  height: 42px;
}

.login-form .btn-primary {
  height: 42px;
  font-size: 14.5px;
  margin-top: 4px;
}

.login-error {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
}

.login-tip {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

.login-foot span {
  display: block;
  margin-top: 4px;
}

.login-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.login-badge-row .badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
  .login-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-brand-panel {
    display: none;
  }

  .login-form-panel {
    min-height: 100vh;
  }
}

@media (max-width: 1000px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .app.nav-open .sidebar {
    transform: none;
  }

  .app.nav-open .sidebar-mask {
    display: block;
    opacity: 1;
  }

  .main {
    margin-left: 0;
  }

  .topbar-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 18px 16px 32px;
  }

  .user-menu-name {
    display: none;
  }

  .mode-badge span.label {
    display: none;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 26px 20px 24px;
  }

  .login-form-panel {
    padding: 20px 14px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .topbar {
    gap: 8px;
  }

  .topbar-crumb {
    flex: 1;
    min-width: 0;
  }

  .crumb-group {
    display: none;
  }

  .crumb-page {
    max-width: 120px;
  }

  .topbar-right {
    gap: 4px;
    flex: none;
  }

  .topbar-refresh {
    display: none;
  }

  .mode-badge {
    padding: 0 7px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .toast {
    max-width: none;
  }

  .pending-banner {
    align-items: flex-start;
  }

  .pending-banner .banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
