/* ==========================================================================
   BrandForge AI — Design System
   Clean Light | Professional Enterprise SaaS Aesthetic
   ========================================================================== */

/* -- Reset -- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-body); background: var(--bg-base); color: var(--text); overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* -- Design Tokens -- */
:root {
  /* Background layers — clean light */
  --bg-base: #f1f5f9;          /* slate-100 */
  --bg-secondary: #f8fafc;     /* slate-50 */
  --bg-tertiary: #f1f5f9;      /* slate-100 */
  --bg-elevated: #ffffff;      /* white */
  --bg-deep: #ffffff;          /* white (sidebar) */

  /* Surfaces */
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-active: #eff6ff;
  --surface-elevated: #ffffff;

  /* Borders — light gray */
  --border: #e2e8f0;           /* slate-200 */
  --border-hover: #cbd5e1;     /* slate-300 */
  --border-strong: #3b82f6;    /* blue-500 */
  --border-subtle: #f1f5f9;

  /* Primary — professional blue */
  --primary: #2563eb;          /* blue-600 */
  --primary-hover: #1d4ed8;    /* blue-700 */
  --primary-active: #1e40af;   /* blue-800 */
  --primary-light: #eff6ff;    /* blue-50 */
  --primary-glow: rgba(37, 99, 235, 0.08);

  /* Gradient — removed; use solid colors */
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #2563eb 100%);
  --gradient-primary-soft: #eff6ff;
  --gradient-bg: #f1f5f9;

  /* Accent colors */
  --accent-teal: #0d9488;      /* teal-600 */
  --accent-green: #16a34a;     /* green-600 */
  --accent-yellow: #ca8a04;    /* yellow-600 */
  --accent-pink: #db2777;      /* pink-600 */
  --accent-orange: #ea580c;    /* orange-600 */
  --accent-blue: #2563eb;      /* blue-600 */
  --accent-red: #dc2626;       /* red-600 */

  /* Text — dark on light */
  --text: #0f172a;             /* slate-900 */
  --text-secondary: #475569;   /* slate-600 */
  --text-muted: #94a3b8;       /* slate-400 */
  --text-dim: #cbd5e1;         /* slate-300 */

  /* Typography */
  --font-display: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;

  /* Font sizes */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;
  --fs-4xl: 40px;
  --fs-5xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows — subtle, professional */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-glow: none;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --content-max: 1400px;
}

/* -- Body Background -- */
body {
  background: var(--bg-base);
  min-height: 100vh;
  position: relative;
}

body::before { display: none; }

/* ==========================================================================
   App Shell
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* -- Sidebar Nav -- */
.app-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.nav-brand {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  flex-shrink: 0;
}

.nav-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-brand-icon svg { width: 18px; height: 18px; color: #fff; }

.nav-brand-text {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.nav-section {
  padding: var(--sp-4) var(--sp-3);
}

.nav-section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 var(--sp-3) var(--sp-2);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  position: relative;
}

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

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-left: auto;
  font-size: var(--fs-xs);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-footer {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-user:hover { background: var(--surface-hover); }

.nav-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.nav-user-info { flex: 1; min-width: 0; }
.nav-user-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.nav-user-role { font-size: var(--fs-xs); color: var(--text-muted); }

.nav-logout-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-logout-btn:hover { background: var(--surface-hover); color: var(--accent-red); }
.nav-logout-btn svg { width: 18px; height: 18px; }

/* 移动端导航触发按钮 + 遮罩（P1-16） */
.nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 110;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.nav-toggle svg { width: 20px; height: 20px; }

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 95;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }

/* 编辑器三栏响应式堆叠（P1-21） */
.editor-cols { align-items: flex-start; }
@media (max-width: 980px) {
  .editor-cols { flex-direction: column; }
  .editor-cols > .editor-col {
    width: 100% !important;
    flex: 1 1 auto !important;
    max-width: 100%;
  }
}

/* -- Main Content Area -- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -- Top Bar -- */
.top-bar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.top-bar-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-left: var(--sp-3);
}

.top-bar-search {
  margin-left: auto;
  position: relative;
  width: 240px;
}

.top-bar-search input {
  width: 100%;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3) 0 36px;
  color: var(--text);
  font-size: var(--fs-sm);
  transition: border-color 0.15s;
}

.top-bar-search input::placeholder { color: var(--text-muted); }
.top-bar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.top-bar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  position: relative;
}

.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

.icon-btn-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--accent-red);
  border: 2px solid var(--bg-elevated);
}

/* -- Content -- */
.page-content {
  padding: var(--sp-6);
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   Components
   ========================================================================== */

/* -- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 600;
  transition: all 0.15s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn svg { width: 16px; height: 16px; stroke-width: 2; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: #fef2f2;
  color: var(--accent-red);
  border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { height: 46px; padding: 0 var(--sp-8); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* -- Cards -- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}

.card-hover:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* -- Stat Cards -- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.stat-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0.8;
}

.stat-card-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}

.stat-card-value {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-card-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--sp-2);
  font-size: var(--fs-sm);
}

.stat-card-trend.up { color: var(--accent-green); }
.stat-card-trend.down { color: var(--accent-red); }

.stat-card-icon {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
}

.stat-card-icon svg { width: 20px; height: 20px; color: var(--primary); }

/* -- Badges / Tags -- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
}

.badge-success { background: #dcfce7; color: var(--accent-green); }
.badge-warning { background: #fef3c7; color: var(--accent-yellow); }
.badge-danger { background: #fee2e2; color: var(--accent-red); }
.badge-info { background: #dbeafe; color: var(--accent-blue); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-teal { background: #ccfbf1; color: var(--accent-teal); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* -- Inputs -- */
.input-group { margin-bottom: var(--sp-4); }

.input-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.input-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.input,
textarea.input,
select.input {
  width: 100%;
  height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color 0.15s;
}

textarea.input { height: auto; padding: var(--sp-3); min-height: 80px; resize: vertical; line-height: 1.5; }

.input::placeholder { color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* -- Tables -- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

table.data-table thead {
  background: var(--bg-tertiary);
}

table.data-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td {
  padding: var(--sp-4);
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}

table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.1s; }
table.data-table tbody tr:hover { background: var(--surface-hover); }

/* -- Progress -- */
.progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* -- Section -- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.section-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* -- Grids -- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

/* -- Agent Pipeline -- */
.agent-pipeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.agent-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.2s;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.agent-step.completed { border-color: #bbf7d0; }
.agent-step.running { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.agent-step.pending { opacity: 0.5; }

.agent-step-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.agent-step.completed .agent-step-icon { background: #dcfce7; color: var(--accent-green); }
.agent-step.running .agent-step-icon { background: var(--primary-light); color: var(--primary); }
.agent-step.pending .agent-step-icon { background: var(--bg-tertiary); color: var(--text-muted); }

.agent-step-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }

.agent-step-content { flex: 1; min-width: 0; }
.agent-step-name { font-size: var(--fs-base); font-weight: 600; color: var(--text); margin-bottom: 2px; }
.agent-step-desc { font-size: var(--fs-sm); color: var(--text-muted); }
.agent-step-meta { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }

.agent-step-status {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.agent-step.completed .agent-step-status { background: #dcfce7; color: var(--accent-green); }
.agent-step.running .agent-step-status { background: var(--primary-light); color: var(--primary); }
.agent-step.pending .agent-step-status { background: var(--bg-tertiary); color: var(--text-muted); }

/* -- Spinner -- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* -- GEO Score Ring -- */
.geo-score-ring {
  width: 120px;
  height: 120px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.geo-score-ring svg { transform: rotate(-90deg); }
.geo-score-ring-value {
  position: absolute;
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* -- Wizard Steps -- */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-8);
}

.wizard-step-dot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.wizard-step-num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.wizard-step-dot.active .wizard-step-num {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.wizard-step-dot.completed .wizard-step-num {
  background: #dcfce7;
  color: var(--accent-green);
  border-color: transparent;
}

.wizard-step-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.wizard-step-dot.active .wizard-step-label { color: var(--text); }

.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: var(--radius-full);
}

.wizard-step-line.completed { background: var(--accent-green); }

/* -- Toggle Switch -- */
.toggle {
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  transition: all 0.2s;
}

.toggle.on { background: var(--primary-light); border-color: var(--primary); }
.toggle.on::after { left: 20px; background: var(--primary); }

/* -- Code Block -- */
.code-block {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
}

.code-block .k { color: var(--accent-pink); }
.code-block .s { color: var(--accent-green); }
.code-block .c { color: var(--text-muted); font-style: italic; }
.code-block .p { color: var(--accent-blue); }
.code-block .n { color: var(--accent-orange); }

/* -- Empty State -- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

.empty-state-icon svg { width: 28px; height: 28px; color: var(--text-muted); }
.empty-state-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: var(--sp-1); }
.empty-state-desc { font-size: var(--fs-sm); color: var(--text-muted); max-width: 320px; }

/* -- Toast -- */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}

/* -- Modal (P2-16: 由 billing.html 内联样式提升为公共组件) -- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: 16px;
  width: min(440px, 92vw);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: popIn .25s ease;
}
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--text, #0f172a); }
.modal-close {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted, #94a3b8); cursor: pointer;
}
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid #f1f5f9;
  display: flex; gap: 10px; justify-content: flex-end;
}

/* -- Divider -- */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

/* -- Tab Bar -- */
.tab-bar {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
}

.tab-item {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* -- Misc Utilities -- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.text-sm { font-size: var(--fs-sm); } .text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--text-muted); } .text-secondary { color: var(--text-secondary); }
.font-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* -- Animations (restrained) -- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.3s ease-out both; }
.fade-in-up:nth-child(1) { animation-delay: 0.02s; }
.fade-in-up:nth-child(2) { animation-delay: 0.06s; }
.fade-in-up:nth-child(3) { animation-delay: 0.1s; }
.fade-in-up:nth-child(4) { animation-delay: 0.14s; }
.fade-in-up:nth-child(5) { animation-delay: 0.18s; }
.fade-in-up:nth-child(6) { animation-delay: 0.22s; }

/* -- Responsive -- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .app-nav { transform: translateX(-100%); transition: transform 0.2s; }
  .app-nav.open { transform: translateX(0); width: 240px; }
  .nav-toggle { display: flex; }
  .top-bar { padding-left: 56px; }
  .top-bar-search { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .page-content { padding: var(--sp-4); }
}

/* 表单必填校验高亮（P2-19） */
.input.input-error,
textarea.input.input-error {
  border-color: var(--danger, #ef4444);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.input-error-hint {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger, #ef4444);
}
.input-error-hint.show { display: block; }

/* 列表/数据区空态（P2-18） */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 12px;
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state-desc { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* 向导生成页操作按钮（P2-22） */
.gen-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

/* P2-20 响应式中间断点：平板 769–1023 区间 */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app-nav { transform: translateX(-100%); transition: transform 0.2s; }
  .app-nav.open { transform: translateX(0); width: 240px; }
  .nav-toggle { display: flex; }
  .top-bar { padding-left: 56px; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .top-bar { padding-left: 52px; gap: 8px; }
  .top-bar-actions { gap: 4px; }
  .top-bar-title { font-size: 18px; }
  .page-content { padding: var(--sp-3, 16px); }
  .grid-2, .grid-3, .grid-4, .stat-grid { grid-template-columns: 1fr !important; }
  .geo-hero-banner { flex-direction: column; }
}

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
