/* ============================================
   Alpha战队 - Dark Trading Terminal Theme
   ============================================ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --warning: #d29922;
  --danger: #f85149;
  --success: #3fb950;
  --purple: #bc8cff;
  --orange: #db6d28;
  --red-up: #f85149;
  --green-down: #3fb950;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --nav-height: 56px;
  --font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

/* ============================================
   Navigation
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.nav-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 32px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  font-weight: 800;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
  flex: 1;
}

.nav-links a {
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.2s;
  display: block;
}

.nav-links a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-links a.active {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  background: none;
  border: none;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 24px) 24px 48px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.meta-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.meta-bar .meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-bar .meta-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================
   Grid System
   ============================================ */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--bg-hover);
}

.card-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title .badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}

/* ============================================
   Stat Cards (KPI)
   ============================================ */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

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

.stat-card.red::before { background: var(--red-up); }
.stat-card.green::before { background: var(--green-down); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.purple::before { background: var(--purple); }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  font-family: var(--mono-family);
  letter-spacing: -0.5px;
}

.stat-value.up { color: var(--red-up); }
.stat-value.down { color: var(--green-down); }

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-sub .up { color: var(--red-up); }
.stat-sub .down { color: var(--green-down); }

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
}

thead th:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

thead th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.3;
  font-size: 0.7rem;
}

thead th.sorted-asc .sort-arrow,
thead th.sorted-desc .sort-arrow {
  opacity: 1;
  color: var(--accent);
}

thead th.sorted-asc .sort-arrow::after { content: " \25B2"; }
thead th.sorted-desc .sort-arrow::after { content: " \25BC"; }
thead th .sort-arrow::after { content: " \25C6"; }

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Table color helpers */
td.up, span.up { color: var(--red-up); }
td.down, span.down { color: var(--green-down); }
td.muted, span.muted { color: var(--text-muted); }

.text-mono {
  font-family: var(--mono-family);
}

/* ============================================
   Progress Bars
   ============================================ */
.progress-container {
  margin-bottom: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.progress-label .label-text {
  color: var(--text-primary);
  font-weight: 500;
}

.progress-label .label-value {
  font-family: var(--mono-family);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
  background: var(--accent);
}

.progress-fill.red { background: var(--red-up); }
.progress-fill.green { background: var(--green-down); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.purple { background: var(--purple); }

.progress-target-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--warning);
  z-index: 1;
}

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-a { background: rgba(248,81,73,0.15); color: var(--red-up); border: 1px solid rgba(248,81,73,0.3); }
.badge-b { background: rgba(210,153,34,0.15); color: var(--warning); border: 1px solid rgba(210,153,34,0.3); }
.badge-c { background: rgba(63,185,80,0.15); color: var(--green-down); border: 1px solid rgba(63,185,80,0.3); }
.badge-default { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-color); }

.badge-buy {
  background: rgba(248,81,73,0.15);
  color: var(--red-up);
  border: 1px solid rgba(248,81,73,0.3);
}

.badge-sell {
  background: rgba(63,185,80,0.15);
  color: var(--green-down);
  border: 1px solid rgba(63,185,80,0.3);
}

.badge-hit {
  background: rgba(248,81,73,0.15);
  color: var(--red-up);
  border: 1px solid rgba(248,81,73,0.3);
}

.badge-miss {
  background: rgba(63,185,80,0.15);
  color: var(--green-down);
  border: 1px solid rgba(63,185,80,0.3);
}

.badge-pending {
  background: rgba(210,153,34,0.15);
  color: var(--warning);
  border: 1px solid rgba(210,153,34,0.3);
}

.badge-eliminated {
  background: rgba(110,118,129,0.15);
  color: var(--text-muted);
  border: 1px solid rgba(110,118,129,0.3);
}

/* ============================================
   Rating Pills
   ============================================ */
.rating-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.rating-A { background: rgba(248,81,73,0.2); color: var(--red-up); }
.rating-A\+ { background: rgba(248,81,73,0.25); color: var(--red-up); }
.rating-A- { background: rgba(248,81,73,0.15); color: var(--red-up); }
.rating-B { background: rgba(210,153,34,0.2); color: var(--warning); }
.rating-B\+ { background: rgba(210,153,34,0.15); color: var(--warning); }
.rating-C { background: rgba(63,185,80,0.15); color: var(--green-down); }
.rating-default { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ============================================
   Charts
   ============================================ */
.chart-container {
  position: relative;
  width: 100%;
  height: 240px;
}

.chart-container-lg {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-container-sm {
  position: relative;
  width: 100%;
  height: 180px;
}

/* ============================================
   Loading & Error States
   ============================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

.error-box {
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.3);
  color: var(--danger);
  padding: 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  text-align: center;
}

/* ============================================
   Search & Filter
   ============================================ */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input,
.filter-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-family);
  transition: border-color 0.2s;
}

.search-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.filter-select {
  cursor: pointer;
}

/* ============================================
   Section Headers
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .icon {
  font-size: 1.1rem;
}

/* ============================================
   Gauge (Hit Rate)
   ============================================ */
.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gauge-value {
  font-size: 3rem;
  font-weight: 800;
  font-family: var(--mono-family);
  line-height: 1;
}

.gauge-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 8px;
}

.gauge-ring {
  width: 160px;
  height: 160px;
  position: relative;
  margin-bottom: 12px;
}

/* ============================================
   Misc
   ============================================ */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 20px 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.positive { color: var(--red-up); }
.negative { color: var(--green-down); }
.neutral { color: var(--text-secondary); }

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.link-button:hover {
  background: var(--bg-tertiary);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  white-space: nowrap;
}

.note-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: 8px;
    gap: 0;
    transform: translateY(-200%);
    transition: transform 0.3s;
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    transform: translateY(0);
  }

  .nav-links a {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
  }

  .container {
    padding: calc(var(--nav-height) + 16px) 12px 32px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5 {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  table {
    font-size: 0.8rem;
  }

  thead th,
  tbody td {
    padding: 8px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .nav-logo {
    font-size: 1rem;
    margin-right: 0;
  }

  .card {
    padding: 16px;
  }

  .stat-card {
    padding: 16px;
  }

  .gauge-value {
    font-size: 2.2rem;
  }
}
