﻿/* ============================================================
   POPZAR Wingo Crossbet Dashboard — Design System
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --bg:          #070d1a;
  --surface:     #0d1526;
  --card:        #111d33;
  --card-hov:    #162240;
  --border:      #1e3050;
  --border-lo:   #152038;

  --accent:      #facc15;
  --accent-bg:   rgba(250, 204, 21, 0.08);
  --accent-hov:  rgba(250, 204, 21, 0.15);
  --accent-dim:  rgba(250, 204, 21, 0.3);

  --text:        #dde8f5;
  --text-muted:  #5c7a9e;
  --text-dim:    #2d4a6a;

  --green:       #22c55e;
  --green-bg:    rgba(34, 197, 94, 0.10);
  --green-bd:    rgba(34, 197, 94, 0.25);

  --red:         #f43f5e;
  --red-bg:      rgba(244, 63, 94, 0.10);
  --red-bd:      rgba(244, 63, 94, 0.25);

  --orange:      #fb923c;
  --orange-bg:   rgba(251, 146, 60, 0.10);
  --orange-bd:   rgba(251, 146, 60, 0.25);

  --blue:        #38bdf8;
  --blue-bg:     rgba(56, 189, 248, 0.10);
  --blue-bd:     rgba(56, 189, 248, 0.25);

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   18px;
  --shadow:      0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg:   0 16px 56px rgba(0, 0, 0, 0.6);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── App Shell ── */
.app {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 18px 60px;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--border-lo);
  margin-bottom: 22px;
  gap: 14px;
  flex-wrap: wrap;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius);
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 20px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1.5px;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 3px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Connection status pill */
.conn-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
}

.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.conn-dot.connected  { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.conn-dot.connecting { background: var(--accent);  animation: pulse-dot 1.1s ease-in-out infinite; }
.conn-dot.error      { background: var(--red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-bg) 0%, transparent 60%);
  pointer-events: none;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.stat-value.accent { color: var(--accent); }
.stat-value.sm     { font-size: 12px; font-weight: 700; color: var(--text-muted); line-height: 1.4; }

/* ============================================================
   MAIN GRID LAYOUT
   ============================================================ */
.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.3px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: 0;
  transition: filter 0.15s, transform 0.1s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover  { filter: brightness(1.14); }
.btn:active { filter: brightness(0.9); transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #0d1117;
  font-size: 14px;
  padding: 10px 22px;
  font-weight: 900;
}

.btn-ghost {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-bd);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ============================================================
   DROPZONE
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.dropzone-icon {
  font-size: 34px;
  margin-bottom: 10px;
  line-height: 1;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
}

.dropzone-sub {
  font-size: 12px;
  color: var(--text-muted);
}

#fileInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
.field       { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); }

.field-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
}

.upload-meta { margin-top: 12px; min-height: 20px; }

.upload-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.upload-status.ok  { color: var(--green); }
.upload-status.err { color: var(--red); }

.field-gap { margin-top: 12px; }

/* Range slider */
.range-row { display: flex; align-items: center; gap: 10px; }
.range-input { flex: 1; accent-color: var(--accent); cursor: pointer; }
.range-val {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

/* ============================================================
   STEP LABEL
   ============================================================ */
.step-label {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 6px;
}

/* ============================================================
   MODE GRID
   ============================================================ */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 0;
}

.mode-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}

.mode-btn:hover  { border-color: var(--accent-dim); background: var(--accent-bg); }
.mode-btn.active { border-color: var(--accent);     background: var(--accent-bg); }

.mode-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.mode-btn.active .mode-num { background: var(--accent); color: #0d1117; }

.mode-info  { flex: 1; }
.mode-name  { font-size: 13px; font-weight: 800; line-height: 1.2; }
.mode-desc  { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.35; }

.filter-date-block { grid-column: 1 / -1; }

.date-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.date-preset.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.date-inputs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-inputs-row .field-input { flex: 1; }

.date-sep { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

/* ============================================================
   FILTER GRID
   ============================================================ */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   CHIPS / BADGES
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.chip-accent  { background: var(--accent-bg);  color: var(--accent); border: 1px solid var(--accent-dim); }
.chip-muted   { background: var(--surface);     color: var(--text-muted); border: 1px solid var(--border); }
.chip-green   { background: var(--green-bg);    color: var(--green);  border: 1px solid var(--green-bd); }
.chip-red     { background: var(--red-bg);      color: var(--red);    border: 1px solid var(--red-bd); }
.chip-orange  { background: var(--orange-bg);   color: var(--orange); border: 1px solid var(--orange-bd); }
.chip-blue    { background: var(--blue-bg);     color: var(--blue);   border: 1px solid var(--blue-bd); }

/* ============================================================
   UPLOAD HISTORY
   ============================================================ */
.history-list { overflow-y: auto; max-height: 260px; }

.history-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-lo);
  align-items: center;
  font-size: 12px;
}

.history-item:last-child { border-bottom: none; }

.history-batch { font-weight: 700; word-break: break-all; line-height: 1.3; }
.history-date  { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.history-ins   { font-weight: 800; color: var(--green); text-align: right; }
.history-skip  { color: var(--text-muted); font-size: 11px; text-align: right; }

/* ============================================================
   RESULTS
   ============================================================ */
.result-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.search-input { flex: 1; min-width: 180px; max-width: 320px; }

.pagination-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-lo);
}

.result-scroll { max-height: 850px; overflow: auto; padding-right: 4px; }

.empty {
  text-align: center;
  padding: 54px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  line-height: 2;
  font-size: 14px;
}

.empty-sm {
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ============================================================
   PAIR CARDS
   ============================================================ */
.pair-list { display: flex; flex-direction: column; gap: 10px; }

.pair-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.pair-card:hover { border-color: var(--accent-dim); }
.pair-card.risk-hi { border-left-color: var(--red); }
.pair-card.risk-md { border-left-color: var(--orange); }
.pair-card.risk-lo { border-left-color: var(--green); }

.pair-head {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.pair-ids {
  font-size: 15px;
  font-weight: 900;
  word-break: break-all;
  line-height: 1.4;
}

.pair-ids .id     { color: var(--accent); }
.pair-ids .sep    { color: var(--text-muted); margin: 0 6px; font-weight: 400; font-size: 13px; }
.pair-head-meta   { color: var(--text-muted); font-size: 12px; margin-top: 5px; }

.pair-head-right  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }

.pair-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border-lo);
}

.pair-metric {
  padding: 10px 14px;
  border-right: 1px solid var(--border-lo);
}

.pair-metric:last-child { border-right: none; }
.pair-metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.pair-metric-value { font-size: 17px; font-weight: 900; margin-top: 4px; }

.pair-detail-row {
  display: none;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border-lo);
}

.pair-detail-row.open { display: block; }

.issue-list {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
  word-break: break-word;
}

/* ============================================================
   TABLE (Same-ID mode)
   ============================================================ */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-lo); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--card-hov); }
tbody td { padding: 10px 12px; vertical-align: middle; }
.td-id { font-weight: 800; }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 26, 0.92);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.loading-box {
  width: min(460px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 18px;
}

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

.loading-box h3 { font-size: 16px; margin-bottom: 6px; }
.loading-sub    { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.pct-label      { font-size: 12px; font-weight: 800; color: var(--accent); }

.bar {
  height: 5px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 6px;
}

.bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fde68a);
  transition: width 0.2s;
  border-radius: 999px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  max-width: 380px;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in  { from { transform: translateX(110%); opacity: 0; } }
@keyframes toast-out { to   { transform: translateX(110%); opacity: 0; } }
.toast.removing { animation: toast-out 0.3s ease forwards; }

.toast-icon  { font-size: 16px; flex-shrink: 0; }
.toast-text  { flex: 1; }

.toast-success { background: var(--green-bg);  border: 1px solid var(--green-bd);  color: #86efac; }
.toast-error   { background: var(--red-bg);    border: 1px solid var(--red-bd);    color: #fca5a5; }
.toast-info    { background: var(--blue-bg);   border: 1px solid var(--blue-bd);   color: #93c5fd; }
.toast-warn    { background: var(--orange-bg); border: 1px solid var(--orange-bd); color: #fdba74; }

/* ============================================================
   MISC
   ============================================================ */
.muted { color: var(--text-muted); }
.divider { border: none; border-top: 1px solid var(--border-lo); margin: 14px 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .pair-metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .ctrl-row, .ctrl-row-3 { grid-template-columns: 1fr; }
  .mode-tabs  { grid-template-columns: 1fr; }
  .app        { padding: 0 12px 40px; }
  .pair-metrics { grid-template-columns: 1fr 1fr; }
}
