/* ============================================================
   Ticket Bot — thème « cockpit » sombre, moderne et soigné.
   ============================================================ */
:root {
  --bg: #0b1020;
  --bg-2: #0f162b;
  --panel: #131c34;
  --panel-2: #16203a;
  --line: #22304f;
  --line-soft: #1b2740;
  --txt: #e6ecfb;
  --muted: #8695b8;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --green: #22c55e;
  --green-d: #16a34a;
  --red: #ef4444;
  --red-d: #dc2626;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --tx: #10b981;      /* accent tx-trade */
  --tc: #a855f7;      /* accent ticombo */
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow-soft: 0 4px 14px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--txt);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(168,85,247,.12), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
b { font-weight: 700; }
a { color: var(--primary-2); }
::selection { background: rgba(99,102,241,.35); }

/* Scrollbars */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb { background: #263353; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #33436b; background-clip: content-box; }

/* ============================================================
   Boutons
   ============================================================ */
.btn {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1b2540, #151d33);
  color: var(--txt);
  border-radius: 10px;
  padding: 9px 13px;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, filter .15s ease, box-shadow .15s ease, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--primary-2), var(--primary)); border-color: transparent; color: #fff; }
.btn-green { background: linear-gradient(180deg, #2fd070, var(--green-d)); border-color: transparent; color: #04240f; }
.btn-red   { background: linear-gradient(180deg, #f76a6a, var(--red-d));  border-color: transparent; color: #fff; }
.btn-blue  { background: linear-gradient(180deg, #5b9bff, var(--blue));   border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 9px; font-size: 12px; border-radius: 9px; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; border-radius: 8px; padding: 4px 8px; }
.icon-btn:hover { color: var(--txt); background: var(--line-soft); }

/* ============================================================
   Login
   ============================================================ */
.login { position: fixed; inset: 0; display: grid; place-items: center; grid-auto-flow: row; gap: 14px; }
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  padding: 34px 30px; border-radius: 20px; width: 340px; max-width: 90vw;
  box-shadow: var(--shadow); text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; margin-bottom: 6px;
  filter: drop-shadow(0 6px 14px rgba(99,102,241,.4)); }
.login-card h1 { margin: 4px 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.login-card p { margin: 0 0 18px; font-size: 12.5px; }
.login-card .field { margin-bottom: 12px; }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: #0c1428; color: var(--txt);
  font: inherit; outline: none; transition: border .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.25); }
.login-foot { font-size: 11px; }
.err { color: #fca5a5; margin-top: 10px; min-height: 16px; font-size: 12px; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(19,28,52,.95), rgba(15,22,43,.85));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 24px; filter: drop-shadow(0 4px 10px rgba(99,102,241,.4)); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 16px; letter-spacing: -.3px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.badge { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  background: rgba(99,102,241,.16); color: var(--primary-2);
  border: 1px solid rgba(99,102,241,.3); padding: 4px 9px; border-radius: 999px; }
.ws-state { display: flex; align-items: center; gap: 6px; font-size: 11.5px; margin-left: 2px; }

.stats { display: flex; gap: 10px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 62px; padding: 6px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); }
.stat-n { font-size: 18px; font-weight: 800; line-height: 1; }
.stat-run { color: var(--green); }
.stat-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.login-group { display: flex; align-items: center; gap: 6px; padding: 4px 8px; margin-right: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.login-group-lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.btn-login-tx { background: rgba(16,185,129,.14); border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.btn-login-tc { background: rgba(168,85,247,.14); border-color: rgba(168,85,247,.4); color: #d8b4fe; }

/* ============================================================
   Barre « appliquer à tous »
   ============================================================ */
.apply-bar {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; margin: 16px 20px 0;
  background: linear-gradient(180deg, rgba(99,102,241,.10), rgba(99,102,241,.04));
  border: 1px solid rgba(99,102,241,.22); border-radius: var(--radius);
}
.apply-title { font-weight: 800; color: var(--primary-2); font-size: 13px; padding-bottom: 8px; }
.apply-fields { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.lbl { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 600; }
.lbl input:not([type=checkbox]), .lbl select {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #0c1428; color: var(--txt); font: inherit; outline: none;
  transition: border .15s, box-shadow .15s;
}
.lbl input:focus, .lbl select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.22); }
.apply-fields > .lbl:nth-child(2), .apply-fields > .lbl:nth-child(3) { flex: 1; min-width: 200px; }
.chk { flex-direction: row !important; align-items: center; gap: 8px !important;
  color: var(--txt); font-weight: 600; padding-bottom: 8px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ============================================================
   Tableau
   ============================================================ */
.table-wrap { overflow-x: auto; padding: 16px 20px 80px; }
table#grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1560px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-soft); }
#grid thead th {
  background: #0e1730; color: var(--muted);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
#grid tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
#grid tbody tr { transition: background .12s; }
#grid tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
#grid tbody tr:hover { background: rgba(99,102,241,.07); }
#grid tbody tr:last-child td { border-bottom: 0; }

.th-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: #4d5b7d; font-size: 9.5px; }

/* Champs dans le tableau */
#grid td input[type=text], #grid td input[type=number], #grid td input[type=password], #grid td select {
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c1428; color: var(--txt); font: inherit; font-size: 12px; width: 100px; outline: none;
  transition: border .15s, box-shadow .15s;
}
#grid td input:focus, #grid td select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
#grid td input::placeholder { color: #56658a; }
.w-url input { width: 250px; }
.w-cats input { width: 155px; }
.w-login { min-width: 200px; }
.w-login input { width: 130px; display: block; margin-bottom: 4px; }
#grid td input.small { width: 78px; }

/* Site select coloré */
#grid td select { font-weight: 600; }

/* Switch */
.switch { position: relative; width: 40px; height: 23px; display: inline-block; cursor: pointer; vertical-align: middle; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: #33425f; border-radius: 999px; transition: .18s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + span { background: linear-gradient(180deg, #2fd070, var(--green-d)); }
.switch input:checked + span::after { left: 18px; }
/* ATC = ambre (distinct du vert « watcher ») pour ne pas confondre les colonnes */
.switch.sw-atc input:checked + span { background: linear-gradient(180deg, #fbbf24, #f59e0b); }

/* Statut */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.18); animation: pulse 1.8s infinite; }
.dot.off { background: #55617d; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.18);} 50% { box-shadow: 0 0 0 5px rgba(34,197,94,.05);} }
.status-cell { min-width: 170px; }
.status-txt { font-size: 11.5px; color: #c7d2ea; white-space: normal; display: inline-block; vertical-align: middle; max-width: 180px; line-height: 1.3; }

.row-actions { display: flex; gap: 6px; }

/* Sélection */
.w-check { width: 34px; text-align: center; }
.w-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
#grid tbody tr.sel { background: rgba(99,102,241,.14) !important; box-shadow: inset 3px 0 0 var(--primary); }
.sel-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 20px 0; padding: 10px 14px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(99,102,241,.16), rgba(99,102,241,.06));
  border: 1px solid rgba(99,102,241,.32); }
.sel-count { font-weight: 800; color: var(--primary-2); margin-right: 4px; }

/* Bouton catégories */
.cat-btn { display: inline-flex; align-items: center; gap: 6px; width: 155px;
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c1428; color: var(--txt); font: inherit; font-size: 12px; cursor: pointer;
  justify-content: space-between; transition: border .15s, box-shadow .15s; }
.cat-btn:hover { border-color: var(--primary); }
.cat-chev { color: var(--muted); }

/* Popover catégories */
.cat-pop { position: absolute; z-index: 80; width: 320px; max-width: 92vw;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cat-pop-head { display: flex; flex-direction: column; gap: 2px; }
.cat-pop-head b { font-size: 13px; }
.cat-pop-head .muted { font-size: 11px; }
.cat-pop-acts { display: flex; gap: 8px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 210px; overflow: auto;
  padding: 4px; border: 1px solid var(--line-soft); border-radius: 10px; }
.cat-chip { font-size: 11.5px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  background: #101a30; color: #b9c6e6; border: 1px solid var(--line); user-select: none;
  white-space: nowrap; transition: .12s; }
.cat-chip:hover { border-color: var(--primary); }
.cat-chip.on { background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff; border-color: transparent; font-weight: 600; }
.cat-add { display: flex; gap: 6px; }
.cat-add input { flex: 1; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #0c1428; color: var(--txt); font: inherit; outline: none; }
.cat-add input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.22); }

/* Vide */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-emo { font-size: 44px; opacity: .5; margin-bottom: 10px; }
.empty p { line-height: 1.6; }

/* ============================================================
   Console de logs (tiroir bas)
   ============================================================ */
.console {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #0a1120; border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  transition: height .18s ease; height: 260px;
}
.console.collapsed { height: 42px; }
.console-head { display: flex; align-items: center; gap: 10px; padding: 0 14px;
  height: 42px; min-height: 42px; cursor: pointer; border-bottom: 1px solid var(--line-soft); user-select: none; }
.console-title { font-weight: 800; font-size: 12.5px; letter-spacing: .3px; }
.console-unread { background: var(--red); color: #fff; font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; }
.console-head select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c1428; color: var(--txt); font: inherit; font-size: 12px; outline: none; }
.console-auto { font-size: 11px !important; color: var(--muted); padding: 0 !important; }
.console-auto input { width: 14px; height: 14px; }
.console-spacer { flex: 1; }
.console-body { flex: 1; overflow-y: auto; padding: 8px 12px;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55; }
.console.collapsed .console-body { display: none; }
.log-line { display: grid; grid-template-columns: 62px 20px 150px 1fr; gap: 8px; align-items: baseline;
  padding: 1px 0; border-bottom: 1px solid rgba(255,255,255,.03); white-space: nowrap; }
.log-t { color: #5b6a8c; }
.log-k { text-align: center; }
.log-lbl { color: #93a4c8; overflow: hidden; text-overflow: ellipsis; }
.log-msg { color: #c7d2ea; white-space: pre-wrap; }
.log-start .log-msg { color: #86efac; }
.log-monitor .log-msg { color: #9fb0d0; }
.log-alert .log-msg { color: #6ee7b7; font-weight: 600; }
.log-cart .log-msg { color: #fbbf24; font-weight: 600; }
.log-login .log-msg { color: #c4b5fd; }
.log-stop .log-msg { color: #94a3b8; }
.log-error .log-msg { color: #fca5a5; font-weight: 600; }
.table-wrap { padding-bottom: 300px; }

/* ============================================================
   Modale réglages
   ============================================================ */
.modal { position: fixed; inset: 0; background: rgba(4,8,18,.66); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 60; }
.modal-card { background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); padding: 22px; border-radius: 18px; width: 480px; max-width: 92vw;
  box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-card .lbl { margin-bottom: 14px; font-size: 12px; }
.modal-card input, .modal-card select { padding: 10px; border-radius: 10px; }
.sub-card { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.msg { margin-top: 12px; color: #86efac; min-height: 16px; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0 16px; }

/* ---------- Guide ---------- */
.guide-card { width: 760px; max-width: 94vw; }
.guide-body { max-height: 72vh; overflow-y: auto; padding-right: 6px; }
.g-sec { padding: 14px 16px; margin-bottom: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-2); }
.g-sec h3 { margin: 0 0 8px; font-size: 15px; color: var(--primary-2); }
.g-sec p { margin: 6px 0; line-height: 1.6; color: #cbd5e1; }
.g-sec ul, .g-sec ol { margin: 6px 0; padding-left: 20px; line-height: 1.7; color: #cbd5e1; }
.g-sec li { margin: 2px 0; }
.g-sec b { color: var(--txt); }
.g-tip { background: linear-gradient(180deg, rgba(34,197,94,.10), rgba(34,197,94,.03)); border-color: rgba(34,197,94,.3); }
.g-tip h3 { color: #6ee7b7; }
.g-warn { background: linear-gradient(180deg, rgba(245,158,11,.10), rgba(245,158,11,.03)); border-color: rgba(245,158,11,.3); }
.g-warn h3 { color: #fbbf24; }

@media (max-width: 720px) {
  .stats { order: 3; margin-left: 0; }
  .apply-fields > .lbl { flex: 1 1 100%; }
}
