/* 基础布局与组件结构 — 颜色由 themes/*.css 通过 CSS 变量提供 */

:root {
  --sidebar-width: 240px;
  /* 默认 fallback（modern 加载前） */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-muted: #f1f5f9;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius-card: 0.75rem;
  --radius-button: 0.375rem;
  --table-header-bg: #f8fafc;
  --sidebar-bg: var(--bg-card);
  --sidebar-active-bg: var(--accent-soft);
  --chart-grid: #e2e8f0;
  --chart-text: #64748b;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --price-up: var(--success);
  --price-down: var(--danger);
  /* QQ 三国金额档位（浅色默认） */
  --price-tier-white: #64748b;
  --price-tier-blue: #2563eb;
  --price-tier-green: #059669;
  --price-tier-orange: #ea580c;
  --price-tier-purple: #9333ea;
  --price-tier-red: #dc2626;
  --price-tier-yellow: #b45309;
  --price-tier-cyan: #0e7490;
  --chart-stall: #2563eb;
  --chart-shop: #d97706;
  --chart-event: #7c3aed;
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-border: #e2e8f0;
  /* 兼容旧变量名 */
  --app-bg: var(--bg-page);
  --app-card: var(--bg-card);
  --app-border: var(--border-color);
  --app-text: var(--text-primary);
  --app-muted: var(--text-secondary);
  --app-primary: var(--accent);
  --app-up: var(--price-up);
  --app-down: var(--price-down);
}

html[data-bs-theme="dark"] {
  --price-tier-white: #f1f5f9;
  --price-tier-blue: #60a5fa;
  --price-tier-green: #34d399;
  --price-tier-orange: #fb923c;
  --price-tier-purple: #c084fc;
  --price-tier-red: #f87171;
  --price-tier-yellow: #fbbf24;
  --price-tier-cyan: #22d3ee;
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-muted: #334155;
  --border-color: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --success: #34d399;
  --danger: #f87171;
  --table-header-bg: #1e293b;
  --chart-grid: #334155;
  --chart-text: #94a3b8;
  --input-bg: #1e293b;
  --input-border: #475569;
  --chart-stall: #60a5fa;
  --chart-shop: #fbbf24;
  --chart-event: #a78bfa;
  --chart-tooltip-bg: #1e293b;
  --chart-tooltip-border: #334155;
}

html[data-bs-theme="light"] {
  --bs-body-bg: var(--bg-page);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border-color);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent);
}

html[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg-page);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border-color);
  --bs-primary: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .insight-card { transition: none; }
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.card, .card-dash, .modal-content, .offcanvas, .dropdown-menu {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.card-dash {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: color-mix(in srgb, var(--accent) 85%, black);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--accent) 85%, black);
}

.form-control, .form-select {
  background-color: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--accent) 25%, transparent);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: var(--border-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--accent) 6%, var(--bg-card));
  --bs-table-striped-bg: var(--bg-muted);
}

.table thead th {
  background: var(--table-header-bg);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.app-wrapper { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-button);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.brand-title { font-weight: 600; font-size: .875rem; line-height: 1.2; }
.brand-sub { font-size: .75rem; color: var(--text-secondary); }

.sidebar-nav { padding: .75rem; }
.sidebar-group-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  padding: .75rem .75rem .25rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .75rem;
  border-radius: var(--radius-button);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  margin-bottom: .125rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar-link.active { background: var(--sidebar-active-bg); color: var(--accent); font-weight: 500; }

.topbar {
  height: 56px;
  background: color-mix(in srgb, var(--bg-card) 95%, transparent);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 100;
}

.stat-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: .8125rem; color: var(--text-secondary); }

.price-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }

.price-tier-white,
.game-price.price-tier-white { color: var(--price-tier-white); }
.price-tier-blue,
.game-price.price-tier-blue { color: var(--price-tier-blue); }
.price-tier-green,
.game-price.price-tier-green { color: var(--price-tier-green); }
.price-tier-orange,
.game-price.price-tier-orange { color: var(--price-tier-orange); }
.price-tier-purple,
.game-price.price-tier-purple { color: var(--price-tier-purple); }
.price-tier-red,
.game-price.price-tier-red { color: var(--price-tier-red); }
.price-tier-yellow,
.game-price.price-tier-yellow { color: var(--price-tier-yellow); }
.price-tier-cyan,
.game-price.price-tier-cyan { color: var(--price-tier-cyan); }

.text-muted .game-price.price-tier-white { color: var(--price-tier-white); }
.text-muted .game-price.price-tier-blue { color: var(--price-tier-blue); }
.text-muted .game-price.price-tier-green { color: var(--price-tier-green); }
.text-muted .game-price.price-tier-orange { color: var(--price-tier-orange); }
.text-muted .game-price.price-tier-purple { color: var(--price-tier-purple); }
.text-muted .game-price.price-tier-red { color: var(--price-tier-red); }
.text-muted .game-price.price-tier-yellow { color: var(--price-tier-yellow); }
.text-muted .game-price.price-tier-cyan { color: var(--price-tier-cyan); }

.item-name-copy-wrap .item-copy-btn { font-size: 0.85em; opacity: 0.65; vertical-align: middle; }
.item-name-copy-wrap .item-copy-btn:hover { opacity: 1; }
.item-name-text { font-weight: inherit; }

.copy-toast {
  position: fixed; bottom: 4.5rem; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem; border-radius: 999px; font-size: 0.8125rem;
  box-shadow: var(--shadow-card); z-index: 1080; pointer-events: none;
}
.text-up { color: var(--price-up) !important; }
.text-down { color: var(--price-down) !important; }

.mobile-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: color-mix(in srgb, var(--bg-card) 95%, transparent);
  border-top: 1px solid var(--border-color);
  display: flex; z-index: 100;
  backdrop-filter: blur(8px);
}
.mobile-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: .5rem 0; font-size: .625rem; color: var(--text-secondary); text-decoration: none;
}
.mobile-tab i { font-size: 1.125rem; }
.mobile-tab.active { color: var(--accent); }

.chart-box { width: 100%; max-width: 100%; overflow: hidden; min-height: 320px; }

.quick-item-btn { cursor: pointer; }
.quick-item-btn.active {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

.market-toggle .btn-check:checked + .btn { font-weight: 600; }

.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--accent);
  position: absolute; left: -5px; top: 1rem;
}

.table > :not(caption) > * > * { background: transparent; }

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-page);
}

.insight-card { transition: border-color .15s, background .15s; }
.insight-card:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: 1.5rem;
}
.page-actions { flex-shrink: 0; }
.page-actions .btn {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .content-area { padding-bottom: 4.5rem !important; }
}

.workbench-table th, .workbench-table td { white-space: nowrap; font-size: .875rem; }
.record-row.record-saved { border-left: 3px solid var(--success); }
.record-row .save-status { min-width: 3rem; }
.price-preview { min-height: 1.25rem; }

body.density-compact .table > :not(caption) > * > * { padding: 0.25rem 0.4rem; font-size: 0.8125rem; }
body.density-compact .card-dash { padding: 0.65rem !important; }
body.density-compact .content-area { --bs-body-line-height: 1.35; }
body.density-compact .sidebar-link { padding: 0.35rem 0.75rem; font-size: 0.875rem; }
body.density-compact .h6, body.density-compact h6 { font-size: 0.9rem; }
body.density-compact .stat-value { font-size: 1.45rem; }
body.density-compact .topbar { height: 48px; }

/* 设置页模板预览 */
.theme-preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.theme-preset-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg-card);
}
.theme-preset-card:hover { border-color: var(--accent); }
.theme-preset-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-preset-card .theme-preview { height: 88px; border-radius: 0.375rem; overflow: hidden; margin-bottom: 0.5rem; border: 1px solid var(--border-color); }
.theme-preset-label { font-size: 0.8125rem; font-weight: 600; text-align: center; }

@media print {
  .sidebar, .mobile-bottom-nav, .no-print, .breadcrumb, .btn, form, .offcanvas { display: none !important; }
  .app-wrapper { display: block !important; }
  .content-area { padding: 0 !important; margin: 0 !important; }
  .card-dash { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
  .chart-box { min-height: 240px; }
}
