:root {
  --bg: #04070e;
  --panel: rgba(10, 17, 28, 0.66);
  --panel-2: rgba(16, 26, 42, 0.82);
  --line: rgba(90, 135, 185, 0.18);
  --line-hot: rgba(34, 211, 238, 0.5);
  --txt: #e4edfa;
  --dim: #7f95b4;
  --dim-2: #566b85;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --blue: #3b82f6;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #fb7185;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --glow-cyan: 0 0 22px rgba(34, 211, 238, 0.28);
  --radius: 4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ---------- Fonds décoratifs ---------- */
.bg-grid, .bg-glow, .bg-scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.bg-grid {
  background-image:
    linear-gradient(rgba(80, 140, 200, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 140, 200, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, #000 40%, transparent 100%);
}
.bg-glow {
  background:
    radial-gradient(760px 380px at 82% -8%, rgba(34, 211, 238, 0.12), transparent 60%),
    radial-gradient(680px 360px at 8% 4%, rgba(59, 130, 246, 0.12), transparent 60%);
}
.bg-scan {
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0, rgba(255,255,255,0.014) 1px, transparent 1px, transparent 3px);
  opacity: 0.6;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(180deg, rgba(6, 11, 20, 0.92), rgba(6, 11, 20, 0.7));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(34, 211, 238, 0.08), 0 10px 30px rgba(0,0,0,0.4);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  color: var(--cyan);
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: 1px solid var(--line-hot);
  border-radius: 8px;
  background: var(--cyan-soft);
  box-shadow: inset 0 0 14px rgba(34, 211, 238, 0.16), var(--glow-cyan);
}
.topbar h1 {
  margin: 0; font-size: 19px; font-weight: 700;
  letter-spacing: 4px;
}
.pro-badge {
  font-size: 10px; letter-spacing: 2px; font-weight: 800; vertical-align: middle;
  color: var(--bg); background: linear-gradient(120deg, var(--cyan), var(--blue));
  padding: 2px 6px; border-radius: 3px; margin-left: 4px; box-shadow: var(--glow-cyan);
}
.tagline { margin: 3px 0 0; font-size: 11px; color: var(--dim); letter-spacing: 1.5px; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.sys-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.5px;
  color: var(--dim); text-transform: uppercase;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
}
.sys-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
  animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.file-name {
  font-family: var(--mono); font-size: 12px; color: var(--cyan);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Boutons ---------- */
.btn {
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--txt);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 10px 18px; border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.14s ease;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
}
.btn:hover { border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #04121a; font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}
.btn-primary:hover { filter: brightness(1.12); box-shadow: 0 0 26px rgba(34, 211, 238, 0.55); }
.btn-ghost { background: transparent; }

/* ---------- Layout écran ---------- */
.screen { position: relative; z-index: 1; max-width: 1160px; margin: 0 auto; padding: 30px 24px 140px; }
.screen-title {
  margin: 6px 0 6px; font-size: 20px; font-weight: 700; letter-spacing: 1px;
}
.screen-title::before {
  content: "▸ "; color: var(--cyan);
}
.screen-sub { margin: 0 0 24px; color: var(--dim); font-size: 14px; }

/* Panneau HUD réutilisable (coins crochet) */
.hud { position: relative; }
.hud::before, .hud::after {
  content: ""; position: absolute; width: 16px; height: 16px; pointer-events: none;
  border: 2px solid var(--cyan); opacity: 0.7;
}
.hud::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.hud::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ---------- Import ---------- */
.dropzone {
  position: relative;
  border: 1px dashed var(--line-hot);
  border-radius: 10px;
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(34,211,238,0.06), transparent 70%),
    var(--panel);
  padding: 68px 30px; text-align: center;
  transition: all 0.18s ease;
  overflow: hidden;
}
.dropzone::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent, rgba(34,211,238,0.05));
  pointer-events: none;
}
.dropzone.drag { border-color: var(--cyan); background: rgba(34,211,238,0.08); box-shadow: inset 0 0 60px rgba(34,211,238,0.12); }
.dz-icon { font-size: 40px; color: var(--cyan); filter: drop-shadow(0 0 10px rgba(34,211,238,0.5)); }
.dropzone h2 { margin: 16px 0 8px; font-size: 22px; letter-spacing: 0.5px; }
.dropzone p { color: var(--dim); margin: 6px 0 20px; }
.dz-hint { font-size: 12.5px; margin-top: 22px !important; color: var(--dim-2); }
.dz-inner { position: relative; z-index: 1; }

.resume-box {
  margin-top: 22px; padding: 18px 22px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.resume-box p { margin: 0; }
.resume-actions { display: flex; gap: 10px; }

/* ---------- Mapping ---------- */
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 26px; }
.map-field {
  position: relative;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 15px 16px 16px;
  transition: border 0.14s ease;
}
.map-field:focus-within { border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.map-field label { display: block; margin-bottom: 10px; }
.map-field .role { font-weight: 700; font-size: 13.5px; letter-spacing: 0.5px; }
.map-field small { color: var(--dim); font-size: 11.5px; }
.map-field.req .role::after { content: " *"; color: var(--cyan); }
.map-field select {
  width: 100%; padding: 10px 11px; border-radius: 5px;
  background: #0a1220; color: var(--txt);
  border: 1px solid var(--line); font-size: 13.5px; font-family: var(--mono);
}
.map-field select:focus { outline: none; border-color: var(--cyan); }

.map-preview h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); }
.table-scroll {
  overflow-x: auto; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
#previewTable th, #previewTable td { padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-family: var(--mono); }
#previewTable th { background: rgba(34,211,238,0.06); color: var(--cyan); position: sticky; top: 0; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
#previewTable tr:last-child td { border-bottom: 0; }
.mapping-actions { display: flex; justify-content: space-between; margin-top: 26px; }

/* ---------- Inventaire ---------- */
.inv-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.search-wrap { flex: 1; min-width: 260px; position: relative; }
#searchInput {
  width: 100%; padding: 13px 16px; border-radius: 6px;
  background: var(--panel-2); color: var(--txt);
  border: 1px solid var(--line); font-size: 14.5px;
  transition: all 0.14s ease;
}
#searchInput::placeholder { color: var(--dim-2); }
#searchInput:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.5px;
  color: var(--dim);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 9px 15px; border-radius: 999px; cursor: pointer;
  transition: all 0.14s ease; text-transform: uppercase;
}
.chip:hover { color: var(--txt); border-color: var(--line-hot); }
.chip-active {
  color: #04121a; font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent; box-shadow: 0 0 14px rgba(34,211,238,0.4);
}

.progress-bar-wrap { margin: 4px 0 18px; }
.progress-stats { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#statCount { font-family: var(--mono); font-size: 13px; color: var(--dim); letter-spacing: 0.5px; }
.stat-ecart { font-family: var(--mono); font-size: 13px; color: var(--amber); font-weight: 700; letter-spacing: 0.5px; }
.progress-track {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
}
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 12px rgba(34,211,238,0.6);
  transition: width 0.3s ease;
}

.inv-table-scroll {
  max-height: calc(100vh - 310px); overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.inv-table th, .inv-table td { padding: 11px 14px; border-bottom: 1px solid rgba(90,135,185,0.1); text-align: left; vertical-align: middle; }
.inv-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: rgba(8,14,24,0.96); backdrop-filter: blur(6px);
  color: var(--cyan); font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
  border-bottom: 1px solid var(--line-hot);
}
.inv-table tbody tr { transition: background 0.1s ease; }
.inv-table tbody tr:hover { background: rgba(34,211,238,0.05); }
.inv-table tbody tr.done { background: rgba(52,211,153,0.05); }
.inv-table tbody tr.done:hover { background: rgba(52,211,153,0.09); }
.inv-table tbody tr.active-row { box-shadow: inset 3px 0 0 var(--cyan); background: rgba(34,211,238,0.08); }
.col-ref { font-family: var(--mono); font-weight: 700; color: var(--txt); letter-spacing: 0.5px; }
.col-des { color: var(--txt); }
.col-loc { color: var(--dim); font-family: var(--mono); font-size: 12.5px; }
.col-theo, .col-count, .col-ecart { text-align: right; white-space: nowrap; }
.col-theo { font-family: var(--mono); color: var(--dim); }
.count-cell { display: flex; align-items: center; gap: 9px; justify-content: flex-end; }
.count-input {
  width: 96px; padding: 8px 11px; text-align: right;
  background: #0a1220; color: var(--cyan); border: 1px solid var(--line); border-radius: 5px;
  font-size: 15px; font-family: var(--mono); font-weight: 700;
  transition: all 0.12s ease;
}
.count-input:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.count-input::-webkit-outer-spin-button, .count-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row-mic {
  width: 36px; height: 36px; border-radius: 6px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  display: grid; place-items: center; font-size: 15px; transition: all 0.14s ease;
}
.row-mic:hover { color: var(--cyan); border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.row-mic.listening { color: var(--red); border-color: var(--red); box-shadow: 0 0 12px rgba(251,113,133,0.5); }
.ecart-badge {
  display: inline-block; min-width: 44px; text-align: center;
  padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 700;
  font-family: var(--mono); border: 1px solid transparent;
}
.ecart-zero { color: var(--green); background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.3); }
.ecart-pos { color: var(--cyan); background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.3); }
.ecart-neg { color: var(--red); background: rgba(251,113,133,0.12); border-color: rgba(251,113,133,0.3); }
.ecart-empty { color: var(--dim-2); }
.empty-list { text-align: center; color: var(--dim); padding: 46px; font-family: var(--mono); }

/* ---------- Barre vocale ---------- */
.voice-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px;
  width: min(780px, calc(100% - 32px)); z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(12,20,34,0.97), rgba(8,14,24,0.97));
  border: 1px solid var(--line-hot); border-radius: 10px;
  box-shadow: 0 12px 44px rgba(0,0,0,0.55), var(--glow-cyan);
}
.voice-bar.listening { border-color: var(--red); box-shadow: 0 12px 44px rgba(0,0,0,0.55), 0 0 24px rgba(251,113,133,0.4); }
.voice-target { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.voice-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--dim); }
.voice-target strong { font-family: var(--mono); font-size: 18px; color: var(--cyan); letter-spacing: 0.5px; }
.voice-des { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.voice-controls { display: flex; align-items: center; gap: 14px; }
.voice-heard { min-width: 54px; text-align: right; font-family: var(--mono); font-size: 16px; color: var(--cyan); font-weight: 700; }

/* Ondes animées */
.waveform { display: flex; align-items: center; gap: 3px; height: 30px; }
.waveform span {
  width: 3px; height: 5px; border-radius: 2px; background: var(--dim-2);
  transition: background 0.2s ease;
}
.voice-bar.listening .waveform span {
  background: var(--cyan); box-shadow: 0 0 6px rgba(34,211,238,0.7);
  animation: wave 0.9s ease-in-out infinite;
}
.voice-bar.listening .waveform span:nth-child(1) { animation-delay: 0s; }
.voice-bar.listening .waveform span:nth-child(2) { animation-delay: 0.12s; }
.voice-bar.listening .waveform span:nth-child(3) { animation-delay: 0.24s; }
.voice-bar.listening .waveform span:nth-child(4) { animation-delay: 0.36s; }
.voice-bar.listening .waveform span:nth-child(5) { animation-delay: 0.24s; }
.voice-bar.listening .waveform span:nth-child(6) { animation-delay: 0.12s; }
.voice-bar.listening .waveform span:nth-child(7) { animation-delay: 0s; }
@keyframes wave { 0%,100% { height: 5px; } 50% { height: 26px; } }

.mic-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  color: #04121a; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 6px 20px rgba(34,211,238,0.45);
  transition: transform 0.1s ease;
}
.mic-btn:active { transform: scale(0.93); }
.mic-btn.listening {
  color: #fff;
  background: linear-gradient(135deg, var(--red), #e11d48);
  animation: micpulse 1.1s infinite;
}
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(251,113,133,0.55); } 50% { box-shadow: 0 0 0 16px rgba(251,113,133,0); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%);
  padding: 13px 22px; border-radius: 8px; z-index: 60;
  font-family: var(--mono); font-size: 13.5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5); backdrop-filter: blur(8px);
}
.toast.err { border-color: var(--red); color: #fecdd3; box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 16px rgba(251,113,133,0.3); }
.toast.ok { border-color: var(--green); color: #bbf7d0; box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 16px rgba(52,211,153,0.3); }
