/* ============================================================
   AI-Glow Intelligence — 大乐透 AI 分析系统主题
   Design System: Deep dark + Aurora purple + Neon green
   ============================================================ */

/* ── CSS Variables ── */
:root {
  --bg-primary: #0a0a12;
  --bg-secondary: #0f0f1a;
  --bg-card: #12121e;
  --bg-card-hover: #16162a;
  --bg-input: #0e0e1a;
  --bg-nav: rgba(10, 10, 18, 0.85);

  --purple: #A855F7;
  --purple-dim: rgba(168, 85, 247, 0.15);
  --purple-glow: rgba(168, 85, 247, 0.4);
  --blue: #3B82F6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --blue-glow: rgba(59, 130, 246, 0.35);
  --green: #00FFC2;
  --green-dim: rgba(0, 255, 194, 0.12);
  --green-glow: rgba(0, 255, 194, 0.3);
  --gold: #FFD700;
  --gold-dim: rgba(255, 215, 0, 0.12);
  --red: #e74c3c;
  --red-bright: #FF4757;
  --orange: #FF6B35;

  --text: #e0e0e8;
  --text-secondary: #9090a8;
  --text-dim: #606078;
  --text-bright: #ffffff;

  --border: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(168, 85, 247, 0.2);
  --border-input: rgba(255, 255, 255, 0.1);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --radius-pill: 99px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(168, 85, 247, 0.15);
  --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.4);

  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --nav-height: 64px;
  --bottom-nav-height: 64px;
  --container-max: 1200px;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple); text-decoration: none; transition: color var(--transition); }
a:hover { color: #c084fc; }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; }
code { font-family: var(--font-mono); font-size: 0.85em; background: rgba(168, 85, 247, 0.1); padding: 0.15em 0.4em; border-radius: 4px; color: #c084fc; }
pre { overflow-x: auto; }
::selection { background: var(--purple); color: #fff; }

/* ── Layout ── */
.main-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: calc(var(--nav-height) + 1.5rem) 1.25rem 6rem;
  min-height: 100vh;
}

/* ── Background Mesh ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 10%, rgba(168, 85, 247, 0.08), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 60%, rgba(59, 130, 246, 0.06), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 90%, rgba(0, 255, 194, 0.04), transparent 50%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

/* ══════════════════════════════════════
   NAVIGATION
   ══════════════════════════════════════ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-nav);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: background var(--transition), box-shadow var(--transition);
}
.navbar.scrolled {
  background: rgba(10, 10, 18, 0.95);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}
.nav-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px var(--purple-glow));
}
.brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 40%, var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

/* Desktop nav links */
.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  align-items: center;
}
.nav-links li a {
  display: block;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-links li a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.nav-links li a.active {
  color: var(--green);
  background: var(--green-dim);
  box-shadow: 0 0 12px var(--green-glow);
}

/* Hamburger */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s;
}
.menu-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile menu overlay */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 18, 0.97);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  flex-direction: column;
  padding: 1.5rem 1.25rem;
  gap: 0.4rem;
  z-index: 999;
  overflow-y: auto;
  transform: translateY(-10px);
  opacity: 0;
  transition: all 0.3s;
}
.mobile-menu.active {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
.mobile-menu a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.mobile-menu a:hover,
.mobile-menu a.active {
  color: var(--green);
  background: var(--green-dim);
}

/* ── User Dropdown ── */
.nav-user-dropdown {
  position: relative;
}
.nav-user-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.nav-user-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}
.nav-user-btn svg {
  transition: transform 0.2s;
}
.nav-user-dropdown.open .nav-user-btn svg {
  transform: rotate(180deg);
}
.nav-user-icon {
  font-size: 1rem;
}
.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 0.4rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  z-index: 1100;
  animation: dropdownIn 0.2s ease-out;
}
.nav-user-dropdown.open .user-dropdown-menu {
  display: block;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}
.user-dropdown-menu a:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.06);
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

/* ── Bottom Mobile Nav ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: rgba(10, 10, 18, 0.95);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 998;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  min-width: 52px;
}
.bottom-nav a .nav-icon { font-size: 1.2rem; }
.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--green);
  background: var(--green-dim);
}

/* ══════════════════════════════════════
   CARDS
   ══════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-hover);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-header h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: linear-gradient(180deg, var(--purple), var(--blue));
  border-radius: 2px;
}
.card-glow {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.06), rgba(59, 130, 246, 0.04));
}

/* ══════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════ */
.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 40%, var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}
.page-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ══════════════════════════════════════
   STATS GRID / KPI CARDS
   ══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stats-grid-compact { gap: 0.75rem; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.stat-kpi {
  text-align: center;
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-bright);
  line-height: 1.2;
}
.stat-extra {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

/* Color variants */
.stat-value a, .number-link {
  color: var(--green);
  text-decoration: none;
  transition: all var(--transition);
}
.stat-value a:hover, .number-link:hover {
  color: #00ffda;
  text-shadow: 0 0 10px var(--green-glow);
}

/* ══════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-bright);
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple), #7c3aed);
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px var(--purple-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #c084fc, var(--purple));
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.5);
  color: #fff;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}
.btn-link {
  background: none;
  border: none;
  color: var(--purple);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0;
  transition: color var(--transition);
  text-decoration: none;
  font-family: inherit;
}
.btn-link:hover { color: #c084fc; text-shadow: 0 0 8px var(--purple-glow); }
.btn-success { background: var(--green-dim); color: var(--green); border-color: rgba(0, 255, 194, 0.2); }
.btn-success:hover { background: rgba(0, 255, 194, 0.2); color: #00ffda; }
.btn-danger { background: rgba(231, 76, 60, 0.1); color: #FF6B6B; border-color: rgba(231, 76, 60, 0.2); }
.btn-danger:hover { background: rgba(231, 76, 60, 0.2); }

.btn:disabled, .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

/* ══════════════════════════════════════
   BALL NUMBERS
   ══════════════════════════════════════ */
.balls, .balls-row, .latest-balls, .detail-balls .balls-container,
.ai-history-balls, .draw-balls .balls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.latest-balls { gap: 0.6rem; margin: 1rem 0; }

.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: 50%;
  line-height: 1;
  flex-shrink: 0;
}
.ball-red {
  width: 38px; height: 38px;
  font-size: 0.82rem;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  box-shadow: 0 0 12px rgba(231, 76, 60, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}
.ball-blue {
  width: 38px; height: 38px;
  font-size: 0.82rem;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}
.ball-large {
  width: 46px; height: 46px;
  font-size: 0.95rem;
}
.ball-small {
  width: 30px; height: 30px;
  font-size: 0.7rem;
}

/* Number ball in table/grid */
.ball-number {
  width: 36px; height: 36px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 700;
}
.ball-number.red {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}
.ball-number.blue {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* ══════════════════════════════════════
   TABLES
   ══════════════════════════════════════ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--purple-dim) transparent;
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--purple-dim); border-radius: 3px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table thead th {
  padding: 0.75rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover {
  background: rgba(168, 85, 247, 0.04);
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ══════════════════════════════════════
   BADGES & STATUS
   ══════════════════════════════════════ */
.badge, .issue-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--purple-dim);
  color: var(--purple);
  white-space: nowrap;
}
.badge-algo {
  background: var(--blue-dim);
  color: var(--blue);
}
.badge-green, .status-success {
  background: var(--green-dim);
  color: var(--green);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}
.status-predicted {
  background: var(--gold-dim);
  color: var(--gold);
}
.status-opened, .status-evaluated {
  background: var(--blue-dim);
  color: var(--blue);
}
.status-reviewed {
  background: var(--green-dim);
  color: var(--green);
}
.rec-strategy {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--purple-dim);
  color: #c084fc;
}

/* ══════════════════════════════════════
   FORMS
   ══════════════════════════════════════ */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-dim);
}
input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}
input[type="checkbox"] {
  accent-color: var(--purple);
  width: 16px; height: 16px;
}
textarea {
  min-height: 80px;
  resize: vertical;
}

/* ══════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
  flex-wrap: wrap;
}
.page-info {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════
   TOAST
   ══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  z-index: 9999;
  animation: toastIn 0.3s ease-out;
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════
   ANALYSIS SCOPE / WINDOW SWITCHER
   ══════════════════════════════════════ */
.analysis-scope {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.6rem 1rem;
  background: rgba(168, 85, 247, 0.05);
  border: 1px solid rgba(168, 85, 247, 0.1);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}
.analysis-window-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.analysis-window-switcher .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
}
.analysis-window-switcher .btn.active,
.analysis-window-switcher .btn-primary {
  background: linear-gradient(135deg, var(--purple), #7c3aed);
  border: none;
  color: #fff;
}

/* ══════════════════════════════════════
   FETCH STATUS BAR
   ══════════════════════════════════════ */
.fetch-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
}
.last-update { color: var(--green); font-weight: 600; }
.stat-desc { color: var(--text-dim); }

/* ══════════════════════════════════════
   DRAW INFO / DETAIL
   ══════════════════════════════════════ */
.draw-info {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.draw-card {
  padding: 1rem;
}
.draw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.draw-issue {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-bright);
}
.draw-date {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.draw-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.sales { font-size: 0.82rem; color: var(--text-dim); }

/* Draw detail page */
.draw-detail-modern .detail-header {
  margin-bottom: 1.25rem;
}
.draw-detail-modern .detail-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-bright);
}
.detail-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.detail-balls {
  padding: 1.5rem 0;
}

/* Detail insights (metric bars) */
.detail-insights { display: flex; flex-direction: column; gap: 1rem; }
.detail-insight-item {}
.detail-insight-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}
.detail-insight-top span { color: var(--text-secondary); }
.detail-insight-top strong { color: var(--text-bright); font-family: var(--font-mono); }

.metric-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.metric-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  border-radius: 3px;
  transition: width 0.6s ease-out;
}
.metric-bar-warning span { background: linear-gradient(90deg, var(--gold), var(--orange)); }
.metric-bar-blue span { background: linear-gradient(90deg, var(--blue), #06b6d4); }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ══════════════════════════════════════
   FREQUENCY / MISSING TABLES
   ══════════════════════════════════════ */
.freq-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  min-width: 60px;
  overflow: hidden;
}
.freq-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
}
.freq-bar .bar-red { background: linear-gradient(90deg, var(--red), var(--orange)); }
.freq-bar .bar-blue { background: linear-gradient(90deg, var(--blue), #06b6d4); }
.freq-bar .bar-green { background: linear-gradient(90deg, var(--green), #34d399); }
.freq-bar .bar-gold { background: linear-gradient(90deg, var(--gold), var(--orange)); }
.freq-bar .bar-purple { background: linear-gradient(90deg, var(--purple), #c084fc); }

.sort-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.sort-options .btn.active {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.3);
}

/* ══════════════════════════════════════
   AI RECOMMEND
   ══════════════════════════════════════ */
.ai-hero-card {
  position: relative;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.06));
  border: 1px solid rgba(168, 85, 247, 0.2);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.ai-hero-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 150px; height: 150px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.2), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.ai-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.ai-issue {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.ai-confidence {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.75rem;
}
.ai-confidence strong { color: var(--green); }

/* Chat bubble for agent debate */
.agent-chat { margin-bottom: 1.25rem; }
.agent-msg {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}
.agent-msg.conservative { border-left-color: var(--blue); background: rgba(59, 130, 246, 0.04); }
.agent-msg.aggressive { border-left-color: var(--orange); background: rgba(255, 107, 53, 0.04); }
.agent-msg.judge { border-left-color: var(--purple); background: rgba(168, 85, 247, 0.04); }
.agent-role {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.agent-msg.conservative .agent-role { color: var(--blue); }
.agent-msg.aggressive .agent-role { color: var(--orange); }
.agent-msg.judge .agent-role { color: var(--purple); }
.agent-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Recommendation result */
.rec-reason {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.75rem 0;
  line-height: 1.6;
}
.ai-basis-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ai-basis-list li {
  position: relative;
  padding: 0.35rem 0 0.35rem 1.2rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.ai-basis-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 6px var(--purple-glow);
}
.ai-summary {
  padding: 1rem;
  background: rgba(168, 85, 247, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 85, 247, 0.1);
}
.ai-summary h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 0.5rem;
}
.ai-summary p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* AI History */
.ai-history-card { padding: 1.25rem; }
.ai-history-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.ai-history-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 50px;
}

/* ══════════════════════════════════════
   WORKBENCH / LIFECYCLE
   ══════════════════════════════════════ */
.panel-notice {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid;
}
.panel-notice.success {
  background: var(--green-dim);
  border-color: rgba(0, 255, 194, 0.2);
  color: var(--green);
}
.panel-notice.error {
  background: rgba(231, 76, 60, 0.1);
  border-color: rgba(231, 76, 60, 0.2);
  color: #FF6B6B;
}

.snapshot-section {
  margin-bottom: 1.5rem;
}
.snapshot-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Timeline */
.lifecycle-timeline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.timeline-step {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.timeline-step.done {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(0, 255, 194, 0.2);
}
.timeline-step.current {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.3);
  box-shadow: 0 0 10px var(--purple-glow);
}
.timeline-arrow {
  color: var(--text-dim);
  font-size: 0.7rem;
}

/* ══════════════════════════════════════
   PROFIT DASHBOARD
   ══════════════════════════════════════ */
.profit-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.profit-metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  transition: all var(--transition);
}
.profit-metric:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}
.profit-metric .metric-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.profit-metric .metric-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-mono);
}
.profit-metric .metric-value.positive { color: var(--green); }
.profit-metric .metric-value.negative { color: var(--red-bright); }

/* ══════════════════════════════════════
   ERROR MESSAGE
   ══════════════════════════════════════ */
.error-message {
  background: rgba(231, 76, 60, 0.08);
  color: #FF6B6B;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid rgba(231, 76, 60, 0.2);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.error-detail {
  font-size: 0.82rem;
  margin-top: 0.5rem;
  opacity: 0.8;
}

/* ══════════════════════════════════════
   FOOTER
   ══════════════════════════════════════ */
.footer {
  padding: 2.5rem 1.25rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.footer-content p {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.footer-disclaimer {
  color: var(--gold) !important;
  font-size: 0.78rem !important;
}
.footer-copy {
  font-size: 0.72rem !important;
  color: var(--text-dim) !important;
}

/* ══════════════════════════════════════
   CHART CONTAINER
   ══════════════════════════════════════ */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  margin: 1rem 0;
}

/* ══════════════════════════════════════
   MOBILE / DESKTOP VISIBILITY
   ══════════════════════════════════════ */
.desktop-only { display: block; }
.mobile-only { display: none; }

/* ══════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  position: relative;
}
.login-page::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 30%, rgba(168, 85, 247, 0.12), transparent 60%),
    radial-gradient(ellipse 40% 40% at 30% 70%, rgba(59, 130, 246, 0.08), transparent 50%);
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}
.login-card .card {
  padding: 2.5rem;
}
.login-title {
  text-align: center;
  margin-bottom: 2rem;
}
.login-title h2 {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 40%, var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}
.login-title p {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ══════════════════════════════════════
   OVERVIEW SUMMARY BLOCKS
   ══════════════════════════════════════ */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.overview-section { margin-bottom: 1.5rem; }
.overview-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ══════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--purple-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(168, 85, 247, 0.3); }

/* ══════════════════════════════════════
   RESPONSIVE — Tablet (≤1024px)
   ══════════════════════════════════════ */
@media (max-width: 1024px) {
  .nav-links { display: none; }
  .menu-toggle { display: flex; }
  .bottom-nav { display: flex; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .main-container {
    padding-bottom: calc(var(--bottom-nav-height) + 2rem);
  }
}

/* ══════════════════════════════════════
   RESPONSIVE — Mobile (≤640px)
   ══════════════════════════════════════ */
@media (max-width: 640px) {
  :root {
    --nav-height: 56px;
  }
  .brand-text { font-size: 0.95rem; }

  .main-container {
    padding: calc(var(--nav-height) + 1rem) 0.75rem calc(var(--bottom-nav-height) + 1.5rem);
  }

  .page-header h1 { font-size: 1.25rem; }
  .page-desc { font-size: 0.82rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .stat-card { padding: 0.9rem 0.7rem; }
  .stat-value { font-size: 1.2rem; }

  .card {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
  }
  .card-header { margin-bottom: 0.75rem; }
  .card-header h3 { font-size: 0.92rem; }

  .ball-large { width: 38px; height: 38px; font-size: 0.82rem; }
  .ball-red, .ball-blue { width: 45px; height: 45px; font-size: 1.2rem; }
  .ball-small { width: 26px; height: 26px; font-size: 0.62rem; }

  .btn { padding: 0.5rem 0.85rem; font-size: 0.8rem; }

  .quick-actions { gap: 0.4rem; }
  .quick-actions .btn { padding: 0.4rem 0.7rem; font-size: 0.75rem; flex: 1; justify-content: center; min-width: 0; }

  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }

  .data-table { font-size: 0.78rem; }
  .data-table thead th { padding: 0.5rem; font-size: 0.65rem; }
  .data-table tbody td { padding: 0.5rem; }

  .chart-container { height: 220px; }

  .agent-msg { padding: 0.8rem 1rem; }
  .agent-content { font-size: 0.8rem; }

  .toast { font-size: 0.78rem; padding: 0.6rem 1.2rem; }

  .login-card .card { padding: 1.75rem; }

  .profit-hero {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .profit-metric { padding: 0.9rem 0.7rem; }
  .profit-metric .metric-value { font-size: 1.1rem; }

  .lifecycle-timeline {
    gap: 0.3rem;
  }
  .timeline-step {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }
}

/* ══════════════════════════════════════
   RESPONSIVE — Small phones (≤380px)
   ══════════════════════════════════════ */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .stat-value { font-size: 1rem; }
  .stat-label { font-size: 0.65rem; }

  .ball-large { width: 34px; height: 34px; font-size: 0.78rem; }
  .ball-red, .ball-blue { width: 40px;height: 40px;font-size: 1.2rem;}

  .page-header h1 { font-size: 1.1rem; }

  .bottom-nav a { font-size: 0.6rem; min-width: 44px; }
  .bottom-nav a .nav-icon { font-size: 1rem; }
}

/* ══════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeInUp 0.4s ease-out both; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.stat-card { animation: fadeInUp 0.3s ease-out both; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--purple-glow); }
  50% { box-shadow: 0 0 20px var(--purple-glow), 0 0 40px rgba(168, 85, 247, 0.1); }
}
.pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }

/* ── AI Pick Card (Overview) ── */
.ai-pick-card {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, var(--bg-card) 50%, rgba(59, 130, 246, 0.06) 100%);
  border-color: var(--border-glow);
}

/* ── Back to Top Button ── */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 50%;
  color: var(--purple);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), var(--shadow-glow);
  z-index: 900;
  font-family: inherit;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
  box-shadow: 0 0 20px var(--purple-glow), 0 4px 16px rgba(0, 0, 0, 0.4);
}
@media (max-width: 640px) {
  .back-to-top {
    bottom: calc(var(--bottom-nav-height) + 1rem);
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

/* Print */
@media print {
  body { background: #fff; color: #000; }
  .navbar, .bottom-nav, .mobile-menu, .menu-toggle { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .ball-red { background: #e74c3c !important; }
  .ball-blue { background: #3B82F6 !important; }
}
