/* ═══════════════════════════════════════════════════════════════════════════
   ED Trade Optimizer — style.css
   Thème sombre · Police Exo 2 · Design tokens v1.0
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Variables CSS — Design Tokens ─────────────────────────────────────────── */
:root {
  /* Fonds */
  --bg-base:              #0d1117;
  --bg-surface:           #161b22;
  --bg-elevated:          #1f2937;
  --bg-overlay:           #0d111799;
  --bg-header:            #0d1117e6;
  --bg-input:             #0d1117;
  --bg-input-disabled:    #161b22;
  --bg-row-hover:         #1f2937;
  --bg-row-selected:      #f0a50014;

  /* Textes */
  --text-primary:         #e6edf3;
  --text-secondary:       #8b949e;
  --text-disabled:        #484f58;
  --text-accent:          #f0a500;
  --text-inverse:         #0d1117;
  --text-link:            #58a6ff;
  --text-link-hover:      #79c0ff;

  /* Accent */
  --accent:               #f0a500;
  --accent-hover:         #ffb733;
  --accent-muted:         #f0a50033;
  --accent-border:        #f0a50066;

  /* États sémantiques */
  --success:              #3fb950;
  --success-bg:           #3fb95014;
  --warning:              #d29922;
  --warning-bg:           #d2992214;
  --danger:               #f85149;
  --danger-bg:            #f8514914;
  --info:                 #58a6ff;
  --info-bg:              #58a6ff14;

  /* Bordures */
  --border-subtle:        #21262d;
  --border-default:       #30363d;
  --border-strong:        #484f58;
  --border-accent:        #f0a50066;

  /* Typographie */
  --font-primary:         'Exo 2', system-ui, -apple-system, sans-serif;
  --font-mono:            'Courier New', Courier, monospace;
  --text-xs:              11px;
  --text-sm:              13px;
  --text-base:            15px;
  --text-md:              17px;
  --text-lg:              20px;
  --text-xl:              24px;
  --text-2xl:             28px;
  --text-3xl:             32px;
  --weight-regular:       400;
  --weight-medium:        500;
  --weight-semibold:      600;
  --weight-bold:          700;
  --leading-tight:        1.25;
  --leading-normal:       1.5;
  --leading-relaxed:      1.75;

  /* Espacements */
  --space-1:              4px;
  --space-2:              8px;
  --space-3:              12px;
  --space-4:              16px;
  --space-5:              20px;
  --space-6:              24px;
  --space-8:              32px;
  --space-12:             48px;

  /* Layout */
  --header-height:        48px;
  --sidebar-width:        28%;
  --content-width:        72%;
  --max-width:            1400px;
  --touch-target:         44px;
  --input-height:         40px;
  --input-height-mobile:  48px;
  --btn-height:           44px;
  --btn-height-primary:   52px;
  --dropdown-max-height:  280px;
  --table-row-height:     40px;
  --radius-sm:            4px;
  --radius-md:            6px;
  --radius-lg:            8px;
  --radius-xl:            12px;
  --radius-full:          9999px;

  /* Ombres */
  --shadow-sm:            0 1px 3px #00000066;
  --shadow-md:            0 4px 12px #00000080;
  --shadow-lg:            0 8px 24px #000000b3;
  --shadow-accent:        0 0 0 2px #f0a50066;
  --shadow-success:       0 0 0 2px #3fb95033;

  /* Transitions */
  --transition-fast:      100ms ease;
  --transition-base:      200ms ease;
  --transition-slow:      350ms ease;
  --transition-cargo:     600ms ease-out;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes blink-danger {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

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

html {
  font-size: var(--text-base);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Fond étoilé subtil */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(240,165,0,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 70%, rgba(88,166,255,0.1) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 50%, rgba(230,237,243,0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--text-link); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--text-link-hover); }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.header__logo .logo-star {
  color: var(--accent);
  font-size: var(--text-xl);
}

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header__nav a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.header__nav a:hover,
.header__nav a.active {
  color: var(--text-accent);
  border-color: var(--border-accent);
  background: var(--accent-muted);
}

.header__menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-lg);
  cursor: pointer;
  padding: var(--space-2);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  align-items: center;
  justify-content: center;
}

/* ── Layout Principal ────────────────────────────────────────────────────────── */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: var(--header-height);
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: 280px;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}

.content {
  flex: 1;
  padding: var(--space-5) var(--space-5);
  min-width: 0;
}

/* ── Panneau surface ─────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

/* ── Champs de saisie ────────────────────────────────────────────────────────── */
.field-group {
  margin-bottom: var(--space-3);
}

.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.input-wrap {
  position: relative;
}

.field-input {
  width: 100%;
  height: var(--input-height);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  padding: 0 var(--space-3);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.field-input:focus {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-sm);
}

.field-input:disabled {
  background: var(--bg-input-disabled);
  border-color: var(--border-subtle);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.field-input.is-valid {
  border-color: var(--success);
}

.field-input.is-error {
  border-color: var(--danger);
}

.field-status {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.field-clear {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1);
  transition: color var(--transition-fast);
  line-height: 1;
}

.field-clear:hover { color: var(--danger); }

.field-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
}

/* ── Dropdown autocomplete ───────────────────────────────────────────────────── */
.dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  max-height: var(--dropdown-max-height);
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-md);
  animation: fadeIn var(--transition-base) ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}

.dropdown-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.dropdown-item:hover,
.dropdown-item.focused {
  background: var(--bg-row-hover);
}

.dropdown-item.focused {
  border-left-color: var(--accent);
  background: var(--accent-muted);
  color: var(--text-accent);
}

.dropdown-item__name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item__meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.dropdown-item__pad {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-accent);
  background: var(--accent-muted);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.dropdown-item__fc {
  font-size: var(--text-xs);
  color: var(--info);
  background: var(--info-bg);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.dropdown-empty {
  padding: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

.dropdown-loading {
  padding: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

/* ── Champs numériques avec boutons ±  ──────────────────────────────────────── */
.num-field {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.num-field .field-input {
  text-align: center;
  -moz-appearance: textfield;
}
.num-field .field-input::-webkit-inner-spin-button,
.num-field .field-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.num-btn {
  min-width: var(--btn-height);
  height: var(--input-height);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.num-btn:hover {
  background: var(--bg-row-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.num-field__unit {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Bouton ANALYSER ─────────────────────────────────────────────────────────── */
.btn-analyze {
  width: 100%;
  height: var(--btn-height-primary);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: var(--font-primary);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  box-shadow: var(--shadow-md);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-analyze:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-analyze:active {
  background: #cc8c00;
  box-shadow: none;
  transform: translateY(0);
}

.btn-analyze:disabled {
  background: #f0a50055;
  color: var(--text-disabled);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-analyze.loading {
  pointer-events: none;
}

.spinner {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

/* ── Boutons secondaires ─────────────────────────────────────────────────────── */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.btn-secondary:hover {
  background: var(--bg-row-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary.active {
  background: var(--accent-muted);
  border-color: var(--border-accent);
  color: var(--text-accent);
}

/* ── Carte aller-retour (round-trip) ─────────────────────────────────────────── */
.rt-card {
  animation: fadeIn var(--transition-slow) ease;
}

.rt-legs {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: var(--space-4);
}

.rt-leg {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}

.rt-leg__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.rt-leg__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  min-width: 56px;
  flex-shrink: 0;
}

.rt-leg__route {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  overflow: hidden;
}

.rt-leg__route strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-arrow {
  color: var(--accent);
  flex-shrink: 0;
  font-size: var(--text-xs);
}

.rt-leg__profit {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  flex-shrink: 0;
}

.rt-leg__profit.has-profit { color: var(--text-accent); }
.rt-leg__profit.no-profit  { color: var(--text-secondary); }

.rt-leg__profit-unit {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
  margin-left: 3px;
}

.rt-leg__cargo {
  margin-top: var(--space-2);
}

.cargo-bar {
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cargo-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0%;
  transition: width var(--transition-cargo), background-color var(--transition-base);
}

.cargo-bar__fill.full    { background: var(--success); }
.cargo-bar__fill.partial { background: var(--warning); }
.cargo-bar__fill.low     { background: var(--danger); }

.rt-leg__mix {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-leg__empty {
  font-size: var(--text-sm);
  color: var(--text-disabled);
  margin-top: var(--space-1);
  font-style: italic;
}

.rt-separator {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-1) 0 var(--space-2);
}

.rt-total {
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.rt-total__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.rt-total__profit {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.rt-total__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-accent);
  line-height: var(--leading-tight);
}

.rt-total__value.no-profit { color: var(--text-secondary); }

.rt-total__unit {
  font-size: var(--text-base);
  color: var(--text-secondary);
}

.rt-total__detail {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.btn-save {
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-save:hover {
  border-color: var(--accent);
  color: var(--text-accent);
}

.btn-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Onglets tableau A→B / B→A */
.table-tabs {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.table-tab {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.table-tab:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.table-tab.active {
  background: var(--accent-muted);
  border-color: var(--border-accent);
  color: var(--text-accent);
  font-weight: var(--weight-semibold);
}

/* ── Select station natif ────────────────────────────────────────────────────── */
.station-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.station-select {
  flex: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: calc(var(--space-3) * 2 + 12px);
}

/* Optgroup "✓ Accessibles" */
.station-select optgroup {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-style: normal;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Options normales */
.station-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-base);
  padding: var(--space-1) 0;
}

/* Options désactivées (stations inaccessibles) */
.station-select option:disabled {
  color: var(--text-disabled);
  background: var(--bg-elevated);
}

/* Spinner de chargement */
.station-spinner {
  font-size: var(--text-base);
  color: var(--text-secondary);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.ship-select-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ship-select {
  flex: 1;
  cursor: pointer;
  /* Flèche native remplacée */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: calc(var(--space-3) * 2 + 12px);
}

.ship-select option,
.ship-select optgroup {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Badge pad déduit du vaisseau */
.ship-pad-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid;
  transition: all var(--transition-base);
}

.ship-pad-badge.pad-S {
  color: var(--info);
  background: var(--info-bg);
  border-color: var(--info);
}

.ship-pad-badge.pad-M {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: var(--warning);
}

.ship-pad-badge.pad-L {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* Avertissement pad Large */
.ship-warning {
  font-size: var(--text-xs);
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

/* Station incompatible dans le dropdown */
.dropdown-item.pad-incompatible {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.dropdown-item.pad-incompatible .dropdown-item__name::after {
  content: ' — pad insuffisant';
  font-size: var(--text-xs);
  color: var(--danger);
  font-weight: var(--weight-regular);
}

/* Badge pad dans les infos station (résultats) */
.station-pad-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.station-pad-badge.ok   { color: var(--success); background: var(--success-bg); }
.station-pad-badge.warn { color: var(--danger);  background: var(--danger-bg); }

/* ── Accordéon ───────────────────────────────────────────────────────────────── */
.filters-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-3);
  background: var(--bg-elevated);
  padding: var(--space-4);
}

.filters-section__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.accordion__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  background: var(--bg-surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  border: none;
  width: 100%;
  text-align: left;
}

.accordion__header:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.accordion.open .accordion__header {
  border-bottom: 1px solid var(--border-accent);
  color: var(--text-primary);
}

.accordion__icon {
  transition: transform var(--transition-base);
  font-size: var(--text-xs);
}

.accordion.open .accordion__icon {
  transform: rotate(0deg);
}

.accordion__body {
  display: none;
  background: var(--bg-elevated);
  padding: var(--space-4);
}

.accordion.open .accordion__body {
  display: block;
  animation: slideDown var(--transition-base) ease;
}

/* ── Tableau des commodités ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  margin-bottom: var(--space-4);
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.table-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.freshness-banner {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.freshness-banner.success { color: var(--success); background: var(--success-bg); }
.freshness-banner.warning { color: var(--warning); background: var(--warning-bg); }
.freshness-banner.danger  { color: var(--danger);  background: var(--danger-bg); }
.freshness-banner.dead    { color: var(--danger);  background: var(--danger-bg); animation: blink-danger 1.5s ease-in-out infinite; }
.freshness-banner.unknown { color: var(--text-secondary); background: var(--bg-elevated); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

thead th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

thead th:hover { color: var(--text-primary); }

thead th.sort-active {
  color: var(--text-accent);
}

thead th .sort-icon {
  font-size: var(--text-xs);
  margin-left: var(--space-1);
}

tbody tr {
  height: var(--table-row-height);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-row-hover); }

tbody tr.top-row {
  background: var(--bg-row-selected);
  border-left: 3px solid var(--accent);
}

tbody tr.disabled-row {
  color: var(--text-disabled);
}

tbody td {
  padding: var(--space-2) var(--space-3);
  vertical-align: middle;
  white-space: nowrap;
}

tbody td:first-child {
  font-weight: var(--weight-medium);
}

.badge-rare {
  display: inline-block;
  background: var(--accent-muted);
  color: var(--text-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  margin-left: var(--space-1);
  letter-spacing: 0.05em;
}

.vs-cargo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.vs-cargo.full    { color: var(--success); }
.vs-cargo.partial { color: var(--warning); }
.vs-cargo.low     { color: var(--danger); }

.table-expanded {
  background: var(--bg-elevated);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
}

.table-show-more {
  padding: var(--space-3) var(--space-4);
  text-align: center;
}

.table-show-more button {
  background: none;
  border: none;
  color: var(--text-link);
  font-size: var(--text-sm);
  cursor: pointer;
  font-family: var(--font-primary);
}

.table-show-more button:hover { color: var(--text-link-hover); }

/* ── Bloc info stations ───────────────────────────────────────────────────────── */
.stations-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.station-info {
  padding: var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.station-info__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.station-info__name {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.station-info__row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.station-info__row-label {
  color: var(--text-secondary);
  min-width: 70px;
  flex-shrink: 0;
}

.station-info__row-value {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

.station-info__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

/* ── Badges état BGS ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.badge.success { color: var(--success); background: var(--success-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.danger  { color: var(--danger);  background: var(--danger-bg); }
.badge.info    { color: var(--info);    background: var(--info-bg); }

.badge.boom       { color: var(--success); background: var(--success-bg); }
.badge.war        { color: var(--danger);  background: var(--danger-bg); }
.badge.election   { color: var(--info);    background: var(--info-bg); }
.badge.expansion  { color: var(--warning); background: var(--warning-bg); }
.badge.outbreak   { color: var(--danger);  background: var(--danger-bg); }
.badge.retreat    { color: var(--text-secondary); background: var(--bg-elevated); }
.badge.default    { color: var(--text-secondary); background: var(--bg-elevated); }

/* ── Favoris ─────────────────────────────────────────────────────────────────── */
.favorites-section {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.favorites-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.fav-btn {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  gap: var(--space-2);
  min-height: var(--touch-target);
}

.fav-btn:hover {
  background: var(--bg-row-hover);
  border-color: var(--border-accent);
}

.fav-btn__label {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  font-family: var(--font-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-btn__meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.fav-btn__profit {
  font-size: var(--text-xs);
  color: var(--text-accent);
  font-weight: var(--weight-semibold);
}

.fav-btn__arrow {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.fav-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1);
  transition: color var(--transition-fast);
  flex-shrink: 0;
  line-height: 1;
}
.fav-delete:hover { color: var(--danger); }

/* ── Bandeau d'alerte ────────────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  animation: fadeIn var(--transition-base) ease;
}

.alert.warning { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); }
.alert.danger  { background: var(--danger-bg);  border: 1px solid var(--danger);  color: var(--danger); }
.alert.info    { background: var(--info-bg);    border: 1px solid var(--info);    color: var(--info); }
.alert.success { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }

/* ── État vide ────────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  min-height: 200px;
}

.empty-state__icon {
  font-size: 40px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state__text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  max-width: 360px;
}

/* ── Slider distance ─────────────────────────────────────────────────────────── */
.slider-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slider-field input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  outline: none;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.slider-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  min-width: 60px;
  text-align: right;
}

/* ── Checkbox custom ─────────────────────────────────────────────────────────── */
.check-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.check-field input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Utilitaires ──────────────────────────────────────────────────────────────── */
.text-accent   { color: var(--text-accent); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-secondary{ color: var(--text-secondary); }
.text-sm       { font-size: var(--text-sm); }
.text-xs       { font-size: var(--text-xs); }
.bold          { font-weight: var(--weight-bold); }
.semibold      { font-weight: var(--weight-semibold); }
.hidden        { display: none !important; }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.gap-2         { gap: var(--space-2); }
.gap-3         { gap: var(--space-3); }
.ml-auto       { margin-left: auto; }
.mt-3          { margin-top: var(--space-3); }
.mb-3          { margin-bottom: var(--space-3); }
.mono          { font-family: var(--font-mono); }

/* ── Page Favoris ────────────────────────────────────────────────────────────── */
.favorites-page {
  max-width: 860px;
  margin: var(--space-6) auto;
  padding: 0 var(--space-4);
}

.favorites-page h1 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.fav-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: border-color var(--transition-fast);
}

.fav-card:hover { border-color: var(--border-strong); }

.fav-card__info { flex: 1; }

.fav-card__label {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.fav-card__meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.fav-card__profit {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-accent);
  white-space: nowrap;
}

.fav-card__actions {
  display: flex;
  gap: var(--space-2);
}

/* ── Responsive Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-4);
  }

  .content {
    padding: var(--space-4);
    order: -1; /* Carte Décision en premier sur mobile */
  }

  .stations-grid {
    grid-template-columns: 1fr;
  }

  .header__nav {
    display: none;
  }

  .header__menu-btn {
    display: flex;
  }

  .fav-card {
    flex-wrap: wrap;
  }

  .fav-card__profit { width: 100%; }

  .field-input, .btn-analyze {
    height: var(--input-height-mobile);
  }

  table {
    font-size: var(--text-sm);
  }

  /* 3 colonnes max sur mobile portrait */
  .table-col-hide-mobile {
    display: none;
  }
}

@media (max-width: 479px) {
  .header { padding: 0 var(--space-3); }
  .decision-card { padding: var(--space-4); }
}
