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

:root {
  --bg: #0f1520;
  --bg-card: #192033;
  --bg-card-hover: #1f2a40;
  --border: #263049;
  --text: #e2e8f0;
  --text-muted: #7a8599;
  --accent: #ffbc12;
  --accent-dim: rgba(255, 188, 18, 0.12);
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}


.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e5a200);
  border-color: transparent;
  color: #000;
  font-weight: 600;
}

.btn-primary:hover { opacity: 0.9; border-color: transparent; }

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
  color: var(--red);
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tabs-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  margin-right: 8px;
  flex-shrink: 0;
}

.tab {
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  font-weight: 500;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Main content */
.main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.section { display: none; opacity: 0; transform: translateX(10px); transition: opacity 0.25s ease, transform 0.25s ease; }
.section.active { display: block; opacity: 1; transform: translateX(0); }

/* Filters bar */
.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-search {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  width: 160px;
  transition: border-color 0.2s;
}

.filter-search:focus { border-color: var(--accent); }

.filter-search::placeholder { color: var(--text-muted); }

.filter-buttons {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover { color: var(--text); border-color: var(--text-muted); }

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

/* Coins widget */
.coins-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.coins-widget-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coins-widget-icon {
  font-size: 1.4rem;
}

.coins-widget-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.coins-widget-price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.coins-widget-unit {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.coins-widget-calc {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coins-widget-input {
  width: 70px;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.coins-widget-input:focus {
  border-color: var(--accent);
}

.coins-widget-eq {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.coins-widget-result {
  font-weight: 600;
  color: var(--accent);
  font-size: 1rem;
}

.coins-widget-unit-label {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
  margin-right: 4px;
}

.coins-widget-real {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

.editable-qty {
  cursor: pointer;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.4);
  transition: color 0.2s;
}
.editable-qty:hover {
  color: var(--accent);
}

.coins-widget-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: #94a3b8;
  transition: all 0.2s;
  margin-left: auto;
}

.coins-widget-link:hover {
  color: var(--accent);
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--accent);
}

/* Price cards grid */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.price-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.price-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.price-card-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.price-card-info {
  flex: 1;
  min-width: 0;
}

.price-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.price-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Trend indicators */
.trend {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.trend-up { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.trend-down { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.trend-neutral { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); }

.price-card-sell {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.price-card-margin {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.margin-good { color: var(--green); }
.margin-ok { color: var(--orange); }
.margin-low { color: var(--red); }

.price-card-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Buy icon */
.price-card-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: #94a3b8;
  transition: all 0.2s;
}

.price-card-buy:hover {
  color: var(--accent);
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--accent);
}

/* Simulator icon on price cards */
.price-card-sim {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
}

.price-card-sim:hover {
  color: var(--green);
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--green);
}

/* Placeholder image */
.price-card-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

/* Chart section */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* Chart current price card */
.chart-current-price { margin-bottom: 16px; }

.chart-price-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.chart-price-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  transition: all 0.2s;
}

.chart-price-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.chart-price-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.chart-price-info { flex: 1; }

.chart-price-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.chart-price-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.chart-price-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

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

.chart-header h3 { font-size: 0.95rem; font-weight: 600; }

.chart-controls { display: flex; gap: 4px; }

.chart-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

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

.chart-wrap { position: relative; height: 300px; }

/* Simulator search bar */
.sim-search-bar {
  margin-bottom: 16px;
}

.sim-search-bar .filter-search {
  width: 100%;
}

/* Simulator cards */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.sim-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.sim-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sim-card-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.sim-card-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.sim-card-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sim-qty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sim-qty-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 10px;
}

.sim-qty-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sim-qty-price {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

/* Forms */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group { flex: 1; min-width: 150px; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus { border-color: var(--accent); }

/* Stat blocks */
.sim-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.sim-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

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

/* Loading & empty states */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 10px;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p { font-size: 0.9rem; }

.last-update {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--text);
  z-index: 1000;
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

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

/* Tarifs section */
.tarifs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.tarifs-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.tarifs-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tarifs-sort select {
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
}

.tarifs-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.tarifs-table-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
}

.tarifs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.tarifs-table thead th {
  text-align: left;
  padding: 10px 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tarifs-table tbody td {
  padding: 8px;
  border-bottom: 1px solid rgba(30, 45, 61, 0.3);
  vertical-align: middle;
}

.tarifs-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.tarifs-name {
  font-weight: 600;
  white-space: nowrap;
}

.tarifs-input {
  width: 90px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  text-align: right;
}

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

.tarifs-input-sm {
  width: 60px;
}

/* Seller trust levels in simulator */
.seller-level {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
}

.seller-trusted .seller-level {
  color: var(--green);
  background: rgba(16, 185, 129, 0.1);
}

.seller-untrusted .seller-level {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

tr.seller-untrusted {
  opacity: 0.6;
}

/* Achats (purchases) section */
.achats-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.achats-form h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 16px; }

.achats-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.achats-avg-table-wrap,
.achats-table-wrap {
  overflow-x: auto;
}

/* Favorite star */
.price-card-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 188, 18, 0.08);
  border: 1px solid rgba(255, 188, 18, 0.15);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.price-card-fav:hover {
  color: var(--accent);
  background: rgba(255, 188, 18, 0.18);
  border-color: var(--accent);
}

.price-card-fav.is-fav {
  color: var(--accent);
  background: rgba(255, 188, 18, 0.2);
  border-color: var(--accent);
}

/* Simulator custom input */
.sim-custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 10px;
  grid-column: 1 / -1;
}

.sim-custom-input {
  width: 60px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.sim-custom-input:focus {
  border-color: var(--accent);
}

/* Responsive */
@media (max-width: 600px) {
  .tabs { padding: 0 6px; }
  .tabs-logo { width: 24px; height: 24px; margin-right: 4px; }
  .tab { padding: 10px 12px; font-size: 0.78rem; }
  .main { padding: 12px; }
  .filters-bar { gap: 8px; }
  .filter-search { width: 100%; order: -1; }
  .filter-btn { padding: 4px 8px; font-size: 0.72rem; }
  .price-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 220px; }
  .form-row { flex-direction: column; }
  .tarifs-action-col { display: none; }
  .tarifs-table tbody td { padding: 6px 4px; }
  .tarifs-table thead th { padding: 8px 4px; }
  .tarifs-input { width: 52px; padding: 4px 4px; font-size: 0.78rem; }
  .tarifs-input-sm { width: 38px; }
  .sim-grid { grid-template-columns: 1fr; }
  .sim-qty-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
  .chart-price-value { font-size: 1.1rem; }
  .coins-widget { flex-direction: column; align-items: flex-start; }
  .coins-widget-link { margin-left: 0; }
}
