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

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3248;
  --accent: #4f6ef7;
  --accent-hover: #6b85ff;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --text: #e8eaf0;
  --text2: #8b90a7;
  --text3: #5a5f7a;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --sidebar-width: 220px;
}

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

#app {
  display: flex;
  height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon { font-size: 20px; }
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }

#main-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

#main-nav ul { list-style: none; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  padding: 16px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text2);
  text-decoration: none;
  transition: all 0.15s;
  font-weight: 500;
  margin-bottom: 2px;
}

.nav-link:hover:not(.disabled) { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--border);
}

.connection-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
}

.connection-badge.disconnected { background: rgba(239,68,68,0.1); color: var(--red); }
.connection-badge.connected { background: rgba(34,197,94,0.1); color: var(--green); }
.connection-badge.connecting { background: rgba(245,158,11,0.1); color: var(--orange); }

.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ===== Main Content ===== */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px;
}

#module-container { max-width: 100%; }

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

.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* ===== Stat Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label { font-size: 12px; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--text2); margin-top: 3px; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }

/* ===== Cards ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-weight: 600; font-size: 14px; }
.card-body { padding: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.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-success { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.25); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.td-label { color: var(--text2); font-size: 11px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-blue { background: rgba(79,110,247,0.15); color: var(--accent); }
.badge-grey { background: var(--bg3); color: var(--text2); }

/* ===== Profit Bar ===== */
.profit-bar-wrap { display: flex; align-items: center; gap: 8px; }
.profit-bar-bg { flex: 1; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; min-width: 60px; }
.profit-bar-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.3s; }
.profit-bar-fill.negative { background: var(--red); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 5px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== Search & Filter Bar ===== */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px 8px 32px;
  color: var(--text);
  font-size: 13px;
  flex: 1;
  min-width: 180px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b90a7' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

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

.filter-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(79,110,247,0.1); }
.filter-btn:hover { border-color: var(--border); color: var(--text); }

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,110,247,0.05);
}

.drop-zone-icon { font-size: 36px; margin-bottom: 12px; }
.drop-zone-text { color: var(--text2); font-size: 14px; margin-bottom: 6px; }
.drop-zone-sub { color: var(--text3); font-size: 12px; }

/* ===== Confidence Indicator ===== */
.confidence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.confidence-high { color: var(--green); }
.confidence-medium { color: var(--orange); }
.confidence-low { color: var(--red); }

/* ===== Match Card ===== */
.match-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.match-card.high { border-left: 3px solid var(--green); }
.match-card.medium { border-left: 3px solid var(--orange); }
.match-card.low { border-left: 3px solid var(--red); }

.match-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.match-arrow { color: var(--text3); font-size: 16px; }

/* ===== Progress ===== */
.progress-wrap { background: var(--bg3); border-radius: 6px; overflow: hidden; height: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.4s; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; color: var(--text2); }

/* ===== Modal ===== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

#modal-overlay.hidden { display: none; }

#modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

#modal-title { font-size: 16px; font-weight: 600; }
#modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; line-height: 1; }
#modal-close:hover { color: var(--text); }
#modal-body { padding: 20px; }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Chart ===== */
.chart-wrap { height: 180px; position: relative; }
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100%;
  padding-bottom: 24px;
}

.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  cursor: pointer;
  opacity: 0.8;
  min-height: 2px;
}
.chart-bar:hover { opacity: 1; }
.chart-bar-label { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ===== Dashboard Gauge Cards ===== */
.dash-gauge-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  text-align: center;
  margin-bottom: 0;
}

.dash-mini-stat {
  margin-bottom: 0;
  cursor: default;
  transition: border-color 0.15s;
}

/* ===== Settings ===== */
.settings-section { margin-bottom: 28px; }
.settings-section-title { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== Utilities ===== */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-muted { color: var(--text2); }
.text-right { text-align: right; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.w-full { width: 100%; }

/* ===== Competitors badges ===== */
.comp-badge { display:inline-block;padding:3px 10px;border-radius:5px;font-size:12px;font-weight:700 }
.comp-badge.new   { background:rgba(99,102,241,0.15);color:#818cf8 }
.comp-badge.price { background:rgba(249,115,22,0.15);color:#f97316 }
.comp-badge.sale { background:rgba(34,197,94,0.15);color:#22c55e }
