/* ============================================
   COMPONENTS — 高级感 · 苹果风
   大量留白，极简边框，大圆角，精细字体
   ============================================ */

/* ── 全局重置 ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--text-primary);
  background: var(--bg-secondary);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 页面结构 ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-8);
}

/* ── 页面头部 ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
}
.page-header-group { }
.page-title {
  font-size: var(--text-title2);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: var(--text-subhead);
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: var(--weight-regular);
}

/* ── 筛选/操作栏 ── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}
.toolbar-left {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-right {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-subhead);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  line-height: 1.3;
  white-space: nowrap;
  letter-spacing: 0.01em;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary-500);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }

.btn-secondary {
  background: transparent;
  color: var(--primary-500);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}

.btn-plain {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-plain:hover:not(:disabled) { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--primary-500);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover:not(:disabled) { opacity: 0.85; }

.btn-sm { padding: 5px 12px; font-size: var(--text-footnote); border-radius: var(--radius-sm); }
.btn-lg { padding: 10px 24px; font-size: var(--text-callout); }

/* 按钮组 */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-light);
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.active {
  background: var(--primary-50);
  color: var(--primary-500);
  font-weight: var(--weight-semibold);
}

/* ── 分段控制器（iOS风格） ── */
.segmented-control {
  display: inline-flex;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}
.segmented-item {
  padding: 6px 16px;
  border-radius: 7px;
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.segmented-item:hover { color: var(--text-primary); }
.segmented-item.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

/* ── 搜索框 ── */
.search-field {
  position: relative;
}
.search-field .input {
  padding-left: 34px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 14px;
  pointer-events: none;
}

/* ── 卡片 ── */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: var(--space-4); }

.surface-focus {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.surface-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) var(--space-6) 0;
}
.card-title {
  font-size: var(--text-headline);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.2px;
}
.card-body { padding: var(--space-5) var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ── 表格 ── */
.table-container {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-primary);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-subhead);
}
.table th {
  text-align: left;
  padding: 12px var(--space-5);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: var(--text-footnote);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.table td {
  padding: 14px var(--space-5);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-tertiary); }

/* ── 输入框 ── */
.input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-callout);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}
.input::placeholder {
  color: var(--text-quaternary);
}
.input-sm { padding: 7px 12px; font-size: var(--text-subhead); }

select.input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

textarea.input {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* ── 标签 ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger  { background: var(--danger-bg); color: var(--danger-text); }
.badge-primary { background: var(--primary-100); color: var(--primary-800); font-weight: var(--weight-medium); }
.badge-plain   { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ── 空状态 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-tertiary);
  text-align: center;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}
.empty-state-title {
  font-size: var(--text-headline);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.empty-state-text {
  font-size: var(--text-callout);
  color: var(--text-tertiary);
  max-width: 320px;
}

/* ── 弹窗/模态框 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  min-width: 480px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: scaleIn 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-6) 0;
}
.modal-title { font-size: var(--text-title3); font-weight: var(--weight-semibold); }
.modal-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s;
}
.modal-close-btn:hover { background: var(--bg-hover); }
.modal-body { padding: var(--space-5) var(--space-6); }
.modal-footer {
  padding: var(--space-5) var(--space-6);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  border-top: 1px solid var(--border-light);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ── 表单 ── */
.form-group { margin-bottom: var(--space-5); }
.form-label {
  display: block;
  font-size: var(--text-subhead);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.form-hint {
  font-size: var(--text-footnote);
  color: var(--text-tertiary);
  margin-top: 4px;
}
.form-error {
  font-size: var(--text-footnote);
  color: var(--danger);
  margin-top: 4px;
}

/* ── 侧边栏 ── */
.sidebar {
  width: 260px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  height: 100vh;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) 0;
}
.sidebar-logo {
  padding: 0 var(--space-5) var(--space-8);
  font-size: var(--text-headline);
  font-weight: var(--weight-bold);
  color: var(--primary-500);
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-3); }
.nav-section-title {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: var(--text-footnote);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-callout);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-weight: var(--weight-regular);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-50);
  color: var(--primary-500);
  font-weight: var(--weight-semibold);
}
.nav-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--primary-100);
  color: var(--primary-700);
}

/* ── 主内容区 ── */
.main-content {
  flex: 1;
  background: var(--bg-secondary);
  min-height: 100vh;
}

/* ── 统计卡片 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}
.stat-label {
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-value {
  font-size: var(--text-title1);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.stat-change {
  font-size: var(--text-footnote);
  margin-top: var(--space-2);
  font-weight: var(--weight-medium);
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── 加载 ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  color: var(--text-tertiary);
  gap: var(--space-3);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 提示/Toast ── */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-subhead);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--info); color: white; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── 头像/Icon ── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-footnote);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-callout); }

/* ── 分割线 ── */
.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--space-6) 0;
}

/* ── 行内描述 ── */
.inline-label {
  font-size: var(--text-footnote);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  margin-right: var(--space-1);
}
.inline-value {
  font-size: var(--text-callout);
  color: var(--text-primary);
}
