/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-hover: #1a1a1a;
  --border: #222222;
  --text: #e8e8e8;
  --text-muted: #666666;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --purple: #a855f7;
  --blue: #3b82f6;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);

  --nav-height: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-brand:hover { color: var(--text); }
.nav-brand-icon { font-size: 1.2rem; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--text); background: var(--bg-hover); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.nav-logout:hover { color: var(--text); border-color: #444; background: var(--bg-hover); }

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ─── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: #444; color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Stats Bar ──────────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.stat-item {
  flex: 1;
  background: var(--bg-card);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-small { font-size: 0.9rem; }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Data Table ─────────────────────────────────────────────────────────────── */
.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--bg-card);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.875rem;
}

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

.table-row {
  background: var(--bg-card);
  transition: background 0.1s;
}
.table-row:hover { background: var(--bg-hover); }

.row-opportunity { border-left: 3px solid var(--green); }
.row-watch { border-left: 3px solid var(--yellow); }
.row-avoid { border-left: 3px solid var(--red); }

/* ─── Card Cells ─────────────────────────────────────────────────────────────── */
.card-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-thumb {
  width: 40px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.card-name {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.set-name {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-gray { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Grade Cells ────────────────────────────────────────────────────────────── */
.grade-cell { display: flex; flex-direction: column; gap: 2px; }
.grade-label { font-size: 0.8rem; }
.grade-rate { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Event Badges ───────────────────────────────────────────────────────────── */
.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.event-type-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.event-out-of-print  { background: rgba(239,68,68,0.15);   color: var(--red);    border: 1px solid rgba(239,68,68,0.3); }
.event-reprint       { background: rgba(59,130,246,0.15);  color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }
.event-supply-shortage { background: rgba(249,115,22,0.15); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }
.event-price-catalyst { background: rgba(34,197,94,0.15);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.event-set-rotation  { background: rgba(168,85,247,0.15);  color: var(--purple); border: 1px solid rgba(168,85,247,0.3); }

/* ─── Macro Events Page ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all 0.15s;
}
.filter-btn:hover { border-color: #444; color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.15s;
}
.event-card:hover { border-color: #333; }

.event-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.event-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.event-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.meta-icon { font-size: 0.85rem; }
.meta-link { color: var(--accent); }
.meta-link:hover { color: var(--accent-hover); }

.event-direction {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.dir-up { background: rgba(34,197,94,0.12); color: var(--green); }
.dir-down { background: rgba(239,68,68,0.12); color: var(--red); }
.dir-neutral { background: var(--bg-hover); color: var(--text-muted); }

.event-confidence { display: flex; flex-direction: column; gap: 6px; }
.confidence-header { display: flex; justify-content: space-between; align-items: center; }
.confidence-label { font-size: 0.75rem; color: var(--text-muted); }
.confidence-value { font-size: 0.75rem; font-weight: 600; color: var(--text); }

.confidence-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.confidence-fill[data-confidence] {
  /* Color by confidence level */
}

.event-footer {
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.event-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Calendar / Timeline ────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 0;
  align-items: flex-start;
}

.timeline-past { opacity: 0.45; }

.timeline-date-col {
  width: 80px;
  flex-shrink: 0;
  padding: 16px 12px 16px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.days-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.days-past { background: var(--bg-hover); color: var(--text-muted); }
.days-today { background: rgba(234,179,8,0.15); color: var(--yellow); border: 1px solid rgba(234,179,8,0.3); }
.days-soon { background: rgba(249,115,22,0.15); color: var(--orange); }
.days-future { background: rgba(99,102,241,0.1); color: var(--accent); }

.event-date-str {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

.timeline-connector {
  width: 32px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 22px;
  flex-shrink: 0;
}

.timeline-dot.impact-bullish { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.timeline-dot.impact-bearish { background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.timeline-dot.impact-neutral { background: var(--text-muted); }

.timeline-line {
  flex: 1;
  width: 1px;
  background: var(--border);
  min-height: 24px;
}

.timeline-item:last-child .timeline-line { display: none; }

.timeline-content {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 10px 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.impact-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.impact-bullish { background: rgba(34,197,94,0.15); color: var(--green); }
.impact-bearish { background: rgba(239,68,68,0.15); color: var(--red); }
.impact-neutral { background: var(--bg-hover); color: var(--text-muted); }

.timeline-type { font-size: 0.78rem; color: var(--text-muted); }
.timeline-sets { font-size: 0.8rem; color: var(--text-muted); }
.timeline-notes { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.timeline-link { font-size: 0.78rem; color: var(--accent); }

/* ─── Card Detail ────────────────────────────────────────────────────────────── */
.card-detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .card-detail-layout { grid-template-columns: 1fr; }
}

.card-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--nav-height) + 24px);
}

.card-image-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  justify-content: center;
}

.card-detail-img {
  width: 100%;
  max-width: 220px;
  border-radius: 8px;
}

.card-image-placeholder {
  width: 100%;
  aspect-ratio: 2.5/3.5;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-detail-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-detail-meta { display: flex; flex-direction: column; gap: 6px; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.meta-key { color: var(--text-muted); }
.meta-val { color: var(--text); font-weight: 500; }

.card-detail-main { display: flex; flex-direction: column; gap: 16px; }

/* ─── Panel ──────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Grade Panel ────────────────────────────────────────────────────────────── */
.grade-panel { display: flex; flex-direction: column; gap: 10px; }
.grade-big { font-size: 1.1rem; font-weight: 600; }
.grade-rate-row { display: flex; justify-content: space-between; font-size: 0.82rem; }
.grade-rate-val { font-weight: 600; color: var(--text); }
.grade-notes { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.grade-source { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Price Chart ────────────────────────────────────────────────────────────── */
.chart-wrapper {
  position: relative;
  height: 280px;
}

/* ─── Events List (Card Detail) ──────────────────────────────────────────────── */
.events-list { display: flex; flex-direction: column; gap: 12px; }

.event-inline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.event-inline-content { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.event-inline-title { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.event-inline-meta { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-muted); flex-wrap: wrap; }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.08) 0%, transparent 60%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-input::placeholder { color: var(--text-muted); }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
}

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon { font-size: 3rem; }

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── Search ─────────────────────────────────────────────────────────────────── */
.search-form { margin-bottom: 24px; }

.search-bar {
  display: flex;
  gap: 8px;
}

.search-input { flex: 1; }

.results-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.card-grid-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
}

.card-grid-item:hover {
  border-color: #444;
  transform: translateY(-2px);
}

.card-grid-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: contain;
  background: var(--bg);
  padding: 8px;
}

.card-grid-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-grid-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-grid-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.card-grid-set {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-grid-rarity {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-orange { color: var(--orange); }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
