/* ============================================
   GEO SaaS — 设计系统（沿用大道智创官网风格）
   ============================================ */

:root {
  /* 主色 */
  --p: #1a73e8;             /* Google Blue */
  --p-light: #4285f4;
  --p-dark: #1557b0;
  --p-bg: #e8f0fe;
  --c: #00c6ff;             /* 渐变辅色 */

  /* 状态色 */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  /* 中性色 */
  --bg: #f8fafc;
  --surface: #ffffff;
  --sidebar-bg: #1f2937;
  --sidebar-fg: #d1d5db;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);

  /* 渐变 */
  --gradient-primary: linear-gradient(135deg, var(--p) 0%, var(--c) 100%);
}

/* ============================================
   基础重置
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--p);
  text-decoration: none;
}

a:hover {
  color: var(--p-dark);
}

/* ============================================
   布局：登录页（全屏居中）
   ============================================ */
.auth-page {
  min-height: 100vh;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.auth-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 13px;
}

/* ============================================
   布局：后台（侧边栏 + 顶部栏 + 内容区）
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 20px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.sidebar-brand .logo {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.sidebar-brand .title {
  font-size: 15px;
  font-weight: 600;
  color: #f3f4f6;
  line-height: 1.3;
}

.sidebar-brand .sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

.sidebar-group {
  margin-bottom: 16px;
}

.sidebar-group-title {
  font-size: 11px;
  color: var(--text-soft);
  padding: 0 24px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--sidebar-fg);
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.sidebar-link.active {
  background: rgba(26, 115, 232, 0.15);
  color: white;
  border-left-color: var(--p);
}

.sidebar-link .badge {
  margin-left: auto;
  background: var(--p);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-link .badge-l1 {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.sidebar-link .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* 主内容区 */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 顶部栏 */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* 内容区 */
.content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

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

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.page-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ============================================
   通用组件
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card + .card {
  margin-top: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

.btn-primary:hover {
  opacity: 0.92;
  color: white;
}

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger  { background: var(--danger);  color: white; }
.btn-ghost   { background: transparent; border-color: var(--border); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

select.form-control { cursor: pointer; }

/* 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}

.table tr:hover td {
  background: var(--bg);
}

.table-actions {
  display: flex;
  gap: 6px;
}

/* 标签 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #374151; }

/* Flash 提示 */
.flash {
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid;
}

.flash-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.flash-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.flash-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* 指标卡片 */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.metric-trend {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* 风险等级 */
.risk-low      { color: var(--success); }
.risk-medium   { color: var(--warning); }
.risk-high     { color: var(--danger); }
.risk-critical { color: var(--danger); font-weight: 600; }

/* 评分 */
.score-a { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.score-b { background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; }
.score-c { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.score-d { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; }

.score-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}

/* GEO 评分明细列表 */
.geo-rule-list {
  list-style: none;
  padding: 0;
}

.geo-rule-list li {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.geo-rule-list .rule-hit {
  background: #f0fdf4;
  color: #166534;
}

.geo-rule-list .rule-miss {
  background: #fef2f2;
  color: #991b1b;
}

.geo-rule-list .rule-point {
  margin-left: auto;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar .form-control {
  width: auto;
  min-width: 180px;
}

.toolbar-spacer { flex: 1; }

/* 空状态 */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* 详情页布局 */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  .detail-grid { grid-template-columns: 2fr 1fr; }
}

@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
  .sidebar { width: 200px; }
  .topbar-user span { display: none; }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 12px 0; }
  .sidebar-brand { padding: 0 16px 12px; }
  .metrics-grid,
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

/* ============================================
   M2.1 — 平台超管 + OEM 配套样式
   ============================================ */

/* 页面大标题 */
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.page-header .muted { color: var(--text-muted); font-size: 13px; }

/* 卡片头部（带右侧操作） */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.mt-24 { margin-top: 24px; }

/* 卡片网格（指标卡 / stat-card 用） */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-primary);
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-card .stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-extra {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

/* 数据表格（替代 .table，列宽更稳） */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(0, 0, 0, 0.015); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .ts {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table code {
  font-size: 11.5px;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  color: var(--text);
}
.data-table .muted { color: var(--text-muted); }
.data-table .empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
}

/* 操作列按钮组（多个按钮排开） */
.data-table .actions,
td .actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.data-table form { display: inline-block; margin: 0; }

/* 表单字段（平台超管编辑页用） */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.form-row > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.form-row > label small {
  font-weight: normal;
  color: var(--text-muted);
  margin-left: 4px;
}
.form-row > .form-control,
.form-row > input,
.form-row > select,
.form-row > textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.form-row > input:focus,
.form-row > select:focus,
.form-row > textarea:focus {
  outline: none;
  border-color: var(--brand-primary, var(--p));
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}
.form-row > input[type="color"] {
  padding: 4px;
  height: 44px;
  cursor: pointer;
}
.form-row > input:disabled,
.form-row > input[disabled] {
  background: var(--bg);
  color: var(--text-muted);
}

/* 并排两列（如两个 color picker） */
.form-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.form-row-grid > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row-grid > div > label {
  font-size: 13px;
  font-weight: 500;
}

/* 表单按钮组 */
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* 颜色预览芯片 */
.color-chip {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  vertical-align: middle;
  margin-right: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

/* 按钮：outline / secondary */
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  border-color: var(--brand-primary, var(--p));
  color: var(--brand-primary, var(--p));
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 0 4px;
  flex-wrap: wrap;
}
.pagination .muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* 列表空状态 */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.45;
}

/* 顶部栏细节微调 */
.topbar {
  min-height: 56px;
}
.tenant-switcher select {
  min-width: 180px;
  height: 32px;
}

/* 边角圆润化 */
.sidebar-brand .logo.logo-img {
  object-fit: cover;
  border-radius: 10px;
  background: var(--bg);
}

/* 卡片 padding 调整（避免 header 边距负数撑变形） */
.card { padding: 18px; }
.card-header + * { margin-top: 0; }

/* data-table 卡片内边距 */
.card .data-table { margin: -18px; }
.card .data-table thead th:first-child,
.card .data-table tbody td:first-child { padding-left: 18px; }
.card .data-table thead th:last-child,
.card .data-table tbody td:last-child { padding-right: 18px; }