/*
 * WARS — thème WhatsApp × terminal
 * Ancienne feuille : web/styles.backup-20260507.css
 */

* {
  box-sizing: border-box;
}

:root {
  /* Palette type WhatsApp (sombre + verts) */
  --wa: #25d366;
  --wa-hover: #20bd5a;
  --wa-teal: #128c7e;
  --wa-deep: #075e54;
  --wa-bubble: #dcf8c6;
  /* Compat : rgba(var(--accent), a) utilisé partout */
  --accent: 37 211 102;
  --accent-strong: 72 242 161;
  --accent-dim: 18 140 126;
  --bg: #050807;
  --bg-elevated: #0c1411;
  --bg-input: rgba(0, 0, 0, 0.45);
  --text: #e8fdf1;
  --text-muted: rgba(232, 253, 241, 0.62);
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 8px;
  --font: ui-monospace, "Cascadia Code", "Fira Code", SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --shadow-glow: 0 0 32px rgba(37, 211, 102, 0.12);
  --border-glow: 1px solid rgba(37, 211, 102, 0.35);
}

html {
  height: 100%;
  background-color: var(--bg);
  scrollbar-gutter: stable;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 500px at 15% -20%, rgba(37, 211, 102, 0.14), transparent 50%),
    radial-gradient(ellipse 700px 400px at 100% 30%, rgba(18, 140, 126, 0.1), transparent 45%),
    linear-gradient(180deg, #070d0a 0%, var(--bg) 38%, #030504 100%);
  background-attachment: fixed;
}

/* Faux CRT / scanlines léger */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(37, 211, 102, 0.09) 2px,
    rgba(37, 211, 102, 0.09) 3px
  );
  mix-blend-mode: overlay;
}

.container {
  max-width: min(1880px, 100vw - 20px);
  margin: 0 auto;
  padding: 16px 12px;
  width: 100%;
}

/* ——— Cartes & panneaux ——— */
.card {
  position: relative;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid rgba(37, 211, 102, 0.28);
  box-shadow: var(--shadow-glow), 0 24px 48px rgba(0, 0, 0, 0.55);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(114, 245, 182, 0.06);
}

.card.app-main-card {
  padding: 18px;
  max-width: min(1640px, calc(100vw - 40px));
  margin: 18px auto;
}

/* ——— Topbar / marque ——— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(37, 211, 102, 0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(37, 211, 102, 0.45));
}

.topbar img {
  max-width: 44px;
  max-height: 44px;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow:
    0 0 18px rgba(37, 211, 102, 0.55),
    0 0 2px rgba(37, 211, 102, 0.9);
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wa);
  opacity: 0.85;
}

.brand-subtitle::before {
  content: "> ";
  color: rgba(37, 211, 102, 0.5);
}

/* ——— Boutons globaux ——— */
.logout-btn {
  width: auto;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: linear-gradient(180deg, rgba(185, 28, 28, 0.9), rgba(127, 29, 29, 0.95));
  color: #fee2e2;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.logout-btn:hover {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.25);
}

.hidden {
  display: none !important;
}

h1 {
  margin-top: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

label {
  display: block;
  margin: 12px 0;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input,
select,
textarea,
button {
  width: 100%;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent), 0.35);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

input,
select,
textarea {
  background: var(--bg-input);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* :not(.login-input) : le login utilise un cadre sur le wrapper, pas d’anneau ici */
input:focus:not(.login-input),
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

button {
  cursor: pointer;
  background: rgba(var(--accent), 0.12);
  color: #b6f5cf;
  border: 1px solid rgba(var(--accent), 0.35);
  font-weight: 800;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

button:hover {
  background: rgba(var(--accent), 0.22);
  box-shadow: 0 0 24px rgba(37, 211, 102, 0.15);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: rgba(18, 140, 126, 0.15);
  color: #99f6e4;
  border-color: rgba(18, 140, 126, 0.4);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions button {
  width: auto;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.tab {
  width: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(var(--accent), 0.2);
}

.tab.active {
  background: rgba(var(--accent), 0.2);
  border-color: var(--wa);
  color: var(--text);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.space-between {
  justify-content: space-between;
}

/* ——— Shell app & menu ——— */
.app-shell {
  position: relative;
}

.global-left-menu {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 232px;
  z-index: 20;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(165deg, rgba(7, 15, 12, 0.97) 0%, rgba(5, 8, 7, 0.94) 100%);
  border-right: 1px solid rgba(37, 211, 102, 0.25);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.45);
}

.global-left-menu h2 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(37, 211, 102, 0.55);
}

.global-left-menu h2::after {
  content: "";
  display: block;
  margin-top: 8px;
  height: 1px;
  background: linear-gradient(90deg, var(--wa), transparent);
  opacity: 0.4;
}

.global-left-menu button.menu-item {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 12px 14px;
  min-height: 46px;
  text-align: left;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 800;
  color: var(--text) !important;
  background: rgba(0, 0, 0, 0.35) !important;
  border: 1px solid rgba(37, 211, 102, 0.22) !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.global-left-menu button.menu-item:hover {
  background: rgba(37, 211, 102, 0.1) !important;
  border-color: rgba(37, 211, 102, 0.5) !important;
}

.global-left-menu button.menu-item.active {
  background: rgba(37, 211, 102, 0.18) !important;
  border-color: var(--wa) !important;
  box-shadow:
    inset 0 0 0 1px rgba(37, 211, 102, 0.2),
    0 0 20px rgba(37, 211, 102, 0.12) !important;
  color: #fff !important;
}

.global-left-menu .menu-spacer {
  flex: 1 1 auto;
  min-height: 12px;
}

.global-left-menu .menu-logout-btn {
  appearance: none;
  display: block;
  width: 100%;
  padding: 11px 14px;
  min-height: 42px;
  text-align: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.global-left-menu .menu-logout-btn:hover {
  background: rgba(220, 60, 60, 0.16);
  border-color: rgba(220, 60, 60, 0.55);
  color: #ffd6d6;
}

html[data-theme="light"] .global-left-menu .menu-logout-btn {
  color: rgba(15, 26, 20, 0.72);
  background: rgba(15, 26, 20, 0.06);
  border-color: rgba(15, 26, 20, 0.12);
}

html[data-theme="light"] .global-left-menu .menu-logout-btn:hover {
  background: rgba(220, 60, 60, 0.10);
  border-color: rgba(220, 60, 60, 0.45);
  color: #8a1d1d;
}

.wa-deactivated {
  text-align: center;
  padding: 28px 22px;
}

.wa-deactivated h2 {
  color: var(--wa);
}

.wa-deactivated .actions {
  margin-top: 8px;
  display: flex;
  justify-content: center;
}

.app-main-area {
  margin-left: 248px;
  padding: 10px 4px 10px 0;
  min-width: 0;
}

.app-shell .card.app-main-card {
  max-width: min(1640px, calc(100vw - 272px));
  margin: 0;
  width: 100%;
}

.app-main-card {
  max-width: none;
  width: 100%;
}

.menu-content {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(37, 211, 102, 0.28);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* ——— Formulaires dans les cartes ——— */
.card form {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent), 0.3);
  background: rgba(0, 0, 0, 0.22);
}

.card form label {
  padding: 10px 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent), 0.18);
  background: rgba(0, 0, 0, 0.15);
}

.card form label + label {
  margin-top: 10px;
}

.card form button[type="submit"] {
  margin-top: 14px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  background: linear-gradient(180deg, var(--wa), var(--wa-teal)) !important;
  color: #041308 !important;
  border: 1px solid rgba(220, 248, 198, 0.35) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4), 0 0 28px rgba(37, 211, 102, 0.25);
}

.card form button[type="submit"]:hover {
  background: linear-gradient(180deg, var(--wa-hover), #0e9b87) !important;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45), 0 0 36px rgba(37, 211, 102, 0.3);
}

/* ——— Login ——— */
/* Pas de ::before sur la carte login : évite une ligne “inset” qui se superpose aux champs au repaint */
#session-content.login-card::before {
  content: none !important;
}

#session-content.login-card {
  max-width: 920px;
  margin: 48px auto;
  padding: 28px 28px 32px;
  border: 1px solid rgba(37, 211, 102, 0.4);
  outline: none !important;
  outline-width: 0 !important;
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(37, 211, 102, 0.1);
}

/* Carte + ancêtres : Edge/Windows dessine parfois un ÉNORME outline sur main/body au focus-within */
#session-content.login-card:focus-within,
#session-content.login-card:focus {
  outline: none !important;
  outline-width: 0 !important;
}

html:has(#session-content.login-card):focus-within,
body:has(#session-content.login-card):focus-within,
main.container:has(#session-content.login-card):focus-within {
  outline: none !important;
  outline-width: 0 !important;
}

/* Tout focus dans la carte (champs, bouton) : pas de second cadre navigateur */
#session-content.login-card :focus,
#session-content.login-card :focus-visible {
  outline: none !important;
  outline-width: 0 !important;
  outline-offset: 0 !important;
}

.login-header {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
}

.login-title {
  margin-top: 16px;
  font-size: 1.25rem;
}

.login-title::before {
  content: "// ";
  color: rgba(37, 211, 102, 0.45);
  font-weight: 700;
}

/* Labels séparés des champs (plus de <label><input>) : évite quirks focus navigateur */
#session-content.login-card form .login-label {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 16px 0 0 !important;
  border-radius: 0 !important;
}

#session-content.login-card form .login-label:first-of-type {
  margin-top: 0 !important;
}

#session-content.login-card form.login-form {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
  border: none !important;
  background: rgba(0, 0, 0, 0.35);
  outline: none !important;
  box-shadow: 0 0 40px rgba(37, 211, 102, 0.08);
}

/* Aucun changement du cadre formulaire quand un champ est focus */
#session-content.login-card form.login-form:focus-within {
  outline: none !important;
  border: none !important;
  box-shadow: 0 0 40px rgba(37, 211, 102, 0.08) !important;
}

/*
 * Login : un seul cadre — celui de l’<input> (plus de div wrapper).
 * L’outline navigateur est tracé *autour* du champ : avec un wrapper borduré,
 * ça donnait un second rectangle “plus grand” que overflow:hidden ne coupe pas.
 */
#session-content.login-card form label.login-label + input.login-input {
  margin-top: 8px !important;
}

#session-content.login-card form .login-input,
#session-content.login-card form .login-input:hover,
#session-content.login-card form .login-input:focus,
#session-content.login-card form .login-input:focus-visible,
#session-content.login-card form .login-input:active,
#session-content.login-card form .login-input:valid,
#session-content.login-card form .login-input:invalid,
#session-content.login-card form .login-input:required:invalid {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.55) !important;
  background-clip: padding-box !important;
  border: 1px solid rgba(37, 211, 102, 0.45) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  outline: none !important;
  outline-offset: 0 !important;
  transition: none !important;
  color: var(--text) !important;
  -webkit-tap-highlight-color: transparent;
}

#session-content.login-card form .login-input[type="password"] {
  padding-right: 40px;
}

#session-content.login-card form .login-input:-moz-focusring {
  outline: none !important;
}

#session-content.login-card form .login-input:-webkit-autofill,
#session-content.login-card form .login-input:-webkit-autofill:hover,
#session-content.login-card form .login-input:-webkit-autofill:focus,
#session-content.login-card form .login-input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border: 1px solid rgba(37, 211, 102, 0.45) !important;
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.55) inset !important;
  transition: background-color 99999s ease-out !important;
}

#session-content.login-card form input:focus,
#session-content.login-card form input:focus-visible,
#session-content.login-card form input:active {
  outline: none !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
}

#session-content.login-card form .login-input::-webkit-credentials-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
}

/* ——— Dropzone & fichiers ——— */
.dropzone-field {
  position: relative;
  margin: 16px 0;
}

.dropzone-field > .dropzone-label {
  display: block;
  margin-bottom: 8px;
}

.dropzone-label {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

.dropzone {
  border: 2px dashed rgba(37, 211, 102, 0.28);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover {
  border-color: rgba(37, 211, 102, 0.55);
  background: rgba(37, 211, 102, 0.06);
}

.dropzone.drag-over {
  border-color: var(--wa);
  background: rgba(37, 211, 102, 0.1);
}

.dropzone-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.dropzone-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.visually-hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wa-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wa-banner-ready {
  background: rgba(37, 211, 102, 0.10);
  border-color: rgba(37, 211, 102, 0.45);
  color: #c8f7d8;
}

.wa-banner-warn {
  background: rgba(220, 60, 60, 0.10);
  border-color: rgba(220, 60, 60, 0.50);
  color: #ffd6d6;
}

.wa-banner-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wa-banner-dot-ready {
  background: var(--wa);
  box-shadow: 0 0 8px rgba(37, 211, 102, 0.65);
}

.wa-banner-dot-warn {
  background: #ff5a5a;
  box-shadow: 0 0 8px rgba(255, 90, 90, 0.6);
  animation: wa-banner-pulse 1.4s ease-in-out infinite;
}

@keyframes wa-banner-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.wa-banner-label {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.wa-banner-ready .wa-banner-label {
  color: #6ee897;
}

.wa-banner-warn .wa-banner-label {
  color: #ff8a8a;
}

.wa-banner-sublabel {
  opacity: 0.85;
  flex: 1 1 220px;
  min-width: 0;
}

.wa-banner-sublabel code {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  font-size: 11px;
}

.wa-banner-action {
  appearance: none;
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(220, 60, 60, 0.7);
  background: rgba(220, 60, 60, 0.30);
  color: #ffe2e2;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wa-banner-action:hover {
  background: rgba(220, 60, 60, 0.55);
  border-color: rgba(255, 90, 90, 0.95);
  color: #ffffff;
}

html[data-wa-ready="0"] form button[type="submit"][data-send-btn],
html[data-wa-ready="0"] form button[type="submit"]:not([data-send-btn]) {
  opacity: 0.55;
  pointer-events: none;
  filter: grayscale(0.4);
}

html[data-wa-ready="0"] form button[type="submit"]::after {
  content: " — WA not ready";
  font-weight: 600;
  opacity: 0.85;
}

html[data-theme="light"] .wa-banner-ready {
  background: rgba(37, 211, 102, 0.10);
  border-color: rgba(18, 140, 126, 0.55);
  color: #06301d;
}

html[data-theme="light"] .wa-banner-ready .wa-banner-label {
  color: var(--wa-deep);
}

html[data-theme="light"] .wa-banner-warn {
  background: rgba(220, 60, 60, 0.06);
  border-color: rgba(220, 60, 60, 0.45);
  color: #6a1818;
}

html[data-theme="light"] .wa-banner-warn .wa-banner-label {
  color: #8a1d1d;
}

html[data-theme="light"] .wa-banner-action {
  background: rgba(220, 60, 60, 0.85);
  border-color: rgba(220, 60, 60, 0.95);
  color: #ffffff;
}

html[data-theme="light"] .wa-banner-action:hover {
  background: rgba(220, 60, 60, 0.95);
}

.bulk-job-card {
  border: 1px solid rgba(37, 211, 102, 0.28);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(37, 211, 102, 0.05), rgba(0, 0, 0, 0.18));
}

/* Compact "campaign in progress" chip shown at the top of the Bulk panel.
   Auto-polls every 5s; when present, click expands details into #bulk-results. */
#bulk-active-banner[data-has-job="0"] {
  display: none;
}

.bulk-active-chip {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 10px 0 14px;
  padding: 9px 14px;
  border: 1px solid rgba(37, 211, 102, 0.45);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.14), rgba(37, 211, 102, 0.06));
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

.bulk-active-chip:hover {
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.22), rgba(37, 211, 102, 0.10));
  border-color: rgba(37, 211, 102, 0.75);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.10);
}

.bulk-active-chip:active {
  transform: scale(0.995);
}

.bulk-active-chip-queued {
  border-color: rgba(255, 196, 0, 0.55);
  background: linear-gradient(90deg, rgba(255, 196, 0, 0.16), rgba(255, 196, 0, 0.05));
}

.bulk-active-chip-queued:hover {
  background: linear-gradient(90deg, rgba(255, 196, 0, 0.24), rgba(255, 196, 0, 0.08));
  border-color: rgba(255, 196, 0, 0.85);
  box-shadow: 0 0 0 3px rgba(255, 196, 0, 0.10);
}

.bulk-active-chip-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--wa);
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.85);
  animation: bulk-job-pulse 1s ease-in-out infinite;
}

.bulk-active-chip-queued .bulk-active-chip-dot {
  background: #ffd34a;
  box-shadow: 0 0 12px rgba(255, 196, 0, 0.7);
}

.bulk-active-chip-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.bulk-active-chip-stats {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.bulk-active-chip-pct {
  margin-left: 4px;
  opacity: 0.7;
}

.bulk-active-chip-cta {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.75;
  white-space: nowrap;
}

.bulk-active-chip:hover .bulk-active-chip-cta {
  opacity: 1;
}

html[data-theme="light"] .bulk-active-chip {
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.12), rgba(37, 211, 102, 0.04));
  border-color: rgba(37, 211, 102, 0.55);
}

html[data-theme="light"] .bulk-active-chip:hover {
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.20), rgba(37, 211, 102, 0.08));
}

html[data-theme="light"] .bulk-active-chip-queued {
  background: linear-gradient(90deg, rgba(255, 170, 0, 0.16), rgba(255, 170, 0, 0.04));
  border-color: rgba(255, 170, 0, 0.65);
}

.bulk-job-card.bulk-job-status-cancelled {
  border-color: rgba(220, 60, 60, 0.45);
  background: linear-gradient(180deg, rgba(220, 60, 60, 0.05), rgba(0, 0, 0, 0.18));
}

.bulk-job-card.bulk-job-status-done {
  border-color: rgba(37, 211, 102, 0.55);
}

.bulk-job-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.bulk-job-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.bulk-job-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.bulk-job-status-pill-running {
  background: rgba(37, 211, 102, 0.18);
  color: var(--wa);
  border-color: rgba(37, 211, 102, 0.55);
}

.bulk-job-status-pill-queued {
  background: rgba(255, 196, 0, 0.16);
  color: #ffd34a;
  border-color: rgba(255, 196, 0, 0.55);
}

.bulk-job-status-pill-done {
  background: rgba(37, 211, 102, 0.20);
  color: #6ee897;
  border-color: rgba(37, 211, 102, 0.7);
}

.bulk-job-status-pill-cancelled {
  background: rgba(220, 60, 60, 0.18);
  color: #ff8a8a;
  border-color: rgba(220, 60, 60, 0.55);
}

.bulk-job-spinner {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wa);
  box-shadow: 0 0 10px rgba(37, 211, 102, 0.85);
  animation: bulk-job-pulse 1s ease-in-out infinite;
}

@keyframes bulk-job-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.55); opacity: 0.45; }
}

.bulk-job-id code {
  font-size: 10.5px;
  opacity: 0.55;
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.08);
}

.bulk-job-stop-btn {
  appearance: none;
  margin-left: auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(220, 60, 60, 0.7);
  background: rgba(220, 60, 60, 0.30);
  color: #ffe2e2;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.bulk-job-stop-btn:hover {
  background: rgba(220, 60, 60, 0.55);
  border-color: rgba(255, 90, 90, 0.95);
  color: #ffffff;
}

.bulk-job-stop-btn:active {
  transform: scale(0.97);
}

.bulk-job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.bulk-job-resume-btn {
  appearance: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(37, 211, 102, 0.75);
  background: rgba(37, 211, 102, 0.22);
  color: #d7ffe6;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.bulk-job-resume-btn:hover {
  background: rgba(37, 211, 102, 0.42);
  border-color: rgba(37, 211, 102, 0.95);
  color: #ffffff;
}

.bulk-job-resume-btn:active {
  transform: scale(0.97);
}

.bulk-job-progress-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.30);
  overflow: hidden;
  margin: 4px 0 10px;
}

.bulk-job-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wa), var(--wa-hover));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 8px rgba(37, 211, 102, 0.6);
}

.bulk-job-status-cancelled .bulk-job-progress-fill {
  background: linear-gradient(90deg, #c54040, #8a1d1d);
  box-shadow: 0 0 8px rgba(220, 60, 60, 0.6);
}

.bulk-job-stats {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.bulk-job-stats strong {
  color: var(--text);
}

.bulk-job-stat-sep {
  margin: 0 6px;
  opacity: 0.4;
}

.bulk-job-stat-success { color: var(--wa); font-weight: 700; }
.bulk-job-stat-error { color: #ff8a8a; font-weight: 700; }
.bulk-job-stat-pct { color: var(--text); font-weight: 700; }

/* While a bulk campaign is running, mute the form's Send button so users don't
   queue a second job in parallel. The "Stop campaign" button stays clickable. */
html[data-bulk-running="1"] form button[type="submit"][data-send-btn] {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(0.4);
}

html[data-bulk-running="1"] form button[type="submit"][data-send-btn]::after {
  content: " — campaign in progress";
  font-weight: 600;
  opacity: 0.85;
}

html[data-theme="light"] .bulk-job-card {
  background: rgba(37, 211, 102, 0.06);
  border-color: rgba(18, 140, 126, 0.45);
}

html[data-theme="light"] .bulk-job-id code {
  background: rgba(15, 26, 20, 0.06);
  border-color: rgba(15, 26, 20, 0.10);
  color: rgba(15, 26, 20, 0.6);
}

html[data-theme="light"] .bulk-job-status-pill-running {
  color: var(--wa-deep);
}

html[data-theme="light"] .bulk-job-status-pill-cancelled {
  color: #8a1d1d;
}

html[data-theme="light"] .bulk-job-stop-btn {
  background: rgba(220, 60, 60, 0.85);
  border-color: rgba(220, 60, 60, 0.95);
  color: #ffffff;
}

.bulk-errors-box {
  margin: 14px 0 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(220, 60, 60, 0.10);
  border: 1px solid rgba(220, 60, 60, 0.45);
  color: #ffd6d6;
}

.bulk-errors-title {
  margin: 0 0 8px;
  color: #ff8a8a;
  font-weight: 700;
  font-size: 13px;
}

.bulk-errors-list {
  margin: 0 0 6px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bulk-errors-list li {
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.bulk-errors-count {
  display: inline-block;
  min-width: 32px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(220, 60, 60, 0.30);
  color: #ffe2e2;
  font-weight: 800;
  font-size: 11px;
  text-align: center;
}

.bulk-errors-detail {
  color: #ffe6e6;
  font-weight: 600;
}

.bulk-errors-example {
  color: rgba(255, 220, 220, 0.62);
  font-size: 12px;
}

.bulk-errors-example code {
  background: rgba(255, 200, 200, 0.10);
  border-color: rgba(255, 200, 200, 0.20);
  color: #ffe2e2;
}

.bulk-errors-hint {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 196, 0, 0.10);
  border: 1px solid rgba(255, 196, 0, 0.35);
  color: #ffe1a1;
  font-size: 12.5px;
  line-height: 1.45;
}

html[data-theme="light"] .bulk-errors-box {
  background: rgba(220, 60, 60, 0.07);
  border-color: rgba(220, 60, 60, 0.45);
  color: #6a1818;
}

html[data-theme="light"] .bulk-errors-title {
  color: #8a1d1d;
}

html[data-theme="light"] .bulk-errors-detail {
  color: #4a0f0f;
}

html[data-theme="light"] .bulk-errors-count {
  background: rgba(220, 60, 60, 0.85);
  color: #ffffff;
}

html[data-theme="light"] .bulk-errors-example {
  color: rgba(74, 15, 15, 0.7);
}

html[data-theme="light"] .bulk-errors-hint {
  background: rgba(255, 196, 0, 0.18);
  border-color: rgba(213, 138, 0, 0.5);
  color: #6b4500;
}

.bulk-file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  margin: 4px 0 14px;
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid rgba(37, 211, 102, 0.32);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(37, 211, 102, 0.04);
}

.bulk-file-chip-icon {
  flex-shrink: 0;
  color: var(--wa);
}

.bulk-file-chip-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.bulk-file-chip-sep {
  opacity: 0.45;
}

.bulk-file-chip-rows {
  color: var(--text-muted);
  white-space: nowrap;
}

.bulk-file-chip-rows strong {
  color: var(--text);
}

.bulk-file-chip-remove {
  appearance: none;
  margin-left: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(220, 60, 60, 0.45);
  background: rgba(220, 60, 60, 0.18);
  color: #ffb4b4;
  font-size: 16px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
}

.bulk-file-chip-remove:hover {
  background: rgba(220, 60, 60, 0.4);
  border-color: rgba(255, 90, 90, 0.85);
  color: #ffffff;
}

.bulk-file-chip-remove:active {
  transform: scale(0.92);
}

html[data-theme="light"] .bulk-file-chip {
  background: rgba(37, 211, 102, 0.08);
  border-color: rgba(18, 140, 126, 0.45);
  color: #0f1a14;
}

html[data-theme="light"] .bulk-file-chip-icon {
  color: var(--wa-deep);
}

html[data-theme="light"] .bulk-file-chip-rows {
  color: rgba(15, 26, 20, 0.6);
}

html[data-theme="light"] .bulk-file-chip-rows strong {
  color: #0f1a14;
}

html[data-theme="light"] .bulk-file-chip-remove {
  background: rgba(220, 60, 60, 0.10);
  border-color: rgba(220, 60, 60, 0.45);
  color: #8a1d1d;
}

html[data-theme="light"] .bulk-file-chip-remove:hover {
  background: rgba(220, 60, 60, 0.85);
  color: #ffffff;
  border-color: rgba(220, 60, 60, 0.95);
}

.selected-file-name {
  margin-top: 8px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.bulk-campaign-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.bulk-campaign-field {
  flex: 1 1 auto;
  margin: 0;
}

.bulk-campaign-action-wrap {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
}

.bulk-use-as-sender-btn {
  min-width: 180px;
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.bulk-use-as-sender-btn.bulk-use-as-sender-active {
  background: rgba(var(--accent), 0.24);
  border-color: rgba(var(--accent), 0.55);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(37, 211, 102, 0.16);
}

@media (max-width: 720px) {
  .bulk-campaign-row {
    flex-wrap: wrap;
  }
  .bulk-campaign-field {
    flex-basis: 100%;
  }
}

textarea.message-with-image-drop {
  min-height: 120px;
}

.message-char-counter {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-align: right;
}

.message-char-counter--warn {
  color: #fbbf24;
}

.message-char-counter--over {
  color: #fecaca;
}

textarea.textarea-drag-active {
  outline: 2px dashed var(--wa);
  outline-offset: 2px;
  background: rgba(37, 211, 102, 0.06);
}

.image-preview-wrap {
  margin-top: 10px;
}

.image-preview-wrap.hidden {
  display: none !important;
}

.image-preview-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.image-preview-thumb {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid rgba(37, 211, 102, 0.35);
  background: #0a0f0c;
}

.image-preview-remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 22px;
  font-size: 14px;
  font-weight: 800;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  border: 1px solid rgba(37, 211, 102, 0.35);
  cursor: pointer;
}

.image-preview-remove:hover {
  background: #b91c1c;
  border-color: #fecaca;
  color: #fff;
}

button[data-send-btn] .send-loading-label {
  display: none;
}

button[data-send-btn].htmx-request .send-idle-label,
button[data-send-btn].is-sending .send-idle-label {
  display: none;
}

button[data-send-btn].htmx-request .send-loading-label,
button[data-send-btn].is-sending .send-loading-label {
  display: inline;
}

button[data-send-btn].htmx-request,
button[data-send-btn].is-sending {
  opacity: 0.88;
  cursor: wait;
  pointer-events: none;
}

/* ——— QR & progress ——— */
#qr-box {
  margin: 16px 0;
  text-align: center;
}

.activation-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 20px 0 8px;
  padding: 24px 16px;
  border-radius: var(--radius);
  border: 1px dashed rgba(37, 211, 102, 0.35);
  background: rgba(37, 211, 102, 0.04);
}

.session-loading-shell {
  min-height: 220px;
}

#qr-image {
  width: 280px;
  height: 280px;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px;
  border: 4px solid var(--wa);
  box-shadow: 0 0 32px rgba(37, 211, 102, 0.25);
}

.progress-wrap {
  margin: 12px 0;
}

progress {
  width: 100%;
  height: 18px;
  accent-color: var(--wa);
}

/* ——— Table / historique ——— */
.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(37, 211, 102, 0.3);
  box-shadow: var(--shadow-glow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.history-actions {
  margin-top: 8px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.history-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-toolbar .history-actions {
  margin-top: 0;
  margin-left: auto;
}

.history-filter {
  display: inline-flex;
  gap: 0;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(37, 211, 102, 0.22);
}

.history-filter-btn {
  appearance: none;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.history-filter-btn:hover {
  color: var(--text);
  background: rgba(37, 211, 102, 0.06);
}

.history-filter-btn.active {
  background: rgba(37, 211, 102, 0.18);
  color: #fff;
  border-color: rgba(37, 211, 102, 0.55);
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.20);
}

html[data-theme="light"] .history-filter {
  background: rgba(15, 26, 20, 0.05);
  border-color: rgba(18, 140, 126, 0.32);
}

html[data-theme="light"] .history-filter-btn {
  color: rgba(15, 26, 20, 0.6);
}

html[data-theme="light"] .history-filter-btn:hover {
  color: #0f1a14;
  background: rgba(37, 211, 102, 0.10);
}

html[data-theme="light"] .history-filter-btn.active {
  background: linear-gradient(180deg, var(--wa) 0%, var(--wa-hover) 100%);
  color: #ffffff;
  border-color: var(--wa-teal);
}

.history-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.history-stat {
  min-width: 180px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.12), rgba(0, 0, 0, 0.35));
  border: 1px solid rgba(37, 211, 102, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.history-stat-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.history-stat-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--wa);
  text-shadow: 0 0 16px rgba(37, 211, 102, 0.35);
}

.table-wrap table {
  border-radius: var(--radius);
  overflow: hidden;
}

.history-campaigns-table {
  width: 100%;
  table-layout: auto;
}

.history-campaigns-table .col-timestamp {
  white-space: nowrap;
  width: 1%;
}

.history-campaigns-table .col-sent,
.history-campaigns-table .col-errors {
  min-width: 4.75rem;
  padding-left: 14px;
  padding-right: 14px;
}

.history-campaigns-table .col-action {
  width: 1%;
  white-space: nowrap;
  padding-left: 12px;
  padding-right: 12px;
}

.history-col-delete {
  width: 36px;
  padding-left: 4px !important;
  padding-right: 4px !important;
  text-align: center;
  vertical-align: middle;
}

.history-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.history-delete-btn:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: rgba(239, 68, 68, 0.65);
}

html[data-theme="light"] .history-delete-btn {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(220, 38, 38, 0.35);
}

html[data-theme="light"] .history-delete-btn:hover {
  background: rgba(239, 68, 68, 0.18);
}

thead th {
  background: rgba(7, 94, 84, 0.45);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:nth-child(odd) td {
  background: rgba(0, 0, 0, 0.2);
}

tbody tr:hover td {
  background: rgba(37, 211, 102, 0.08);
}

th,
td {
  border: 1px solid rgba(37, 211, 102, 0.18);
  padding: 10px;
  text-align: left;
}

.download-csv-link {
  display: inline-block;
  margin-top: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  text-decoration: none;
  background: linear-gradient(180deg, #f59e0b, #d97706);
  color: #1a0f00;
  border: 1px solid rgba(251, 191, 36, 0.5);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.download-csv-link:hover {
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
}

.download-csv-link-btn {
  appearance: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

/* Make the two yellow History action buttons share the same row and width. */
.history-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.history-actions > .download-csv-link {
  margin-top: 0;
  margin-left: 0 !important;
  min-width: 180px;
  text-align: center;
  box-sizing: border-box;
  line-height: 1.2;
  white-space: nowrap;
}

/* On narrow screens the toolbar wraps, but the two yellow buttons stay
   side-by-side so they always look like a paired action group. */
@media (max-width: 720px) {
  .history-toolbar-left {
    width: 100%;
  }
  .history-actions {
    width: 100%;
    justify-content: stretch;
  }
  .history-actions > .download-csv-link {
    flex: 1 1 0;
    min-width: 0;
  }
}

.bulk-preflight-card {
  width: min(520px, calc(100vw - 32px));
  max-height: min(85vh, 720px);
  overflow: auto;
}

.bulk-preflight-stats {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.bulk-preflight-stats li {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bulk-preflight-stats li.warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.bulk-preflight-stat-label {
  flex: 1 1 160px;
  color: var(--text-muted);
  font-size: 13px;
}

.bulk-preflight-stat-value {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.bulk-preflight-stat-value.ok {
  color: #86efac;
}

.bulk-preflight-sample {
  margin: 0 0 12px;
  font-size: 13px;
}

.bulk-preflight-sample-title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text-muted);
}

.bulk-preflight-sample ul {
  margin: 0;
  padding-left: 18px;
}

.bulk-preflight-sample li {
  margin: 2px 0;
}

.bulk-preflight-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  vertical-align: middle;
}

.bulk-preflight-chip.warn {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.bulk-preflight-chip.ok {
  background: rgba(134, 239, 172, 0.12);
  color: #86efac;
}

.bulk-preflight-review-btn {
  font-size: 13px;
  padding: 4px 10px;
}

.bulk-job-stat-skipped {
  color: #fcd34d;
}

.ok-line {
  color: #86efac;
}

/* Sheet email modal */
.sheet-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 12, 9, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: sheetModalFadeIn 0.14s ease-out;
}

@keyframes sheetModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-modal-card {
  width: min(440px, calc(100vw - 32px));
  background: linear-gradient(180deg, #0e1612 0%, #0a120e 100%);
  border: 1px solid rgba(37, 211, 102, 0.32);
  border-radius: 14px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(37, 211, 102, 0.08) inset;
  padding: 22px 22px 18px;
  color: var(--text);
  animation: sheetModalPop 0.16s ease-out;
}

@keyframes sheetModalPop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.sheet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sheet-modal-header h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.sheet-modal-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.sheet-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.sheet-modal-text {
  margin: 4px 0 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.sheet-modal-form label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sheet-modal-form input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(37, 211, 102, 0.28);
  background: rgba(0, 0, 0, 0.42);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.sheet-modal-form input[type="email"]:focus {
  border-color: var(--wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

.sheet-modal-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.32);
  color: #fecaca;
  font-size: 12.5px;
}

.sheet-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.sheet-modal-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.sheet-modal-btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.10);
  color: var(--text-muted);
}

.sheet-modal-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.sheet-modal-btn-primary {
  background: linear-gradient(180deg, var(--wa) 0%, var(--wa-hover) 100%);
  color: #04130a;
  border-color: var(--wa-teal);
}

.sheet-modal-btn-primary:hover {
  filter: brightness(1.06);
}

html[data-theme="light"] .sheet-modal {
  background: rgba(15, 26, 20, 0.40);
}

html[data-theme="light"] .sheet-modal-card {
  background: #ffffff;
  border-color: rgba(18, 140, 126, 0.28);
  color: #0f1a14;
  box-shadow:
    0 20px 50px rgba(15, 26, 20, 0.18),
    0 0 0 1px rgba(18, 140, 126, 0.06) inset;
}

html[data-theme="light"] .sheet-modal-text {
  color: rgba(15, 26, 20, 0.62);
}

html[data-theme="light"] .sheet-modal-form input[type="email"] {
  background: #f6fbf8;
  color: #0f1a14;
  border-color: rgba(18, 140, 126, 0.32);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(var(--accent), 0.3);
  background: rgba(0, 0, 0, 0.3);
}

.status-badge.status-sent {
  color: #bbf7d0;
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.4);
}

.status-badge.status-received {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.15);
}

.status-badge.status-error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.15);
}

.status-badge.status-pending {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.35);
}

.status-badge.status-muted {
  color: #cbd5e1;
  background: rgba(120, 120, 120, 0.18);
  border-color: rgba(148, 163, 184, 0.28);
}

.error {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(127, 29, 29, 0.3);
  color: #fecaca;
}

#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: none;
  max-width: 380px;
  border: 1px solid rgba(37, 211, 102, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 24px rgba(37, 211, 102, 0.15);
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

@media (max-width: 900px) {
  .global-left-menu {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(37, 211, 102, 0.2);
    border-radius: var(--radius);
    margin-bottom: 12px;
  }

  .app-main-area {
    margin-left: 0;
    padding: 0;
  }

  .app-shell .card.app-main-card {
    max-width: 100%;
  }
}

/* ─────────── Theme toggle button ─────────── */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(37, 211, 102, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--wa);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, color 0.15s ease;
}

.theme-toggle:hover {
  background: rgba(37, 211, 102, 0.18);
  border-color: var(--wa);
  box-shadow: 0 0 18px rgba(37, 211, 102, 0.18);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-icon {
  display: inline-block;
}

.theme-icon-sun {
  display: none;
}

html[data-theme="light"] .theme-icon-moon {
  display: none;
}

html[data-theme="light"] .theme-icon-sun {
  display: inline-block;
}

/* ─────────── Light theme overrides ─────────── */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f4;
  --bg-elevated: #ffffff;
  --bg-input: rgba(255, 255, 255, 0.95);
  --text: #0f1a14;
  --text-muted: rgba(15, 26, 20, 0.62);
  --shadow-glow: 0 6px 24px rgba(37, 211, 102, 0.18);
}

html[data-theme="light"] body {
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 500px at 15% -20%, rgba(37, 211, 102, 0.18), transparent 55%),
    radial-gradient(ellipse 700px 400px at 100% 30%, rgba(18, 140, 126, 0.10), transparent 50%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 50%, #e7eee9 100%);
}

html[data-theme="light"] body::before {
  opacity: 0.025;
  mix-blend-mode: multiply;
}

html[data-theme="light"] .card,
html[data-theme="light"] .card.app-main-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(37, 211, 102, 0.30);
  box-shadow: 0 10px 30px rgba(15, 26, 20, 0.08);
}

html[data-theme="light"] .topbar {
  border-bottom: 1px solid rgba(37, 211, 102, 0.25);
}

html[data-theme="light"] .brand-title {
  text-shadow: none;
  color: var(--wa-deep);
}

html[data-theme="light"] .brand-subtitle {
  color: var(--wa-teal);
}

html[data-theme="light"] .brand-subtitle::before {
  color: rgba(18, 140, 126, 0.6);
}

html[data-theme="light"] .brand-logo {
  filter: drop-shadow(0 0 8px rgba(37, 211, 102, 0.35));
}

html[data-theme="light"] .global-left-menu {
  background: linear-gradient(180deg, #ffffff 0%, #f3f6f4 100%);
  border-right: 1px solid rgba(37, 211, 102, 0.25);
}

html[data-theme="light"] .global-left-menu h2,
html[data-theme="light"] .global-left-menu h2::after {
  color: var(--wa-teal);
}

html[data-theme="light"] .global-left-menu button.menu-item {
  background: rgba(37, 211, 102, 0.08);
  color: var(--text);
  border: 1px solid rgba(37, 211, 102, 0.25);
}

html[data-theme="light"] .global-left-menu button.menu-item:hover {
  background: rgba(37, 211, 102, 0.15);
}

html[data-theme="light"] .global-left-menu button.menu-item.active {
  background: linear-gradient(180deg, var(--wa) 0%, var(--wa-hover) 100%);
  color: #ffffff;
  border-color: var(--wa-teal);
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: var(--bg-input) !important;
  color: var(--text) !important;
  border-color: rgba(37, 211, 102, 0.4) !important;
}

html[data-theme="light"] button {
  background: rgba(37, 211, 102, 0.10);
  color: var(--wa-deep);
  border-color: rgba(37, 211, 102, 0.4);
}

html[data-theme="light"] button:hover {
  background: rgba(37, 211, 102, 0.18);
  box-shadow: 0 0 14px rgba(37, 211, 102, 0.18);
}

/* Keep the WA deactivate button red in light mode too. */
html[data-theme="light"] .logout-btn {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(180deg, rgba(185, 28, 28, 0.92), rgba(127, 29, 29, 0.96));
  color: #fee2e2;
  box-shadow: 0 10px 22px rgba(185, 28, 28, 0.22);
}

html[data-theme="light"] .logout-btn:hover {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.25);
}

html[data-theme="light"] .tab {
  background: rgba(15, 26, 20, 0.05);
  color: var(--text);
}

html[data-theme="light"] .history-stat {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.12), rgba(255, 255, 255, 0.7));
  color: var(--text);
  border-color: rgba(37, 211, 102, 0.3);
}

html[data-theme="light"] .status-badge.status-sent {
  background: rgba(37, 211, 102, 0.18);
  color: var(--wa-deep);
}

html[data-theme="light"] .status-badge.status-received {
  background: rgba(245, 158, 11, 0.18);
  color: #92400e;
}

html[data-theme="light"] .status-badge.status-error {
  background: rgba(239, 68, 68, 0.18);
  color: #991b1b;
}

html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.85);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
}

html[data-theme="light"] .theme-toggle:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: #f59e0b;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.2);
}

/* ─────────── Admin panel ─────────── */
.admin-card {
  max-width: 1100px;
  margin: 18px auto;
  padding: 18px;
}

/* When the admin panel is active, expand the main card to give the wide
   users table more horizontal room and avoid the horizontal scrollbar.
   :has() is the modern (no-JS) way to scope this to admin views only. */
.app-main-card:has(.admin-section) {
  max-width: 1640px;
}

.app-main-card:has(.admin-section) .menu-content {
  padding: 14px;
}

.admin-section {
  margin-top: 4px;
}

.admin-section-title {
  margin: 18px 0 10px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wa);
}

.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(37, 211, 102, 0.22);
  background: rgba(0, 0, 0, 0.25);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

.admin-table th,
.admin-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(37, 211, 102, 0.12);
  vertical-align: middle;
}

.admin-table thead th {
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(37, 211, 102, 0.25);
  white-space: nowrap;
}

.admin-th-break {
  display: inline-block;
  line-height: 1.15;
  white-space: normal;
}

.admin-table tbody tr:hover {
  background: rgba(37, 211, 102, 0.04);
}

.admin-table code {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 6px;
  border-radius: 4px;
}

.admin-col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.admin-col-actions .admin-action {
  padding: 5px 9px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  border-radius: 6px;
  margin-left: 4px;
}

.admin-col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
}

.admin-section .history-header {
  margin-bottom: 18px;
}

.admin-stats-global {
  flex-wrap: nowrap;
  gap: 8px;
}

.admin-stats-global .history-stat {
  min-width: 0;
  flex: 1 1 0;
  padding: 8px 11px;
}

.admin-stats-global .history-stat-label {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-stats-global .history-stat-value {
  font-size: 18px;
}

@media (max-width: 900px) {
  .admin-stats-global {
    flex-wrap: wrap;
  }
}

.admin-stats-hint {
  margin: 10px 0 14px;
  font-size: 11px;
  line-height: 1.45;
}

.admin-stats-hint code {
  font-size: 11px;
  padding: 1px 4px;
}

.admin-user-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.admin-user-link .admin-customer-code {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.01em;
}

.admin-user-link .admin-customer-code-unknown {
  color: var(--text-muted);
  font-weight: 600;
  font-style: italic;
}

.admin-user-link .admin-client-id-hint {
  font-size: 10px;
  opacity: 0.55;
}

.admin-user-link .admin-client-id-hint code {
  font-size: 10px;
  padding: 0 4px;
  background: rgba(37, 211, 102, 0.06);
  border: 1px solid rgba(37, 211, 102, 0.16);
}

.admin-user-link:hover .admin-customer-code {
  color: var(--wa);
}

.admin-user-link:hover .admin-client-id-hint {
  opacity: 0.85;
}

html[data-theme="light"] .admin-user-link:hover .admin-customer-code {
  color: var(--wa-deep);
}

.role-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.role-badge.role-superadmin {
  background: linear-gradient(135deg, rgba(255, 196, 0, 0.18), rgba(255, 155, 0, 0.10));
  color: #ffd34a;
  border-color: rgba(255, 196, 0, 0.45);
}

.role-badge.role-admin {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.22), rgba(18, 140, 126, 0.18));
  color: #4ade80;
  border-color: rgba(37, 211, 102, 0.55);
}

.role-badge.role-user {
  background: rgba(120, 130, 145, 0.14);
  color: #cbd5e1;
  border-color: rgba(120, 130, 145, 0.35);
}

html[data-theme="light"] .role-badge.role-superadmin {
  background: linear-gradient(135deg, rgba(213, 138, 0, 0.18), rgba(170, 110, 0, 0.10));
  color: #8a5a00;
  border-color: rgba(213, 138, 0, 0.55);
}

html[data-theme="light"] .role-badge.role-admin {
  background: linear-gradient(135deg, rgba(18, 140, 126, 0.18), rgba(37, 211, 102, 0.14));
  color: var(--wa-deep);
  border-color: rgba(18, 140, 126, 0.55);
}

html[data-theme="light"] .role-badge.role-user {
  background: rgba(15, 26, 20, 0.06);
  color: rgba(15, 26, 20, 0.7);
  border-color: rgba(15, 26, 20, 0.18);
}

.admin-action {
  width: auto;
  margin: 0 4px 0 0;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: #b6f5cf;
  cursor: pointer;
}

.admin-action:hover {
  background: rgba(37, 211, 102, 0.22);
}

.admin-always-toggle {
  cursor: pointer;
}

.admin-always-toggle:hover {
  filter: brightness(1.08);
}

.admin-action-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.admin-action-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

html[data-theme="light"] .admin-table-wrap {
  background: #ffffff;
  border-color: rgba(37, 211, 102, 0.25);
}

html[data-theme="light"] .admin-table thead th {
  background: rgba(37, 211, 102, 0.08);
  color: var(--wa-deep);
}

html[data-theme="light"] .admin-table code {
  background: rgba(15, 26, 20, 0.06);
}

html[data-theme="light"] .admin-action {
  color: var(--wa-deep);
}

/* Keep the danger button visibly red on light background. The generic
 * `html[data-theme="light"] .admin-action` rule above would otherwise
 * override `.admin-action-danger`'s color (same specificity, declared
 * later in source order). */
html[data-theme="light"] .admin-action-danger {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(220, 38, 38, 0.55);
  color: #b91c1c;
}

html[data-theme="light"] .admin-action-danger:hover {
  background: rgba(239, 68, 68, 0.20);
  border-color: rgba(220, 38, 38, 0.8);
  color: #991b1b;
}

/* Sidebar admin section */
.menu-divider {
  height: 1px;
  margin: 14px 4px 8px;
  background: linear-gradient(90deg, transparent, rgba(37, 211, 102, 0.35), transparent);
}

.menu-section-title {
  margin: 0 4px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-item-admin {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.30);
  color: #fde68a;
}

.menu-item-admin:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.18);
}

.menu-item-admin.active {
  background: linear-gradient(180deg, #f59e0b, #d97706) !important;
  color: #1a1a1a !important;
  border-color: #f59e0b !important;
}

html[data-theme="light"] .menu-item-admin {
  background: rgba(245, 158, 11, 0.10);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.4);
}

html[data-theme="light"] .menu-item-admin.active {
  color: #ffffff !important;
}
