
:root {
  --bg: #020617;
  --bg-elevated: #020617;
  --bg-soft: rgba(15, 23, 42, 0.85);
  --card: rgba(15, 23, 42, 0.95);
  --border-subtle: rgba(51, 65, 85, 0.9);
  --border-strong: rgba(30, 64, 175, 0.9);
  --accent: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.28);
  --accent-strong: #4f46e5;
  --accent-green: #22c55e;
  --accent-amber: #facc15;
  --accent-red: #f97373;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-strong: 0 26px 60px rgba(15, 23, 42, 0.88);
  --shadow-card: 0 16px 35px rgba(15, 23, 42, 0.82);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.75);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 0 0, #0f172a 0, transparent 55%),
    radial-gradient(circle at 100% 0, #1e293b 0, transparent 55%),
    #020617;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
}

/* 通用 */

.view {
  display: none;
}

.view-active {
  display: block;
}

.page {
  display: none;
}

.page-active {
  display: block;
}

.page h2 {
  margin: 0 0 0.35rem;
  font-size: 1.28rem;
  letter-spacing: 0.01em;
}

.page-desc {
  margin: 0 0 0.9rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 登录 */

.login-wrapper {
  padding: 2.4rem 1rem 2.8rem;
}

.login-card {
  max-width: 880px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  padding: 2.2rem 2.4rem;
  background:
    radial-gradient(circle at 0 0, rgba(129, 140, 248, 0.28), transparent 55%),
    radial-gradient(circle at 100% 0, rgba(56, 189, 248, 0.25), transparent 55%),
    linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(22px);
}

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  margin-bottom: 1.6rem;
}

.login-title-group h1 {
  margin: 0;
  font-size: 1.4rem;
}

.login-title-group p {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.login-tag {
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.88);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.login-body {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 1.3rem 1.5rem;
}

/* 表单元素 */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.9rem;
}

.field span {
  color: var(--text-main);
}

.field small {
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  padding: 0.52rem 0.6rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(71, 85, 105, 0.9);
  background: rgba(15, 23, 42, 0.94);
  color: var(--text-main);
  outline: none;
  font-size: 0.9rem;
  -webkit-appearance: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(129, 140, 248, 0.95);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.7);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

/* 按钮 */

.btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
  font-size: 0.86rem;
  padding: 0.46rem 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.14s ease-out;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn.full {
  width: 100%;
  justify-content: center;
}

.btn.small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.btn.primary {
  background: linear-gradient(135deg, #4f46e5, #22d3ee);
  border-color: transparent;
  color: #f9fafb;
  box-shadow: 0 16px 35px rgba(56, 189, 248, 0.55);
}

.btn.primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn.secondary {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(59, 130, 246, 0.7);
}

.btn.secondary:hover {
  background: rgba(37, 99, 235, 0.3);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #f97316);
  border-color: transparent;
  color: #fef2f2;
  box-shadow: 0 12px 30px rgba(248, 113, 113, 0.6);
}

.btn.danger.ghost {
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(254, 202, 202, 0.7);
}

/* 顶部栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.7rem 1.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid rgba(30, 64, 175, 0.8);
  background:
    radial-gradient(circle at 0 0, rgba(129, 140, 248, 0.22), transparent 60%),
    rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.brand-main {
  font-size: 0.98rem;
  font-weight: 600;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.account-info {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(51, 65, 85, 0.95);
}

.account-label {
  font-size: 0.82rem;
}

.account-switch {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
  font-size: 0.82rem;
}

/* Workers 计划 pill */

.plan-pill {
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-size: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.96);
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.plan-pill-free {
  border-color: rgba(148, 163, 184, 0.9);
  background: rgba(31, 41, 55, 0.94);
  color: #e5e7eb;
}

.plan-pill-bundled {
  border-color: rgba(96, 165, 250, 0.95);
  background: rgba(37, 99, 235, 0.35);
  color: #dbeafe;
}

.plan-pill-paid {
  border-color: rgba(244, 114, 182, 0.96);
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(59, 130, 246, 0.35));
  color: #fdf2ff;
}

/* 主布局 */

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

/* 侧边栏 */

.sidebar {
  padding: 1.1rem 0.9rem 1.6rem;
  border-right: 1px solid rgba(30, 64, 175, 0.8);
  background:
    radial-gradient(circle at 0 0, rgba(30, 64, 175, 0.32), transparent 58%),
    rgba(15, 23, 42, 0.98);
}

.sidebar-section + .sidebar-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px dashed rgba(55, 65, 81, 0.9);
}

.sidebar-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  padding: 0 0.2rem;
}

.nav-item {
  width: 100%;
  margin: 0.12rem 0;
  text-align: left;
  padding: 0.42rem 0.8rem;
  border-radius: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-item span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-item:hover {
  background: rgba(15, 23, 42, 0.88);
}

.nav-item.active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.9);
}

/* 主内容 */

.main {
  padding: 1.1rem 1.4rem 2.1rem;
}

/* 卡片 */

.card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
}

.card h3 {
  margin: 0 0 0.55rem;
  font-size: 0.98rem;
}

/* 工具条 */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.toolbar input {
  flex: 1;
}

/* grid */

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

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

/* 卡片网格 */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.8rem;
}

/* 开关 */

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-pill {
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: #374151;
  position: relative;
  transition: background 0.18s ease-out;
}

.toggle-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #f9fafb;
  top: 2px;
  left: 2px;
  transition: transform 0.18s ease-out;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.7);
}

.toggle input:checked + .toggle-pill {
  background: #4f46e5;
}

.toggle input:checked + .toggle-pill .toggle-thumb {
  transform: translateX(18px);
}

/* 表格 */

.table {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.96);
  overflow: hidden;
  font-size: 0.83rem;
}

.table-header,
.table-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: center;
  padding: 0.4rem 0.6rem;
  column-gap: 0.35rem;
}

.table-header {
  background: rgba(15, 23, 42, 0.99);
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.table-row:nth-child(odd) {
  background: rgba(15, 23, 42, 0.94);
}

.table-row:nth-child(even) {
  background: rgba(15, 23, 42, 0.99);
}

.table-row:hover {
  background: rgba(30, 64, 175, 0.35);
}

.table-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 域名套餐 pill（仅付费显示） */

.zone-plan-pill {
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-size: 0.7rem;
  border-width: 1px;
  border-style: solid;
}

.zone-plan-pro {
  border-color: rgba(96, 165, 250, 0.95);
  background: rgba(37, 99, 235, 0.35);
  color: #dbeafe;
}

.zone-plan-business {
  border-color: rgba(249, 115, 22, 0.95);
  background: rgba(234, 88, 12, 0.28);
  color: #fed7aa;
}

.zone-plan-enterprise {
  border-color: rgba(244, 114, 182, 0.98);
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.34), rgba(236, 72, 153, 0.36));
  color: #fdf2ff;
}

.zone-plan-other {
  border-color: rgba(148, 163, 184, 0.9);
  background: rgba(31, 41, 55, 0.96);
  color: #e5e7eb;
}

/* 历史记录 & 简易列表 */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-item {
  padding: 0.5rem 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.97);
  font-size: 0.8rem;
}

.history-item .meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* 模板卡片 */

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.template-card {
  border-radius: 0.9rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.97);
  padding: 0.7rem 0.8rem;
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.template-card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.template-card .desc {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.template-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.template-card .actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.badge-blue {
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.85);
  background: rgba(37, 99, 235, 0.25);
  padding: 0.04rem 0.4rem;
  font-size: 0.7rem;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: env(safe-area-inset-bottom, 1.3rem);
  transform: translateX(-50%);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.98);
  color: var(--text-main);
  font-size: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: var(--shadow-soft);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -10px);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.85);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.95);
}

/* Loading 遮罩 */

.loading-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.loading-backdrop.hidden {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.65);
  border-top-color: #38bdf8;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.4rem;
}

.loading-text {
  font-size: 0.84rem;
  color: var(--text-muted);
}

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

/* Dashboard summary */

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.stat-card {
  border-radius: 0.9rem;
  padding: 0.55rem 0.7rem;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(31, 41, 55, 0.9);
  font-size: 0.8rem;
}

.stat-card .label {
  color: var(--text-muted);
  margin-bottom: 0.18rem;
}

.stat-card .value {
  font-weight: 600;
}

/* 响应式 */

@media (max-width: 960px) {
  .login-card {
    margin: 1.3rem 0.5rem;
    padding: 1.6rem 1.5rem;
  }
  .login-body {
    grid-template-columns: 1fr;
  }
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0.7rem 1.1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(30, 64, 175, 0.8);
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
  }
  .sidebar-section {
    flex: 1 1 220px;
  }
  .main {
    padding-inline: 1rem;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .login-card {
    margin: 1rem 0.2rem;
    padding: 1.4rem 1.1rem;
  }
  .login-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-right {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
}
