:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #08080c;
  --bg-2: #0c0c12;
  --bg-elevated: #0f0f16;
  --panel: #12121a;
  --panel-2: #18181f;
  --panel-3: #1f1f28;
  --text: #f1f1f6;
  --text-secondary: #c8c8d4;
  --muted: #9898a8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #ff3d6a;
  --accent-soft: rgba(255, 61, 106, 0.14);
  --red: #c91538;
  --red-2: #ff3d6a;
  --red-dark: #5c0d1f;
  --purple: #7b3cff;
  --purple-2: #a66eff;
  --green: #1ea86a;
  --yellow: #d5a11a;
  --orange: #f08a24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow: var(--shadow-md);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  /* Boutons / champs : même rayon sur toute l’app */
  --radius-control: 12px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Mobile : cibles tactiles confortables (réf. ~44px) */
  --mobile-touch-sm: 42px;
  --mobile-touch-md: 46px;

  --sticky-left-1: 72px;
  --sticky-left-2: 420px;
  --sticky-right-1: 150px;

  --sticky-completed-left: 72px;
  --sticky-completed-action: 150px;

  /* Empilement : jamais de chevauchement imprévisible */
  --z-sticky-band: 85;
  --z-topbar-app: 100;
  --z-toast-app: 180;
  --z-drawer-backdrop: 260;
  --z-drawer-panel: 270;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
  min-height: 100%;
  background-color: var(--bg);
  /* Fond global (html seul : évite de superposer deux fois les calques sur body) */
  background-image:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.055) 1px, transparent 1.6px),
    repeating-linear-gradient(
      118deg,
      transparent 0,
      transparent 76px,
      rgba(255, 61, 106, 0.022) 76px,
      rgba(255, 61, 106, 0.022) 77px
    ),
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(255, 61, 106, 0.1), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(123, 60, 255, 0.065), transparent 45%),
    radial-gradient(ellipse 60% 48% at 8% 92%, rgba(123, 60, 255, 0.055), transparent 52%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 55%, #0a0a0f 100%);
  background-size:
    36px 36px,
    auto,
    auto,
    auto,
    auto,
    auto;
  background-position:
    0 0,
    0 0,
    center top,
    100% 0,
    0% 100%,
    center;
  background-attachment: fixed;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

::selection {
  background: rgba(255, 61, 106, 0.35);
  color: #fff;
}

/* Scrollbars — zones scrollables principales */
.results-wrap,
.completed-wrap,
.downloads-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) rgba(0, 0, 0, 0.2);
}

.results-wrap::-webkit-scrollbar,
.completed-wrap::-webkit-scrollbar,
.downloads-wrap::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.results-wrap::-webkit-scrollbar-track,
.completed-wrap::-webkit-scrollbar-track,
.downloads-wrap::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
}

.results-wrap::-webkit-scrollbar-thumb,
.completed-wrap::-webkit-scrollbar-thumb,
.downloads-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.results-wrap::-webkit-scrollbar-thumb:hover,
.completed-wrap::-webkit-scrollbar-thumb:hover,
.downloads-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
  background-clip: padding-box;
}

h1, h2, h3, p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  min-height: 64px;
  border-bottom: 1px solid var(--border-strong);
  background: rgba(15, 15, 22, 0.92);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow-sm);
}

.portal-title {
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  position: relative;
  display: inline-block;
  padding-bottom: 4px;
}

.portal-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.75rem;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red-2) 0%, rgba(255, 61, 106, 0.2) 100%);
}

.topbar-left {
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(460px, 1fr);
  gap: 20px;
  padding: 20px 22px 28px;
  max-width: 1920px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: linear-gradient(165deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  transition:
    transform 0.2s var(--ease-out),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.065);
}

.search-panel {
  padding: 20px 22px;
  min-width: 0;
}

.completed-panel {
  padding: 20px 22px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-head-main {
  flex: 1;
  min-width: 0;
}

.panel-mobile-toggle {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  align-self: flex-start;
}

.panel-head-spacious.panel-head,
.panel-head.compact.panel-head-spacious {
  align-items: flex-start;
}

.panel-head.compact:not(.panel-head-spacious) {
  align-items: center;
}

.mobile-panel-section {
  display: block;
}

.panel-mobile-body {
  display: block;
}

@media (min-width: 761px) {
  .mobile-panel-section {
    display: contents;
  }

  .panel-mobile-body {
    display: contents;
  }

  .panel-mobile-toggle {
    display: none !important;
  }
}

.panel-head h2 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.panel-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
  max-width: 52ch;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  margin-bottom: 14px;
}

.search-main,
.search-side {
  display: flex;
  gap: 10px;
}

.search-main input {
  flex: 1;
}

.search-side select,
.search-side button {
  flex: 1;
}

input,
button,
.btn,
a.download-link {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elevated);
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease),
    transform 0.18s var(--ease);
}

select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text);
  background-color: var(--bg-elevated);
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background-color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

select:not([multiple]) {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  min-height: 0;
  border-radius: 6px;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

input:focus,
select:focus {
  outline: none;
}

input:focus-visible,
select:focus-visible {
  border-color: rgba(255, 61, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 61, 106, 0.18);
}

button:focus:not(:focus-visible),
.btn:focus:not(:focus-visible) {
  outline: none;
}

button:focus-visible,
.btn:focus-visible,
a.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 61, 106, 0.22);
}

button {
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 42px;
  box-sizing: border-box;
}

.btn-with-icon {
  gap: 8px;
}

.btn-with-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background-color: currentColor;
  opacity: 0.9;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.icon-back::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M13.83 19a1 1 0 0 1-.71-.29l-6-6a1 1 0 0 1 0-1.42l6-6a1 1 0 1 1 1.42 1.42L9.24 12l5.3 5.29A1 1 0 0 1 13.83 19Z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M13.83 19a1 1 0 0 1-.71-.29l-6-6a1 1 0 0 1 0-1.42l6-6a1 1 0 1 1 1.42 1.42L9.24 12l5.3 5.29A1 1 0 0 1 13.83 19Z'/%3E%3C/svg%3E");
}

.icon-settings::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94a7.43 7.43 0 0 0 .05-.94 7.43 7.43 0 0 0-.05-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.14 7.14 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 2h-3.8a.5.5 0 0 0-.49.42l-.36 2.54a7.14 7.14 0 0 0-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.43 7.43 0 0 0-.05.94 7.43 7.43 0 0 0 .05.94l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .6.22l2.39-.96c.5.39 1.05.71 1.63.94l.36 2.54a.5.5 0 0 0 .49.42h3.8a.5.5 0 0 0 .49-.42l.36-2.54c.58-.23 1.13-.55 1.63-.94l2.39.96a.5.5 0 0 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94a7.43 7.43 0 0 0 .05-.94 7.43 7.43 0 0 0-.05-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.14 7.14 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 2h-3.8a.5.5 0 0 0-.49.42l-.36 2.54a7.14 7.14 0 0 0-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.43 7.43 0 0 0-.05.94 7.43 7.43 0 0 0 .05.94l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .6.22l2.39-.96c.5.39 1.05.71 1.63.94l.36 2.54a.5.5 0 0 0 .49.42h3.8a.5.5 0 0 0 .49-.42l.36-2.54c.58-.23 1.13-.55 1.63-.94l2.39.96a.5.5 0 0 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7z'/%3E%3C/svg%3E");
}

.icon-admin::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 10.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11v8.8z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 10.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11v8.8z'/%3E%3C/svg%3E");
}

.icon-export::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E");
}

.icon-filter::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z'/%3E%3C/svg%3E");
}

.icon-snapshot::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm4 18H6V4h7v5h5v11z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm4 18H6V4h7v5h5v11z'/%3E%3C/svg%3E");
}

.icon-lock::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2zm-6 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm3.1-9H8.9V6a3.1 3.1 0 0 1 6.2 0v2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2zm-6 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm3.1-9H8.9V6a3.1 3.1 0 0 1 6.2 0v2z'/%3E%3C/svg%3E");
}

.icon-check::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
}

.icon-backup::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13a4.98 4.98 0 0 0 3.35-8.96zM14 13v4h-4v-4H7l5-5 5 5h-3z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13a4.98 4.98 0 0 0 3.35-8.96zM14 13v4h-4v-4H7l5-5 5 5h-3z'/%3E%3C/svg%3E");
}

.icon-restore::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z'/%3E%3C/svg%3E");
}

.icon-refresh::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'/%3E%3C/svg%3E");
}

.icon-logout::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8v-2H4V5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8v-2H4V5z'/%3E%3C/svg%3E");
}

.btn-primary {
  background: linear-gradient(180deg, #3a3a48 0%, #25252f 100%);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  border-color: rgba(255, 61, 106, 0.45);
  background: linear-gradient(180deg, #424250 0%, #2a2a34 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
}

.btn-accent {
  background: linear-gradient(180deg, #ff4a72 0%, var(--red) 100%);
  border-color: rgba(92, 13, 31, 0.9);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 12px rgba(201, 21, 56, 0.35);
}

.btn-accent:hover:not(:disabled) {
  border-color: rgba(255, 120, 150, 0.55);
}

.btn-danger {
  background: linear-gradient(180deg, #ff4a70 0%, #c6183b 100%);
  border-color: #781226;
  color: white;
}

.btn-danger-outline {
  background: rgba(209, 23, 58, 0.08);
  border-color: rgba(209, 23, 58, 0.35);
  color: #ffc4d0;
}

.btn-warning-outline {
  background: rgba(240, 138, 36, 0.10);
  border-color: rgba(240, 138, 36, 0.38);
  color: #ffd9b3;
}

.btn-row {
  padding: 8px 14px;
  border-radius: var(--radius-control);
  font-size: 13px;
  white-space: nowrap;
  min-height: 38px;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

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

.meta {
  color: var(--muted);
  font-size: 13px;
}

.display-panel {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.028);
}

.panel-filter-section-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-filter-section-title + .display-grid + .panel-filter-section-title {
  margin-top: 18px;
}

.panel-filter-hint {
  margin: -4px 0 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  max-width: 52ch;
}

.display-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.display-grid label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.display-grid input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--red-2);
  cursor: pointer;
}

.completed-note {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid rgba(255, 61, 106, 0.65);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
}

.completed-toolbar {
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status {
  display: none;
}

.status.hidden {
  display: none !important;
}

.status.status-info,
.status.status-success,
.status.status-error {
  display: block;
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
}

.status.status-info {
  color: #dbe7ff;
  border-color: rgba(79, 131, 255, 0.45);
  background: rgba(43, 87, 189, 0.15);
}

.status.status-success {
  color: #ddffef;
  border-color: rgba(34, 181, 108, 0.5);
  background: rgba(14, 120, 69, 0.16);
}

.status.status-error {
  color: #ffe2e9;
  border-color: rgba(255, 61, 106, 0.55);
  background: rgba(184, 22, 62, 0.17);
}

.results-wrap {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: calc(100vh - 300px);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.completed-wrap {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: auto;
  flex: 1;
  min-height: 120px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

/* Tableaux à colonnes redimensionnables (colgroup + largeurs %) */
.table-resizable {
  table-layout: fixed;
  width: 100%;
}

.table-resizable .sticky-left,
.table-resizable .sticky-right,
.table-resizable .col-check,
.table-resizable .col-action,
.table-resizable .completed-check-col,
.table-resizable .completed-check-cell,
.table-resizable .sticky-completed-action,
.table-resizable .completed-action-cell {
  width: auto;
  min-width: 0;
  max-width: none;
}

.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  margin-right: -4px;
  z-index: 25;
  cursor: col-resize;
  background: transparent;
}

.col-resizer:hover {
  background: rgba(59, 130, 246, 0.35);
}

.col-resizer:active {
  background: rgba(59, 130, 246, 0.55);
}

/* Colonnes étroites : pas de chevauchement (table-layout: fixed + col %) */
.table-resizable th,
.table-resizable td {
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.table-resizable thead th {
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.table-resizable tbody td {
  white-space: normal;
  vertical-align: top;
}

.table-resizable tbody td.sticky-left,
.table-resizable tbody td.completed-check-cell {
  vertical-align: middle;
  text-align: center;
}

.table-resizable thead th.col-check,
.table-resizable thead .completed-check-col {
  text-align: center;
}

.table-resizable .results-table thead th.col-title,
.table-resizable .results-table tbody td.col-title,
.table-resizable .results-table tbody td.title-cell {
  min-width: 0 !important;
  max-width: none !important;
}

.table-resizable .title-text {
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.table-resizable .completed-name {
  max-width: 100%;
}

.table-resizable .completed-name-main,
.table-resizable .completed-name-sub {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table-resizable .download-title,
.table-resizable .download-subtext {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table-resizable .status-pill {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  text-align: center;
}

.table-resizable .cat-list {
  min-width: 0;
  max-width: 100%;
}

.table-resizable .badge,
.table-resizable .badge-file,
.table-resizable .cat-pill {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.table-resizable td .admin-actions {
  min-width: 0;
  max-width: 100%;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: linear-gradient(180deg, var(--panel-3) 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border-strong);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

th,
td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  background-clip: padding-box;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.sortable-search,
.sortable-completed {
  cursor: pointer;
  user-select: none;
}

.sortable-search::after,
.sortable-completed::after {
  content: " ↕";
  color: #787886;
  font-size: 12px;
}

.sticky-left,
.sticky-left-2,
.sticky-right {
  position: sticky;
  z-index: 7;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%);
}

thead .sticky-left,
thead .sticky-left-2,
thead .sticky-right {
  z-index: 10;
}

.sticky-left {
  left: 0;
  width: var(--sticky-left-1);
  min-width: var(--sticky-left-1);
  max-width: var(--sticky-left-1);
}

.sticky-left-2 {
  left: var(--sticky-left-1);
  min-width: var(--sticky-left-2);
  max-width: var(--sticky-left-2);
}

.sticky-right {
  right: 0;
  width: var(--sticky-right-1);
  min-width: var(--sticky-right-1);
  max-width: var(--sticky-right-1);
}

.completed-check-col {
  position: sticky;
  left: 0;
  z-index: 11;
  width: var(--sticky-completed-left);
  min-width: var(--sticky-completed-left);
  max-width: var(--sticky-completed-left);
  background: linear-gradient(180deg, var(--panel-3) 0%, var(--panel) 100%);
}

.completed-check-cell {
  position: sticky;
  left: 0;
  z-index: 9;
  width: var(--sticky-completed-left);
  min-width: var(--sticky-completed-left);
  max-width: var(--sticky-completed-left);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%);
}

.sticky-completed-action {
  position: sticky;
  right: 0;
  z-index: 9;
  width: var(--sticky-completed-action);
  min-width: var(--sticky-completed-action);
  max-width: var(--sticky-completed-action);
  background: linear-gradient(180deg, var(--panel-3) 0%, var(--panel) 100%);
  box-sizing: border-box;
}

.completed-action-cell {
  position: sticky;
  right: 0;
  z-index: 7;
  width: var(--sticky-completed-action);
  min-width: var(--sticky-completed-action);
  max-width: var(--sticky-completed-action);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%);
  box-sizing: border-box;
}

@media (min-width: 761px) {
  .completed-table thead th.sticky-completed-action,
  .completed-table tbody td.completed-action-cell {
    padding-right: 14px;
    padding-left: 10px;
  }

  .completed-action-cell .download-link,
  .completed-action-cell .btn {
    max-width: 100%;
    box-sizing: border-box;
  }
}

.col-check {
  width: var(--sticky-left-1);
  min-width: var(--sticky-left-1);
}

.col-action {
  width: var(--sticky-right-1);
  min-width: var(--sticky-right-1);
}

.col-source {
  min-width: 120px;
}

.col-size {
  min-width: 90px;
}

.col-age {
  min-width: 80px;
}

.col-categories {
  min-width: 220px;
}

.col-seed {
  min-width: 120px;
}

/* Titre : pas de sticky horizontal ; l’en-tête reste collé en haut avec les autres th */
.results-table thead th.col-title {
  position: sticky;
  top: 0;
  z-index: 4;
  min-width: min(100%, 220px);
  max-width: 36rem;
  box-shadow: none;
}

.results-table tbody td.col-title,
.results-table tbody td.title-cell {
  position: static;
  left: auto;
  min-width: min(100%, 220px);
  max-width: 36rem;
  box-shadow: none;
}

.title-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 22px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--panel-3);
}

.badge.torrent {
  color: #ffd1da;
  border-color: rgba(255, 48, 93, 0.5);
  background: rgba(209, 23, 58, 0.16);
}

.badge.usenet {
  color: #e4d3ff;
  border-color: rgba(166, 110, 255, 0.55);
  background: rgba(123, 60, 255, 0.16);
}

.badge-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: #dedee8;
}

.badge-folder {
  color: #ffd8df;
  border-color: rgba(209, 23, 58, 0.45);
  background: rgba(209, 23, 58, 0.12);
}

.cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: #11121a;
  border: 1px solid var(--border);
  color: #d7d7e0;
}

.download-link {
  display: inline-flex;
  text-decoration: none;
  font-weight: 700;
}

.download-link:hover {
  border-color: var(--red-2);
}

.small-muted {
  color: var(--muted);
  font-size: 12px;
}

.completed-name {
  max-width: 320px;
  position: relative;
  z-index: 0;
}

.completed-name-main {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  font-size: 13px;
}

.completed-name-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.hide-source .col-source,
.hide-source td[data-col="source"] {
  display: none;
}

.hide-size .col-size,
.hide-size td[data-col="size"] {
  display: none;
}

.hide-age .col-age,
.hide-age td[data-col="age"] {
  display: none;
}

.hide-categories .col-categories,
.hide-categories td[data-col="categories"] {
  display: none;
}

.hide-seed .col-seed,
.hide-seed td[data-col="seed"] {
  display: none;
}

.toast-container {
  position: fixed;
  top: 78px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}

.toast-container .toast {
  pointer-events: auto;
}

.toast {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toastIn 0.28s var(--ease-out);
  color: var(--text);
  background: linear-gradient(180deg, rgba(24, 24, 32, 0.98) 0%, rgba(14, 14, 20, 0.98) 100%);
}

.toast.success {
  border-color: rgba(34, 181, 108, 0.45);
  background: linear-gradient(180deg, rgba(34, 181, 108, 0.18) 0%, rgba(17, 17, 24, 0.96) 100%);
}

.toast.warning {
  border-color: rgba(213, 161, 26, 0.45);
  background: linear-gradient(180deg, rgba(213, 161, 26, 0.18) 0%, rgba(17, 17, 24, 0.96) 100%);
}

.toast.error {
  border-color: rgba(209, 23, 58, 0.5);
  background: linear-gradient(180deg, rgba(209, 23, 58, 0.2) 0%, rgba(17, 17, 24, 0.96) 100%);
}

.toast-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.95;
}

.toast-message {
  font-size: 14px;
  line-height: 1.35;
}

.toast-hide {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px) translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) translateX(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) translateX(10px);
  }
}

.login-top-actions {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
  background: inherit;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(165deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.login-card h1 {
  font-size: 30px;
  margin-bottom: 6px;
}

.login-card .muted {
  color: var(--muted);
  text-align: center;
}

.portal-brand-wrap {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin-bottom: 14px;
}

.portal-brand-title {
  margin: 0;
  font-size: 44px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #ffd4dd 35%, #ff4f76 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(255, 79, 118, 0.10);
}

.portal-brand-subtitle {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #b9b9c5;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 1400px) {
  :root {
    --sticky-left-2: 340px;
  }
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .completed-panel {
    position: static;
    max-height: none;
  }

  .results-wrap {
    max-height: 60vh;
  }

  .completed-name {
    max-width: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-side {
    flex-direction: column;
  }

  .results-table thead th.col-title {
    min-width: 140px;
    max-width: 12rem;
  }

  .results-table tbody td.col-title,
  .results-table tbody td.title-cell {
    min-width: 140px;
    max-width: 12rem;
  }

  th,
  td {
    font-size: 13px;
    padding: 9px 8px;
  }

  .toast-container {
    right: 12px;
    left: 12px;
    width: auto;
  }

  .admin-log-filter-fields {
    grid-template-columns: 1fr;
  }

  .admin-log-filter-actions {
    width: 100%;
  }

  .portal-brand-title {
    font-size: 38px;
  }
}

.btn.is-busy,
.download-link.is-busy {
  position: relative;
  pointer-events: none;
  opacity: 0.9;
}

.btn.is-busy::before,
.download-link.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.98);
  animation: portalSpin 0.72s linear infinite;
  margin-right: 8px;
  flex: 0 0 auto;
}

.download-link.is-busy {
  display: inline-flex;
  align-items: center;
}

.download-link.is-busy::after {
  content: "Préparation...";
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

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

.display-panel.collapsed {
  display: none;
}

.btn.active {
  border-color: rgba(255, 48, 93, 0.55);
  background: rgba(209, 23, 58, 0.12);
  color: #ffd2dc;
}

.sortable-search.sort-active,
.sortable-completed.sort-active {
  color: #ffffff;
  background: linear-gradient(180deg, rgba(255, 48, 93, 0.18) 0%, rgba(20, 20, 27, 1) 100%);
  box-shadow: inset 0 -2px 0 rgba(255, 48, 93, 0.75);
}

.sortable-search.sort-active::after,
.sortable-completed.sort-active::after {
  color: #ffd2dc;
}

.sortable-search.sort-active.sort-asc::after,
.sortable-completed.sort-active.sort-asc::after {
  content: " ↑";
}

.sortable-search.sort-active.sort-desc::after,
.sortable-completed.sort-active.sort-desc::after {
  content: " ↓";
}

.filter-count {
  color: var(--muted);
  font-size: 12px;
}

.category-filter-all {
  font-weight: 700;
}

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(209, 23, 58, 0.45);
  background: rgba(209, 23, 58, 0.12);
  color: #ffd7df;
  font-size: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 1fr);
  align-items: start;
}

.admin-layout .admin-primary-column,
.admin-layout .admin-secondary-column {
  min-width: 0;
}

.admin-layout .admin-primary-column .results-wrap.admin-table-shell {
  max-height: min(68vh, 920px);
}

.admin-layout .admin-secondary-column {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-layout .admin-secondary-column .panel.downloads-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-layout .admin-secondary-column .completed-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  min-width: 0;
}

@media (max-width: 1200px) {
  .admin-layout .admin-secondary-column {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Conteneur table admin : coins propres, pas de double bordure */
.admin-table-shell {
  border-radius: var(--radius-md);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.admin-table-shell .admin-users-table,
.admin-table-shell .admin-logs-table {
  border-radius: 0;
}

.admin-health-label-spaced {
  margin-top: 10px;
}

/* Groupes de boutons réutilisables */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-group--tools {
  justify-content: flex-start;
  row-gap: 10px;
}

.btn-group .btn {
  flex: 0 1 auto;
  min-width: 0;
}

/* Outils secondaires : visuellement plus discrets */
.btn-ghost-tool {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.07);
}

.btn-ghost-tool:hover:not(:disabled) {
  border-color: rgba(255, 48, 93, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

/* Filtres logs : champs étiquetés + actions séparées */
.admin-log-filter-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-log-filter-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.admin-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.admin-filter-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-filter-field input,
.admin-filter-field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.admin-log-filter-actions {
  padding-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 0;
  width: 100%;
}

/* Colonnes tableau utilisateurs (table-layout: fixed déjà sur .table-resizable) */
.admin-users-table col.col-admin-num {
  width: 3%;
}

.admin-users-table col.col-admin-name {
  width: 13%;
}

.admin-users-table col.col-admin-role {
  width: 6%;
}

.admin-users-table col.col-admin-security {
  width: 7%;
}

.admin-users-table col.col-admin-active {
  width: 6%;
}

.admin-users-table col.col-admin-session {
  width: 9%;
}

.admin-users-table col.col-admin-ip {
  width: 10%;
}

.admin-users-table col.col-admin-ua {
  width: 20%;
}

.admin-users-table col.col-admin-created {
  width: 7%;
}

.admin-users-table col.col-admin-login {
  width: 7%;
}

.admin-users-table col.col-admin-actions {
  width: 12%;
}

.admin-users-table th,
.admin-users-table td {
  vertical-align: middle;
  overflow: hidden;
  min-width: 0;
}

.admin-users-table td:not(.admin-users-actions-cell) {
  word-break: break-word;
}

.admin-cell-ellipsis {
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* .ua-cell définit max-width: 260px plus bas ; le tableau admin impose les largeurs via col */
.admin-users-table .ua-cell {
  max-width: none;
}

.admin-users-actions-cell {
  overflow: visible;
  vertical-align: top;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.admin-stat-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.admin-stat-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
}

.admin-stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.admin-stat-sub {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.admin-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 10px 0 8px;
  align-items: stretch;
}

.admin-health-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  background: rgba(255, 255, 255, 0.028);
  min-height: 100px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.admin-health-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.admin-health-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  min-width: 0;
}

.admin-health-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-health-value-sm {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.admin-health-kv-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 4px;
}

.admin-health-kv-line span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.admin-health-kv-line strong {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.admin-health-path-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  line-height: 1.35;
}

.admin-health-path-tag {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.admin-health-path-text {
  flex: 1 1 140px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  text-align: right;
  word-break: break-all;
}

.admin-health-path-flag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.admin-health-path-flag.ok {
  color: #b6f7d0;
  border-color: rgba(34, 181, 108, 0.45);
  background: rgba(34, 181, 108, 0.16);
}

.admin-health-path-flag.bad {
  color: #ffd7df;
  border-color: rgba(209, 23, 58, 0.45);
  background: rgba(209, 23, 58, 0.16);
}

.admin-health-card-wide {
  grid-column: span 2;
}

@media (max-width: 1100px) {
  .admin-health-card-wide {
    grid-column: auto;
  }
}

.admin-health-alerts {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.admin-health-alerts.hidden {
  display: none;
}

.admin-health-alert {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.admin-health-alert strong {
  margin-right: 6px;
}

.admin-health-alert-warning {
  background: color-mix(in oklab, var(--warning) 12%, transparent);
  border-color: color-mix(in oklab, var(--warning) 45%, var(--border));
}

.admin-health-alert-error {
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  border-color: color-mix(in oklab, var(--danger) 50%, var(--border));
}

.admin-create-user {
  margin-bottom: 20px;
}

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

.admin-table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.admin-table-pager.hidden {
  display: none;
}

.admin-table-pager-info {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 84px;
  text-align: center;
}

.admin-form input,
.admin-form select {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.admin-form select:not([multiple]) {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.admin-form input::placeholder {
  color: var(--muted);
}

.admin-form select option {
  color: #f4f4f7;
  background: #14141b;
}

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

.admin-actions--dropdown {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
}

.admin-actions-dropdown {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.admin-actions-dropdown__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.admin-actions-dropdown__summary::-webkit-details-marker {
  display: none;
}

.admin-actions-dropdown__summary::marker {
  content: "";
  display: none;
}

.admin-actions-dropdown__summary::after {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  flex-shrink: 0;
  opacity: 0.85;
}

.admin-actions-dropdown[open] .admin-actions-dropdown__summary::after {
  transform: translateY(2px) rotate(225deg);
}

.admin-actions-dropdown__summary:hover {
  border-color: rgba(255, 48, 93, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

.admin-actions-dropdown__summary:focus-visible {
  outline: 2px solid rgba(255, 61, 106, 0.55);
  outline-offset: 2px;
}

.admin-actions-dropdown__panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.admin-actions-dropdown .admin-actions .admin-action-form + .admin-action-form::before {
  content: none;
}

@media (min-width: 761px) {
  .admin-users-table tbody td.admin-users-actions-cell {
    vertical-align: top;
    min-width: 108px;
    max-width: 200px;
  }

  .admin-users-table tbody td.admin-users-actions-cell .admin-actions--dropdown .btn-row {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .admin-users-table tbody td.admin-users-actions-cell .admin-inline-rename .btn-row {
    flex: 0 0 auto;
  }
}

.admin-actions .admin-action-form {
  position: relative;
}

.admin-actions .admin-action-form + .admin-action-form::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.admin-log-filters {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.admin-log-filters:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.admin-log-filter-actions .btn {
  min-height: 40px;
}

.log-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid var(--border);
}

.log-status-success {
  color: #d6ffe9;
  border-color: rgba(34, 181, 108, 0.45);
  background: rgba(34, 181, 108, 0.16);
}

.log-status-failed,
.log-status-error {
  color: #ffd7df;
  border-color: rgba(209, 23, 58, 0.45);
  background: rgba(209, 23, 58, 0.16);
}

.log-status-partial {
  color: #ffeab8;
  border-color: rgba(213, 161, 26, 0.45);
  background: rgba(213, 161, 26, 0.16);
}

.password-page-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 18px;
}

.password-card {
  padding: 26px 24px;
  border-radius: var(--radius-lg);
}

.password-form {
  display: grid;
  gap: 14px;
}

.form-block {
  display: grid;
  gap: 8px;
}

.form-block span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.password-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.form-alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid var(--border);
}

.form-alert-error {
  color: #ffd7df;
  border-color: rgba(209, 23, 58, 0.45);
  background: rgba(209, 23, 58, 0.12);
}

.form-alert-success {
  color: #d6ffe9;
  border-color: rgba(34, 181, 108, 0.45);
  background: rgba(34, 181, 108, 0.12);
}

.form-alert-warning {
  color: #ffeab8;
  border-color: rgba(213, 161, 26, 0.45);
  background: rgba(213, 161, 26, 0.12);
}

.settings-banner {
  margin-bottom: 18px;
}

.settings-page-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 18px;
}

.settings-grid {
  display: grid;
  gap: 18px;
}

@media (min-width: 900px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-card-muted {
    grid-column: 1 / -1;
  }
}

.settings-card-muted .panel-desc {
  max-width: 720px;
}

.session-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.session-indicator-active {
  color: #d6ffe9;
  border-color: rgba(34, 181, 108, 0.40);
  background: rgba(34, 181, 108, 0.14);
}

.session-indicator-active .session-dot {
  background: var(--green);
  box-shadow: 0 0 10px rgba(34, 181, 108, 0.45);
}

.session-indicator-inactive {
  color: #d4d4dd;
  border-color: rgba(163, 163, 175, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

.session-indicator-inactive .session-dot {
  background: #7e7e8d;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
}

.admin-badge-success {
  color: #d6ffe9;
  border-color: rgba(34, 181, 108, 0.40);
  background: rgba(34, 181, 108, 0.14);
}

.admin-badge-muted {
  color: #d4d4dd;
  border-color: rgba(163, 163, 175, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

.admin-badge-warning {
  color: #ffeab8;
  border-color: rgba(213, 161, 26, 0.45);
  background: rgba(213, 161, 26, 0.16);
}

.admin-inline-rename {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.admin-inline-rename input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.admin-inline-rename input::placeholder {
  color: var(--muted);
}

.ua-cell {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Mes téléchargements / side stack --- */

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.downloads-panel,
.completed-panel {
  min-width: 0;
}

.downloads-head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.downloads-wrap {
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.downloads-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

.downloads-table th,
.downloads-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.downloads-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
}

.download-title {
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.download-subtext {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}

.progress-cell {
  min-width: 180px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--purple-2));
}

.progress-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-column: 1;
  }
}


/* === UX polish phase === */

.topbar {
  align-items: center;
}

.topbar-user {
  gap: 14px;
}

.topbar-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  text-align: right;
}

.topbar-user-meta-card {
  align-items: flex-end;
  justify-content: center;
  min-height: 46px;
  min-width: 0;
  max-width: min(100%, 280px);
  padding: 8px 14px 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.02) 100%
  );
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
}

.topbar-user-meta-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--red-2) 0%, var(--purple-2) 100%);
  opacity: 0.95;
}

.topbar-user-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-role {
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f4f4f8;
  background: rgba(255, 61, 106, 0.16);
  border: 1px solid rgba(255, 61, 106, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-link {
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  color: #ececf3;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.topbar-link:hover {
  border-color: rgba(255, 48, 93, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.topbar-link-logout {
  font-weight: 800;
}

.panel-head-spacious {
  gap: 16px;
  align-items: flex-start;
}

.panel-head-main {
  min-width: 0;
}

.panel-meta-row {
  margin-top: 8px;
}

.panel-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #d6d6df;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.downloads-panel .panel-desc,
.completed-panel .panel-desc {
  max-width: 560px;
}

.downloads-wrap-padded {
  margin-top: 12px;
  padding: 10px 12px 12px;
}

.downloads-wrap {
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.015) 100%);
}

.downloads-table {
  min-width: 100%;
}

.downloads-table th,
.downloads-table td {
  padding: 14px 16px;
}

.downloads-table thead th:first-child {
  border-top-left-radius: 14px;
}

.downloads-table thead th:last-child {
  border-top-right-radius: 14px;
}

.downloads-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 14px;
}

.downloads-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 14px;
}

.downloads-table .empty-cell {
  padding: 24px 16px;
  text-align: center;
  color: #b8b8c4;
}

.download-title {
  margin-bottom: 2px;
}

.download-subtext {
  line-height: 1.45;
}

.completed-wrap {
  margin-top: 12px;
}

.completed-note {
  line-height: 1.45;
}

.completed-toolbar {
  gap: 10px;
}

.btn.is-busy {
  position: relative;
  filter: saturate(1.08);
}

.btn.is-busy::after {
  content: "";
  width: 13px;
  height: 13px;
  margin-left: 8px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  animation: portalSpin 0.85s linear infinite;
}

.sortable-search,
.sortable-completed,
.sortable-downloads {
  cursor: pointer;
  user-select: none;
  position: relative;
  background-clip: padding-box;
}

.sortable-downloads::after {
  content: " ↕";
  color: #787886;
  font-size: 12px;
}

.sortable-search.sort-active,
.sortable-completed.sort-active,
.sortable-downloads.sort-active {
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(255, 48, 93, 0.24) 0%, rgba(25, 25, 34, 0.98) 54%, rgba(25, 25, 34, 1) 100%);
  box-shadow:
    inset 0 -2px 0 rgba(255, 48, 93, 0.88),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.sortable-search.sort-active::after,
.sortable-completed.sort-active::after,
.sortable-downloads.sort-active::after {
  color: #ffd2dc;
}

.sortable-downloads.sort-active.sort-asc::after {
  content: " ↑";
}

.sortable-downloads.sort-active.sort-desc::after {
  content: " ↓";
}

.results-table thead th,
.completed-table thead th,
.downloads-table thead th {
  background-clip: padding-box;
}

@media (max-width: 980px) {
  .topbar-user {
    justify-content: flex-end;
  }

  .topbar-user-meta-card {
    width: 100%;
    max-width: none;
    align-items: flex-start;
    text-align: left;
  }

  .topbar-user-name {
    align-self: start;
    text-align: left;
  }

  .topbar-user-role {
    align-self: flex-start;
  }

  .topbar-links {
    width: 100%;
    justify-content: flex-end;
  }

  .panel-head-spacious {
    flex-direction: column;
    align-items: stretch;
  }

  .downloads-head-actions {
    width: 100%;
  }

  .downloads-head-actions .btn,
  .topbar-links .btn,
  .topbar-links form,
  .topbar-links form .btn {
    width: 100%;
  }
}


/* === UX quick fix === */

.results-wrap {
  overflow: auto;
  padding-top: 0 !important;
}

.results-table thead th,
.completed-table thead th,
.downloads-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(28, 28, 38, 0.98) !important;
  background-image: none !important;
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.sortable-search.sort-active,
.sortable-completed.sort-active,
.sortable-downloads.sort-active {
  background: rgba(42, 26, 38, 0.98) !important;
  box-shadow:
    inset 0 -2px 0 rgba(255, 61, 106, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
}

/* Sticky column headers must stack above thead z-index: 3 + scrolling cells */
.results-table thead th.sticky-left,
.completed-table thead th.completed-check-col {
  z-index: 13;
}

.results-table thead th.sticky-right,
.completed-table thead th.sticky-completed-action {
  z-index: 13;
}

.downloads-panel {
  padding: 18px 18px 16px !important;
}

.downloads-panel .panel-head {
  margin-bottom: 10px;
}

.downloads-wrap,
.completed-wrap {
  margin-top: 10px;
}

.downloads-wrap {
  padding: 0 !important;
  border-radius: 16px;
  overflow: auto;
}

.downloads-table {
  min-width: 100% !important;
}

.downloads-table th,
.downloads-table td {
  padding: 14px 14px !important;
}

.downloads-table .empty-cell {
  padding: 20px 14px !important;
}

.panel-head-spacious {
  gap: 12px !important;
}

.btn.is-busy::before {
  content: none !important;
}

.btn.is-busy::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.32);
  border-top-color: rgba(255,255,255,0.98);
  animation: portalSpin 0.85s linear infinite;
}

.downloads-head-actions,
.completed-toolbar {
  align-items: center;
}

@media (max-width: 1180px) {
  .results-wrap {
    min-width: 0;
  }
}


/* === Safe status polish === */

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  white-space: nowrap;
}

.status-downloading {
  color: #b9ffd0;
  background: rgba(28, 122, 71, 0.22);
  border-color: rgba(74, 222, 128, 0.24);
}

.status-processing {
  color: #eceff4;
  background: rgba(107, 114, 128, 0.24);
  border-color: rgba(156, 163, 175, 0.22);
}

.status-completed {
  color: #dcfce7;
  background: rgba(21, 128, 61, 0.22);
  border-color: rgba(74, 222, 128, 0.22);
}

.status-error {
  color: #ffd4d4;
  background: rgba(185, 28, 28, 0.22);
  border-color: rgba(248, 113, 113, 0.26);
}

.status-duplicate {
  color: #dbeafe;
  background: rgba(37, 99, 235, 0.20);
  border-color: rgba(96, 165, 250, 0.24);
}

.status-paused {
  color: #fff1b8;
  background: rgba(161, 98, 7, 0.22);
  border-color: rgba(250, 204, 21, 0.24);
}

.status-stalled {
  color: #ffddb5;
  background: rgba(194, 65, 12, 0.22);
  border-color: rgba(251, 146, 60, 0.26);
}

.status-queued,
.status-unknown,
.status-deleted {
  color: #d1d5db;
  background: rgba(75, 85, 99, 0.18);
  border-color: rgba(156, 163, 175, 0.20);
}


/* === Phase 1 safe fixes === */

.hidden {
  display: none !important;
}

.transfer-progress {
  margin-top: 12px;
  margin-bottom: 2px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.025) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.transfer-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.transfer-progress-label {
  font-size: 14px;
  font-weight: 700;
  color: #f3f3f8;
}

.transfer-progress-step {
  font-size: 12px;
  font-weight: 800;
  color: #c9c9d6;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.transfer-progress-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.08);
}

.transfer-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--red-2));
  transition: width 0.28s ease;
}

.transfer-progress.is-done .transfer-progress-fill {
  background: linear-gradient(90deg, #1fa463, #28c67a);
}

.btn-secondary {
  color: #ececf3;
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.10);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 48, 93, 0.35);
}

.password-actions .btn {
  min-height: 42px;
  padding-inline: 16px;
  border-radius: 14px;
}

.sticky-left,
.sticky-left-2,
.sticky-right,
.completed-check-cell,
.completed-action-cell {
  background: var(--panel) !important;
  background-image: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%) !important;
}

thead .sticky-left,
thead .sticky-left-2,
thead .sticky-right,
.completed-check-col,
.sticky-completed-action {
  background: var(--panel-3) !important;
  background-image: linear-gradient(180deg, var(--panel-3) 0%, var(--panel) 100%) !important;
}

.sticky-left,
thead .sticky-left,
.completed-check-cell,
.completed-check-col {
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.05);
}

.sticky-left-2,
thead .sticky-left-2 {
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.05);
}

.sticky-right,
thead .sticky-right,
.completed-action-cell,
.sticky-completed-action {
  box-shadow: -1px 0 0 rgba(255, 255, 255, 0.05);
}

.results-table tbody tr:hover .sticky-left,
.results-table tbody tr:hover .sticky-right,
.completed-table tbody tr:hover .completed-check-cell,
.completed-table tbody tr:hover .completed-action-cell {
  background: #171720 !important;
}

@media (max-width: 760px) {
  .transfer-progress-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* UI ERGONOMICS & ANIMATIONS */
button,
.btn {
  transition:
    transform 0.2s var(--ease-out),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    opacity 0.2s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled),
  .btn:hover:not(.disabled-link) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm), 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

button:active:not(:disabled),
.btn:active:not(.disabled-link) {
  transform: translateY(0);
}

.results-table tbody tr, .completed-table tbody tr, .downloads-table tbody tr {
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.results-table tbody tr:hover, .completed-table tbody tr:hover, .downloads-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

/* STORAGE WIDGET */
.storage-widget {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  min-width: 148px;
  margin-right: 8px;
  transition: opacity 0.3s var(--ease);
}

.storage-widget.hidden {
  display: none;
}

.storage-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.storage-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.storage-text {
  font-size: 12px;
  font-weight: 600;
  color: #e4e4e9;
}

.storage-bar {
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.storage-fill {
  height: 100%;
  background: linear-gradient(90deg, #22b56c, #a66eff);
  border-radius: 999px;
  transition: width 1s cubic-bezier(0.1, 0.8, 0.3, 1), background-color 0.5s ease;
}

.storage-fill.warning {
  background: linear-gradient(90deg, #d5a11a, #f08a24);
}

.storage-fill.danger {
  background: linear-gradient(90deg, #d1173a, #ff305d);
}

@media (max-width: 760px) {
  .storage-widget {
    margin-right: 0;
    margin-bottom: 12px;
  }
}

@media (max-width: 760px) {
  .topbar-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-topbar-toggle {
    display: inline-flex;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .mobile-tips-toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(14, 14, 20, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
  }

  .mobile-tips-title {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 4px;
  }

  .mobile-tips-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
  }

  .mobile-tips-close {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
  }

  body.topbar-collapsed .topbar {
    padding-top: 8px;
    padding-bottom: 8px;
    min-height: 48px;
  }

  body.topbar-collapsed .topbar-right {
    display: none;
  }

  body.topbar-collapsed .portal-title {
    font-size: 1rem;
    padding-bottom: 0;
  }

  body.topbar-collapsed .portal-title::after {
    display: none;
  }

  body.topbar-collapsed .layout {
    padding-top: 8px;
  }

  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .layout {
    gap: 14px;
    padding: 12px 12px calc(22px + env(safe-area-inset-bottom, 0px));
  }

  .panel {
    border-radius: 14px;
  }

  .panel-head,
  .panel-head.compact {
    gap: 10px;
  }

  .panel-desc {
    font-size: 13px;
  }

  .mobile-section-collapsed .panel-mobile-body,
  .mobile-panel-collapsed .panel-mobile-body {
    display: none !important;
  }

  .mobile-section-collapsed .panel-head,
  .mobile-panel-collapsed .panel-head {
    margin-bottom: 0;
  }

  .mobile-section-collapsed .panel-head > *:not(.panel-head-main):not(.panel-mobile-toggle),
  .mobile-panel-collapsed .panel-head > *:not(.panel-head-main):not(.panel-mobile-toggle) {
    display: none !important;
  }

  #toggleDisplayBtn.topbar-link {
    font-size: 13px;
    min-height: 38px;
    padding: 8px 12px;
  }

  .toolbar {
    gap: 10px;
  }

  .toolbar-left {
    width: 100%;
    gap: 8px;
  }

  .toolbar-left .btn {
    min-height: 42px;
  }

  .search-panel .toolbar-left {
    flex-wrap: wrap;
  }

  .search-panel .toolbar-left #toggleDisplayBtn,
  .search-panel .toolbar-left #toggleCategoriesBtn {
    flex: 1 1 calc(50% - 5px);
    min-width: min(100%, 160px);
    justify-content: center;
  }

  .search-form input,
  .search-form select,
  .search-form button,
  .topbar-link,
  .completed-toolbar .btn,
  .downloads-head-actions .btn,
  .mobile-sort-order-btn {
    min-height: 42px;
  }

  .mobile-sort-bar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "label select order";
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    position: sticky;
    top: calc(52px + env(safe-area-inset-top, 0px));
    z-index: 7;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .mobile-sort-label {
    grid-area: label;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .mobile-sort-bar select {
    grid-area: select;
    width: 100%;
    min-width: 0;
    min-height: 38px;
    font-size: 13px;
  }

  .mobile-sort-order-btn {
    grid-area: order;
    min-width: 42px;
    min-height: 38px;
    font-weight: 800;
    line-height: 1;
    padding: 8px 10px;
  }

  .mobile-sort-bar > .small-muted {
    grid-area: select;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .table-resizable .col-resizer {
    display: none !important;
  }

  .results-wrap,
  .completed-wrap,
  .downloads-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  .results-table,
  .completed-table,
  .downloads-table,
  .admin-users-table,
  .admin-logs-table,
  .admin-system-events-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .results-table colgroup,
  .completed-table colgroup,
  .downloads-table colgroup,
  .admin-users-table colgroup,
  .admin-logs-table colgroup,
  .admin-system-events-table colgroup {
    display: none;
  }

  .results-table thead,
  .completed-table thead,
  .downloads-table thead,
  .admin-users-table thead,
  .admin-logs-table thead,
  .admin-system-events-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
    padding: 0;
  }

  .results-table tbody tr,
  .completed-table tbody tr,
  .downloads-table tbody tr,
  .admin-users-table tbody tr,
  .admin-logs-table tbody tr,
  .admin-system-events-table tbody tr {
    display: block;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: linear-gradient(165deg, var(--panel) 0%, var(--panel-2) 100%);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .results-table tbody td,
  .completed-table tbody td,
  .downloads-table tbody td,
  .admin-users-table tbody td,
  .admin-logs-table tbody td,
  .admin-system-events-table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 0 !important;
    border-bottom: 1px solid var(--border);
    white-space: normal;
  }

  .results-table tbody td,
  .completed-table tbody td,
  .downloads-table tbody td {
    font-size: 13px;
  }

  .results-table tbody td::before,
  .completed-table tbody td::before,
  .downloads-table tbody td::before,
  .admin-users-table tbody td::before,
  .admin-logs-table tbody td::before,
  .admin-system-events-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 min(38%, 11rem);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .results-table .title-text,
  .completed-table .completed-name-main,
  .downloads-table .download-title {
    font-weight: 700;
  }

  .results-table tbody tr td:last-child,
  .completed-table tbody tr td:last-child,
  .downloads-table tbody tr td:last-child,
  .admin-users-table tbody tr td:last-child,
  .admin-logs-table tbody tr td:last-child,
  .admin-system-events-table tbody tr td:last-child {
    border-bottom: 0;
  }

  .results-table tbody td > *:not(:first-child),
  .completed-table tbody td > *:not(:first-child),
  .downloads-table tbody td > *:not(:first-child),
  .admin-users-table tbody td > *:not(:first-child),
  .admin-logs-table tbody td > *:not(:first-child),
  .admin-system-events-table tbody td > *:not(:first-child) {
    margin-top: 6px;
  }

  .results-table .empty-cell,
  .completed-table .empty-cell,
  .downloads-table .empty-cell,
  .admin-users-table .empty-cell,
  .admin-logs-table .empty-cell,
  .admin-system-events-table .empty-cell {
    display: block !important;
    text-align: center;
    padding: 14px;
    border: 0 !important;
  }

  .results-table .empty-cell::before,
  .completed-table .empty-cell::before,
  .downloads-table .empty-cell::before,
  .admin-users-table .empty-cell::before,
  .admin-logs-table .empty-cell::before,
  .admin-system-events-table .empty-cell::before {
    content: none;
  }

  .results-table .sticky-left,
  .results-table .sticky-right,
  .completed-table .completed-check-cell,
  .completed-table .completed-action-cell {
    position: static;
    left: auto;
    right: auto;
    background: transparent !important;
    box-shadow: none !important;
  }

  .results-table .sticky-left,
  .completed-table .completed-check-cell {
    align-items: center;
  }

  .results-table .sticky-left::before,
  .completed-table .completed-check-cell::before {
    flex-basis: min(38%, 11rem);
  }

  .results-table .sticky-right,
  .completed-table .completed-action-cell {
    justify-content: flex-start;
  }

  .results-table .sticky-right .btn,
  .completed-table .completed-action-cell .btn {
    width: 100%;
  }

  .results-table .sticky-left,
  .completed-table .completed-check-cell {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .downloads-table .progress-cell {
    display: block;
  }

  .downloads-table .progress-cell::before {
    display: block;
    margin-bottom: 6px;
  }

  .downloads-table .progress-bar {
    width: 100%;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-actions .admin-action-form {
    width: 100%;
  }

  .admin-actions .btn {
    width: 100%;
  }

  .completed-toolbar {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 8;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(11, 11, 16, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    margin-top: 10px;
  }

  .completed-toolbar .btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 12px;
  }

  .topbar-links {
    width: 100%;
  }

  .topbar-links .btn,
  .topbar-links form,
  .topbar-links form .btn {
    width: 100%;
  }

  /* Optimisation smartphone : alléger les colonnes secondaires */
  body:not(.mobile-show-details) .results-table thead th.col-categories,
  body:not(.mobile-show-details) .results-table tbody td:nth-child(6),
  body:not(.mobile-show-details) .results-table thead th.col-seed,
  body:not(.mobile-show-details) .results-table tbody td:nth-child(7) {
    display: none;
  }

  body:not(.mobile-show-details) .completed-table thead th:nth-child(3),
  body:not(.mobile-show-details) .completed-table tbody td:nth-child(3) {
    display: none;
  }

  body:not(.mobile-show-details) .admin-users-table thead th:nth-child(1),
  body:not(.mobile-show-details) .admin-users-table tbody td:nth-child(1),
  body:not(.mobile-show-details) .admin-users-table thead th:nth-child(7),
  body:not(.mobile-show-details) .admin-users-table tbody td:nth-child(7),
  body:not(.mobile-show-details) .admin-users-table thead th:nth-child(8),
  body:not(.mobile-show-details) .admin-users-table tbody td:nth-child(8),
  body:not(.mobile-show-details) .admin-users-table thead th:nth-child(9),
  body:not(.mobile-show-details) .admin-users-table tbody td:nth-child(9),
  body:not(.mobile-show-details) .admin-users-table thead th:nth-child(10),
  body:not(.mobile-show-details) .admin-users-table tbody td:nth-child(10) {
    display: none;
  }

  body:not(.mobile-show-details) .admin-logs-table thead th:nth-child(5),
  body:not(.mobile-show-details) .admin-logs-table tbody td:nth-child(5),
  body:not(.mobile-show-details) .admin-system-events-table thead th:nth-child(5),
  body:not(.mobile-show-details) .admin-system-events-table tbody td:nth-child(5) {
    display: none;
  }

  body.mobile-compact .mobile-sort-bar {
    margin-bottom: 8px;
    padding: 6px 8px;
  }

  body.mobile-compact .mobile-sort-label {
    font-size: 11px;
  }

  body.mobile-compact .results-table,
  body.mobile-compact .completed-table,
  body.mobile-compact .downloads-table,
  body.mobile-compact .admin-users-table,
  body.mobile-compact .admin-logs-table,
  body.mobile-compact .admin-system-events-table {
    border-spacing: 0 8px;
  }

  body.mobile-compact .results-table tbody td,
  body.mobile-compact .completed-table tbody td,
  body.mobile-compact .downloads-table tbody td,
  body.mobile-compact .admin-users-table tbody td,
  body.mobile-compact .admin-logs-table tbody td,
  body.mobile-compact .admin-system-events-table tbody td {
    padding: 8px 10px;
    gap: 8px;
  }

  body.mobile-compact .results-table tbody td::before,
  body.mobile-compact .completed-table tbody td::before,
  body.mobile-compact .downloads-table tbody td::before,
  body.mobile-compact .admin-users-table tbody td::before,
  body.mobile-compact .admin-logs-table tbody td::before,
  body.mobile-compact .admin-system-events-table tbody td::before {
    font-size: 11px;
    flex-basis: min(36%, 10rem);
  }

  body.mobile-compact .results-table .sticky-right .btn,
  body.mobile-compact .completed-table .completed-action-cell .btn,
  body.mobile-compact .admin-actions .btn {
    min-height: 36px;
    font-size: 12px;
    padding: 7px 10px;
  }

  body.mobile-compact .completed-toolbar {
    padding: 6px;
    gap: 8px;
  }

  body.mobile-compact .completed-toolbar .btn {
    min-height: 36px;
    font-size: 11px;
    padding-left: 8px;
    padding-right: 8px;
  }

  body.mobile-pro .mobile-sort-bar {
    border-color: rgba(255, 61, 106, 0.34);
    background: rgba(255, 61, 106, 0.08);
  }

  body.mobile-pro .results-table tbody tr,
  body.mobile-pro .completed-table tbody tr,
  body.mobile-pro .downloads-table tbody tr,
  body.mobile-pro .admin-users-table tbody tr,
  body.mobile-pro .admin-logs-table tbody tr,
  body.mobile-pro .admin-system-events-table tbody tr {
    border-color: rgba(255, 61, 106, 0.26);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 61, 106, 0.16);
  }

  /* Thème clair : texte des barres de tri / zones « smartphone » plus lisible */
  html[data-theme="light"] .mobile-sort-label {
    color: #0f172a;
  }

  html[data-theme="light"] .mobile-sort-bar select {
    color: #0f172a;
    font-weight: 600;
  }

  html[data-theme="light"] .mobile-sort-bar > .small-muted {
    color: #1e293b;
  }

  html[data-theme="light"] body.mobile-pro .mobile-sort-bar {
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(15, 23, 42, 0.07);
  }

  html[data-theme="light"] body.mobile-compact .mobile-sort-label {
    color: #0f172a;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (min-width: 761px) {
  .mobile-sort-bar {
    display: none;
  }

  .mobile-topbar-toggle {
    display: none;
  }

  .mobile-tips-toast {
    display: none;
  }
}

.theme-toggle {
  min-width: 5.5rem;
  font-size: 13px;
  font-weight: 700;
}

/* ——— Thème clair ——— */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f3f7;
  --bg-2: #e8ebf1;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --panel-3: #eef1f6;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.14);
  --accent: #1d4ed8;
  --accent-soft: rgba(29, 78, 216, 0.12);
  --red: #b91c1c;
  --red-2: #dc2626;
  --red-dark: #7f1d1d;
  --purple: #5b21b6;
  --purple-2: #6d28d9;
  --green: #047857;
  --yellow: #a16207;
  --orange: #c2410c;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.09);
  --shadow: var(--shadow-md);

  /* Tableaux (mode clair) — même base partout */
  --table-wrap-bg: #f8fafc;
  --table-surface: #ffffff;
  --table-header-bg: #f1f5f9;
  --table-header-border: rgba(15, 23, 42, 0.1);
  --table-row-hover: #f1f5f9;
  --table-cell-border: rgba(15, 23, 42, 0.08);
  --table-choice-bg: #eef2ff;
  --table-choice-bg-header: #e0e7ff;
  --table-choice-hover: #e0e7ff;
  --table-sticky-action-hover: #e2e8f0;

  background-color: var(--bg);
  background-image:
    radial-gradient(circle at center, rgba(15, 23, 42, 0.055) 1px, transparent 1.6px),
    repeating-linear-gradient(
      118deg,
      transparent 0,
      transparent 84px,
      rgba(29, 78, 216, 0.028) 84px,
      rgba(29, 78, 216, 0.028) 85px
    ),
    radial-gradient(ellipse 100% 55% at 50% -12%, rgba(29, 78, 216, 0.07), transparent 52%),
    radial-gradient(ellipse 65% 42% at 100% 0%, rgba(100, 116, 139, 0.07), transparent 48%),
    radial-gradient(ellipse 58% 46% at 6% 94%, rgba(91, 33, 182, 0.05), transparent 52%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-size:
    38px 38px,
    auto,
    auto,
    auto,
    auto,
    auto;
  background-position:
    0 0,
    0 0,
    center top,
    100% 0,
    0% 100%,
    center;
  background-attachment: fixed;
}

html[data-theme="light"] ::selection {
  background: rgba(29, 78, 216, 0.2);
  color: #0f172a;
}

html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

html[data-theme="light"] .results-wrap,
html[data-theme="light"] .completed-wrap,
html[data-theme="light"] .downloads-wrap {
  background: var(--table-wrap-bg) !important;
  border-color: var(--table-cell-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  scrollbar-color: rgba(15, 23, 42, 0.22) rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .results-wrap::-webkit-scrollbar-track,
html[data-theme="light"] .completed-wrap::-webkit-scrollbar-track,
html[data-theme="light"] .downloads-wrap::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .results-wrap::-webkit-scrollbar-thumb,
html[data-theme="light"] .completed-wrap::-webkit-scrollbar-thumb,
html[data-theme="light"] .downloads-wrap::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
}

html[data-theme="light"] .results-table thead th,
html[data-theme="light"] .completed-table thead th,
html[data-theme="light"] .downloads-table thead th,
html[data-theme="light"] .admin-users-table thead th,
html[data-theme="light"] .admin-logs-table thead th,
html[data-theme="light"] .admin-system-events-table thead th {
  background: var(--table-header-bg) !important;
  color: #334155;
  border-bottom-color: var(--table-header-border);
  box-shadow:
    inset 0 -1px 0 var(--table-header-border),
    inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
}

html[data-theme="light"] .results-table tbody td,
html[data-theme="light"] .completed-table tbody td,
html[data-theme="light"] .downloads-table tbody td,
html[data-theme="light"] .admin-users-table tbody td,
html[data-theme="light"] .admin-logs-table tbody td,
html[data-theme="light"] .admin-system-events-table tbody td {
  background: var(--table-surface) !important;
  color: #0f172a;
  border-bottom-color: var(--table-cell-border);
}

html[data-theme="light"] thead .sticky-right,
html[data-theme="light"] thead .sticky-completed-action {
  background: var(--table-header-bg) !important;
}

html[data-theme="light"] thead .sticky-left.col-check,
html[data-theme="light"] thead .completed-check-col {
  background: var(--table-choice-bg-header) !important;
  color: #3730a3;
  box-shadow:
    inset 0 -1px 0 var(--table-header-border),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    1px 0 0 rgba(99, 102, 241, 0.2) !important;
}

html[data-theme="light"] .results-table tbody .sticky-left,
html[data-theme="light"] .completed-table tbody .completed-check-cell {
  background: var(--table-choice-bg) !important;
  color: #312e81;
  box-shadow: 1px 0 0 rgba(99, 102, 241, 0.18);
}

html[data-theme="light"] .results-table tbody tr:hover td,
html[data-theme="light"] .completed-table tbody tr:hover td,
html[data-theme="light"] .downloads-table tbody tr:hover td,
html[data-theme="light"] .admin-users-table tbody tr:hover td,
html[data-theme="light"] .admin-logs-table tbody tr:hover td,
html[data-theme="light"] .admin-system-events-table tbody tr:hover td {
  background: var(--table-row-hover) !important;
}

html[data-theme="light"] .results-table tbody tr:hover .sticky-left,
html[data-theme="light"] .completed-table tbody tr:hover .completed-check-cell {
  background: var(--table-choice-hover) !important;
}

html[data-theme="light"] .results-table tbody tr:hover .sticky-right,
html[data-theme="light"] .completed-table tbody tr:hover .completed-action-cell {
  background: var(--table-sticky-action-hover) !important;
}

html[data-theme="light"] .completed-action-cell .btn,
html[data-theme="light"] .completed-action-cell .download-link {
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}

html[data-theme="light"] .completed-action-cell .btn-accent {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #fff !important;
  border-color: rgba(30, 64, 175, 0.85) !important;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2) !important;
}

html[data-theme="light"] .completed-action-cell .btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
  color: #fff !important;
  border-color: rgba(127, 29, 29, 0.85) !important;
}

html[data-theme="light"] .completed-action-cell .btn-danger-outline {
  background: rgba(254, 226, 226, 0.55) !important;
  color: #991b1b !important;
  border-color: rgba(185, 28, 28, 0.32) !important;
}

html[data-theme="light"] .completed-action-cell .btn-secondary,
html[data-theme="light"] .completed-action-cell a.btn-secondary.download-link {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}

html[data-theme="light"] .completed-action-cell .btn-secondary:hover:not(:disabled),
html[data-theme="light"] .completed-action-cell a.btn-secondary.download-link:hover:not(.disabled-link) {
  background: rgba(15, 23, 42, 0.06) !important;
  border-color: rgba(29, 78, 216, 0.28) !important;
}

html[data-theme="light"] .col-resizer:hover {
  background: rgba(29, 78, 216, 0.28);
}

html[data-theme="light"] .col-resizer:active {
  background: rgba(29, 78, 216, 0.45);
}

html[data-theme="light"] .sortable-search.sort-active,
html[data-theme="light"] .sortable-completed.sort-active,
html[data-theme="light"] .sortable-downloads.sort-active {
  color: #0f172a !important;
  background: rgba(219, 234, 254, 0.98) !important;
  box-shadow:
    inset 0 -2px 0 rgba(29, 78, 216, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
}

html[data-theme="light"] .sortable-search.sort-active::after,
html[data-theme="light"] .sortable-completed.sort-active::after,
html[data-theme="light"] .sortable-downloads.sort-active::after {
  color: #1d4ed8 !important;
  font-weight: 800;
}

html[data-theme="light"] .login-page {
  background: inherit;
}

html[data-theme="light"] .toast {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 252, 0.98) 100%);
  border-color: var(--border-strong);
}

html[data-theme="light"] .btn-secondary {
  background: rgba(15, 23, 42, 0.04);
  border-color: var(--border-strong);
  color: var(--text);
}

html[data-theme="light"] .btn-secondary:hover,
html[data-theme="light"] .btn-secondary:focus-visible {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(29, 78, 216, 0.28);
}

html[data-theme="light"] .btn-ghost-tool {
  background: rgba(15, 23, 42, 0.035);
  border-color: rgba(15, 23, 42, 0.12);
  color: #475569;
}

html[data-theme="light"] .btn-ghost-tool:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.07);
  color: #1e293b;
}

html[data-theme="light"] .admin-log-filter-actions {
  border-top-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .admin-actions-dropdown__summary {
  background: rgba(15, 23, 42, 0.04);
  border-color: var(--border-strong);
  color: var(--text);
}

html[data-theme="light"] .admin-actions-dropdown__summary:hover {
  background: rgba(15, 23, 42, 0.07);
  border-color: rgba(29, 78, 216, 0.28);
}

html[data-theme="light"] .admin-actions-dropdown__panel {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .btn-accent {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: rgba(30, 64, 175, 0.85);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
}

html[data-theme="light"] .btn-accent:hover:not(:disabled) {
  border-color: rgba(59, 130, 246, 0.75);
}

html[data-theme="light"] .btn-danger-outline {
  background: rgba(254, 226, 226, 0.55);
  border-color: rgba(185, 28, 28, 0.32);
  color: #991b1b;
}

html[data-theme="light"] .btn-warning-outline {
  background: rgba(254, 243, 199, 0.55);
  border-color: rgba(180, 83, 9, 0.32);
  color: #92400e;
}

html[data-theme="light"] input:focus-visible,
html[data-theme="light"] select:focus-visible {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16);
  border-color: rgba(29, 78, 216, 0.42);
}

html[data-theme="light"] .storage-widget {
  background: rgba(15, 23, 42, 0.04);
  border-color: var(--border-strong);
}

html[data-theme="light"] .portal-brand-title {
  background: linear-gradient(180deg, #0f172a 0%, #1d4ed8 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="light"] .topbar-user-meta-card {
  background: linear-gradient(155deg, #ffffff 0%, #f1f5f9 100%);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

html[data-theme="light"] .topbar-user-meta-card::before {
  background: linear-gradient(180deg, #2563eb 0%, #7c3aed 100%);
}

html[data-theme="light"] .topbar-user-name {
  color: #0f172a;
}

html[data-theme="light"] .topbar-user-role {
  color: #1e40af;
  background: rgba(29, 78, 216, 0.12);
  border-color: rgba(29, 78, 216, 0.28);
  box-shadow: none;
}

html[data-theme="light"] .topbar-link {
  color: var(--text);
}

html[data-theme="light"] .btn-primary {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border-color: rgba(29, 78, 216, 0.38);
  color: #1e3a8a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: rgba(29, 78, 216, 0.52);
  color: #1e3a8a;
}

html[data-theme="light"] select:not([multiple]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

html[data-theme="light"] .btn.active {
  border-color: rgba(29, 78, 216, 0.42);
  background: rgba(219, 234, 254, 0.92);
  color: #0f172a;
  font-weight: 800;
}

html[data-theme="light"] .form-alert-error {
  color: #9f1239;
  background: rgba(254, 205, 211, 0.42);
  border-color: rgba(190, 18, 60, 0.32);
}

html[data-theme="light"] .form-alert-success {
  color: #065f46;
  background: rgba(209, 250, 229, 0.75);
  border-color: rgba(5, 150, 105, 0.32);
}

html[data-theme="light"] .form-alert-warning {
  color: #92400e;
  background: rgba(254, 243, 199, 0.78);
  border-color: rgba(180, 83, 9, 0.3);
}

html[data-theme="light"] .meta,
html[data-theme="light"] .small-muted,
html[data-theme="light"] .panel-desc {
  color: #64748b;
}

html[data-theme="light"] .admin-stat-card {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .admin-health-card {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.14);
}

html[data-theme="light"] .admin-badge-success {
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(209, 250, 229, 0.55);
}

html[data-theme="light"] .admin-badge-muted {
  color: #475569;
  border-color: rgba(100, 116, 139, 0.28);
  background: rgba(241, 245, 249, 0.9);
}

html[data-theme="light"] .admin-badge-warning {
  color: #92400e;
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(254, 243, 199, 0.65);
}

html[data-theme="light"] .badge.torrent {
  color: #9f1239;
  border-color: rgba(190, 18, 60, 0.38);
  background: rgba(254, 205, 211, 0.75);
}

html[data-theme="light"] .badge.usenet {
  color: #5b21b6;
  border-color: rgba(124, 58, 237, 0.38);
  background: rgba(237, 233, 254, 0.95);
}

html[data-theme="light"] .badge-file {
  color: #1e293b;
  border-color: rgba(100, 116, 139, 0.35);
  background: rgba(241, 245, 249, 0.98);
}

html[data-theme="light"] .badge-folder {
  color: #9f1239;
  border-color: rgba(190, 18, 60, 0.35);
  background: rgba(254, 205, 211, 0.65);
}

html[data-theme="light"] .cat-pill {
  color: #334155;
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .log-status-success {
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.4);
  background: rgba(209, 250, 229, 0.9);
}

html[data-theme="light"] .log-status-failed,
html[data-theme="light"] .log-status-error {
  color: #9f1239;
  border-color: rgba(190, 18, 60, 0.4);
  background: rgba(254, 205, 211, 0.75);
}

html[data-theme="light"] .log-status-partial {
  color: #92400e;
  border-color: rgba(180, 83, 9, 0.4);
  background: rgba(254, 243, 199, 0.88);
}

html[data-theme="light"] .session-indicator-active {
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.4);
  background: rgba(209, 250, 229, 0.92);
}

html[data-theme="light"] .session-indicator-inactive {
  color: #475569;
  border-color: rgba(100, 116, 139, 0.32);
  background: rgba(241, 245, 249, 0.98);
}

html[data-theme="light"] .status-pill {
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: none;
}

html[data-theme="light"] .status-downloading {
  color: #14532d;
  background: rgba(220, 252, 231, 0.95);
  border-color: rgba(22, 163, 74, 0.35);
}

html[data-theme="light"] .status-processing {
  color: #334155;
  background: rgba(241, 245, 249, 0.98);
  border-color: rgba(100, 116, 139, 0.3);
}

html[data-theme="light"] .status-completed {
  color: #14532d;
  background: rgba(220, 252, 231, 0.92);
  border-color: rgba(22, 163, 74, 0.32);
}

html[data-theme="light"] .status-error {
  color: #9f1239;
  background: rgba(254, 205, 211, 0.75);
  border-color: rgba(190, 18, 60, 0.35);
}

html[data-theme="light"] .status-duplicate {
  color: #1e40af;
  background: rgba(219, 234, 254, 0.95);
  border-color: rgba(59, 130, 246, 0.35);
}

html[data-theme="light"] .status-paused {
  color: #92400e;
  background: rgba(254, 243, 199, 0.9);
  border-color: rgba(180, 83, 9, 0.35);
}

html[data-theme="light"] .status-stalled {
  color: #9a3412;
  background: rgba(255, 237, 213, 0.92);
  border-color: rgba(234, 88, 12, 0.35);
}

html[data-theme="light"] .status-queued,
html[data-theme="light"] .status-unknown,
html[data-theme="light"] .status-deleted {
  color: #475569;
  background: rgba(241, 245, 249, 0.98);
  border-color: rgba(100, 116, 139, 0.28);
}

html[data-theme="light"] .status.status-info {
  color: #1e3a8a;
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(219, 234, 254, 0.75);
}

html[data-theme="light"] .status.status-success {
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(209, 250, 229, 0.75);
}

html[data-theme="light"] .status.status-error {
  color: #9f1239;
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(255, 228, 230, 0.75);
}

html[data-theme="light"] .admin-form select option {
  color: #0f172a;
  background: #ffffff;
}

html[data-theme="light"] .admin-inline-rename input {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--border-strong);
}

/* ——— Tiroir navigation mobile (centre de contrôle) ——— */
.mobile-drawer__backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-backdrop);
  background: rgba(2, 2, 6, 0.52);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), visibility 0.2s;
}

.mobile-drawer__backdrop--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

html[data-theme="light"] .mobile-drawer__backdrop--visible {
  background: rgba(15, 23, 42, 0.35);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(22rem, 100vw - 32px);
  max-width: 100%;
  z-index: var(--z-drawer-panel);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-left: 1px solid var(--border-strong);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.22s var(--ease-out), visibility 0.22s;
}

.mobile-drawer--open {
  transform: translateX(0);
  visibility: visible;
}

.mobile-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.mobile-drawer__title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}

.mobile-drawer__close {
  flex-shrink: 0;
  min-height: var(--mobile-touch-sm);
}

.mobile-drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-drawer__section {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.mobile-drawer__section:last-child {
  border-bottom: 0;
}

.mobile-drawer__section--grow {
  flex: 1;
  min-height: 0;
}

.mobile-drawer__section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.mobile-drawer__slot {
  margin-bottom: 12px;
}

.mobile-drawer__slot--storage {
  margin-top: 8px;
}

.mobile-drawer__btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-drawer__btn-stack .btn {
  width: 100%;
  justify-content: center;
  min-height: var(--mobile-touch-md);
}

.mobile-drawer__hint {
  margin: -4px 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 500;
}

.mobile-drawer__modes--segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.2);
}

html[data-theme="light"] .mobile-drawer__modes--segmented {
  background: rgba(15, 23, 42, 0.05);
  border-color: var(--border);
}

.mobile-drawer__modes--segmented .btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 5px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  justify-content: center;
}

.mobile-drawer__modes--segmented .btn.active {
  background: linear-gradient(180deg, rgba(255, 61, 106, 0.98), rgba(200, 24, 70, 0.95));
  border-color: rgba(255, 61, 106, 0.5);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 61, 106, 0.22);
}

html[data-theme="light"] .mobile-drawer__modes--segmented .btn.active {
  color: #fff;
}

html[data-theme="light"] .mobile-drawer__modes--segmented .btn:not(.active) {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.14);
  font-weight: 800;
}

html[data-theme="light"] .mobile-drawer__section:has(.mobile-drawer__modes--segmented) .mobile-drawer__section-title {
  color: #334155;
}

html[data-theme="light"] .mobile-drawer__section:has(.mobile-drawer__modes--segmented) .mobile-drawer__hint {
  color: #1e293b;
  font-weight: 600;
}

.mobile-drawer__slot--flush {
  margin-bottom: 0;
}

.mobile-drawer__switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.mobile-drawer__switch input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--red-2);
}

.mobile-drawer-action-btn {
  width: 100%;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-group-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 100%;
  align-items: stretch;
}

.flex-1 {
  flex: 1 1 0;
  min-width: 0;
}

.mobile-only-hidden {
  display: none !important;
}

.tools-btn-primary {
  order: -1;
}

.section-card {
  min-width: 0;
}

.section-header {
  min-width: 0;
}

.section-toggle.panel-mobile-toggle {
  flex-shrink: 0;
}

.admin-actions-dropdown {
  position: relative;
  z-index: 1;
}

.admin-actions-dropdown[open] {
  z-index: 5;
}

.admin-actions-dropdown__panel {
  position: relative;
  z-index: 2;
}

@media (max-width: 760px) {
  .topbar {
    z-index: var(--z-topbar-app);
  }

  .toast-container {
    z-index: var(--z-toast-app);
  }

  .mobile-sort-bar {
    z-index: var(--z-sticky-band);
  }

  body.mobile-shell .topbar-right {
    display: none !important;
  }

  .panel-mobile-toggle,
  .section-toggle {
    min-height: var(--mobile-touch-sm);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    justify-self: end;
    align-self: start;
    margin-left: 0;
  }

  .panel-head.section-header,
  .panel-head.compact.section-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "mhead mtoggle"
      "mextra mextra";
    align-items: start;
    gap: 10px 12px;
    column-gap: 12px;
  }

  .panel-head.section-header .panel-head-main {
    grid-area: mhead;
    min-width: 0;
  }

  .panel-head.section-header .panel-mobile-toggle {
    grid-area: mtoggle;
  }

  .panel-head.section-header .downloads-head-actions,
  .panel-head.section-header .panel-head-actions {
    grid-area: mextra;
    width: 100%;
    margin-top: 0;
  }

  .panel-head.section-header > .btn:not(.panel-mobile-toggle) {
    grid-area: mextra;
    width: 100%;
    justify-self: stretch;
  }

  .mobile-panel-section .panel-head.section-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "mhead mtoggle"
      "mextra mextra";
  }

  .panel-head.section-header:not(:has(.panel-mobile-toggle)) {
    grid-template-columns: 1fr;
    grid-template-areas:
      "mhead"
      "mextra";
  }

  .panel-mobile-body {
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  }

  .mobile-section-collapsed .panel-mobile-body,
  .mobile-panel-collapsed .panel-mobile-body {
    opacity:                 0.96;
  }

  .completed-toolbar.btn-group-vertical {
    position: static;
    box-shadow: none;
    padding: 0;
    margin-top: 12px;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .completed-toolbar .tools-btn-danger {
    margin-top: 4px;
  }

  .admin-table-pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .admin-table-pager .btn {
    min-height: var(--mobile-touch-sm);
  }

  /* Tableau utilisateurs admin : fond / bordure alignés sur les bords de la carte (mobile) */
  .panel.search-panel.section-card .panel-mobile-body .results-wrap.admin-table-shell {
    margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(14px, env(safe-area-inset-right, 0px)));
    width: calc(
      100% + max(14px, env(safe-area-inset-left, 0px)) + max(14px, env(safe-area-inset-right, 0px))
    );
    max-width: none;
    box-sizing: border-box;
    border-radius: var(--radius-md);
  }

  .admin-users-table tbody td {
    align-items: flex-start !important;
  }

  .admin-users-table tbody td .admin-badge {
    align-self: flex-start;
    max-width: 100%;
  }

  .admin-users-table tbody td.admin-users-actions-cell {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .admin-users-table tbody td.admin-users-actions-cell::before {
    margin-bottom: 2px;
  }

  .admin-actions-dropdown__panel {
    isolation: isolate;
  }
}

@media (min-width: 761px) {
  .mobile-drawer,
  .mobile-drawer__backdrop {
    display: none !important;
  }

  body.mobile-drawer-open {
    overflow: auto;
  }
}

/* —— Touch: évite le double-tap zoom sur les contrôles principaux —— */
button:not(.col-resizer),
.btn,
.topbar-link,
.topbar-link-logout,
input[type="submit"],
.mobile-sort-order-btn,
.mobile-sort-pro-btn,
.mobile-sort-details-btn,
.mobile-sort-compact-btn {
  touch-action: manipulation;
}

/* —— Appareils sans survol précis : pas de “lift” au tap —— */
@media (hover: none) {
  button:hover:not(:disabled),
  .btn:hover:not(.disabled-link) {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .panel:hover {
    transform: none;
  }

  .admin-stat-card:hover {
    transform: none;
  }
}

/* —— Mobile UX : couche complémentaire (≤760px) —— */
@media (max-width: 760px) {
  .mobile-shell .mobile-header {
    min-height: 62px;
  }

  body.mobile-shell .topbar-left {
    width: 100%;
    max-width: 100%;
  }

  body.mobile-shell .portal-title {
    flex: 1;
    min-width: 0;
  }

  .mobile-shell .mobile-page {
    width: 100%;
    gap: 12px;
  }

  .mobile-shell .mobile-section {
    width: 100%;
  }

  .mobile-shell .mobile-section__header {
    align-items: flex-start;
    gap: 10px;
  }

  .mobile-shell .mobile-toggle {
    min-width: 110px;
    align-self: flex-start;
  }

  html {
    -webkit-tap-highlight-color: rgba(255, 61, 106, 0.14);
  }

  body {
    overflow-x: hidden;
  }

  .topbar {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }

  .layout {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .search-panel {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  /* Topbar : lecture gauche-droite, cartes utilisateur pleine largeur */
  .topbar-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .theme-toggle {
    align-self: flex-start;
    min-height: var(--mobile-touch-sm);
    padding-left: 14px;
    padding-right: 14px;
  }

  .storage-widget {
    width: 100%;
    max-width: none;
  }

  .topbar-user {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-user-meta {
    align-items: flex-start;
    text-align: left;
    max-width: 100%;
  }

  .topbar-user-meta-card {
    max-width: none;
    align-items: flex-start;
    align-self: stretch;
  }

  .topbar-user-name {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
  }

  .topbar-links {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* Recherche : action principale = pleine largeur, métadonnées lisibles */
  .toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-left .btn {
    width: 100%;
    min-height: var(--mobile-touch-md);
    justify-content: center;
  }

  .toolbar-left #downloadSelectedBtn {
    order: -1;
  }

  .toolbar-left .meta {
    width: 100%;
    text-align: center;
    font-size: 13px;
    line-height: 1.45;
    padding-top: 2px;
  }

  .downloads-head-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .downloads-head-actions .btn {
    width: 100%;
    flex: 1 1 auto;
    min-height: var(--mobile-touch-sm);
    justify-content: center;
  }

  .completed-panel .panel-head.section-header > .btn:not(.panel-mobile-toggle) {
    min-height: var(--mobile-touch-sm);
    justify-content: center;
  }

  /* Barre d’actions terminés : pile verticale, zones tactiles stables */
  .completed-toolbar {
    position: sticky;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .completed-toolbar .btn {
    flex: 1 1 auto;
    width: 100%;
    min-height: var(--mobile-touch-md);
    font-size: 13px;
  }

  .form-alert {
    font-size: 15px;
    line-height: 1.45;
    padding: 14px 16px;
  }

  .panel h2 {
    font-size: clamp(1.05rem, 4vw, 1.22rem);
    line-height: 1.25;
  }

  .panel-desc {
    line-height: 1.45;
  }

  .display-panel {
    padding: 12px 14px;
  }

  .display-grid label {
    min-height: 44px;
    padding: 6px 0;
    align-items: center;
  }

  .display-grid input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
  }

  .completed-note {
    font-size: 14px;
    line-height: 1.55;
  }

  .status.status-info,
  .status.status-success,
  .status.status-error {
    padding: 12px 14px;
    font-size: 14px;
    margin: 10px 0 12px;
  }

  .toast-container {
    top: max(72px, calc(env(safe-area-inset-top, 0px) + 56px));
    right: 12px;
    left: 12px;
    width: auto;
  }

  .toast {
    padding: 15px 16px;
  }

  .toast-message {
    font-size: 15px;
    line-height: 1.45;
  }

  .transfer-progress {
    margin-top: 10px;
    margin-bottom: 6px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: rgba(0, 0, 0, 0.22);
  }

  .login-page {
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }

  .login-top-actions {
    top: max(16px, env(safe-area-inset-top, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
  }

  .login-card {
    padding: 26px 22px 24px;
  }

  .settings-page-wrap {
    padding-top: max(20px, env(safe-area-inset-top, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
    max-width: none;
  }

  .password-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .password-actions .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .results-table tbody td,
  .completed-table tbody td,
  .downloads-table tbody td {
    font-size: 14px;
    line-height: 1.5;
  }

  .results-table tbody td::before,
  .completed-table tbody td::before,
  .downloads-table tbody td::before {
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .results-table .empty-cell,
  .completed-table .empty-cell,
  .downloads-table .empty-cell,
  .admin-users-table .empty-cell,
  .admin-logs-table .empty-cell {
    font-size: 14px;
    line-height: 1.5;
    padding: 20px 16px !important;
  }

  .mobile-sort-bar {
    margin-bottom: 12px;
  }

  .admin-stats {
    gap: 10px;
  }

  .admin-stat-card {
    padding: 14px 12px;
  }

  .admin-health-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-health-card-wide {
    grid-column: auto;
  }

  .admin-create-user .admin-form {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-create-user .admin-form input,
  .admin-create-user .admin-form select {
    width: 100%;
    min-height: 46px;
  }

  .password-page-wrap {
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
    padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
  }

  .password-page-wrap .password-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .password-page-wrap .password-actions .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .side-stack {
    gap: 16px;
  }
}

/* Mobile UX hardening: readable cards, safer taps, admin parity */
@media (max-width: 760px) {
  .admin-log-filter-form,
  .admin-log-filter-fields,
  .admin-log-filter-actions {
    width: 100%;
  }

  .admin-log-filter-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .admin-log-filter-actions .btn {
    width: 100%;
    min-height: var(--mobile-touch-sm);
    justify-content: center;
  }

  .display-grid {
    gap: 10px;
  }

  .display-grid label {
    flex: 1 1 calc(50% - 10px);
    min-width: min(100%, 150px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
  }

  .display-grid input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
  }

  .results-table,
  .completed-table,
  .downloads-table,
  .admin-users-table,
  .admin-logs-table,
  .admin-system-events-table {
    border-spacing: 0 12px;
  }

  .results-table tbody tr,
  .completed-table tbody tr,
  .downloads-table tbody tr,
  .admin-users-table tbody tr,
  .admin-logs-table tbody tr,
  .admin-system-events-table tbody tr {
    border-radius: 12px;
  }

  .results-table tbody td,
  .completed-table tbody td,
  .downloads-table tbody td,
  .admin-users-table tbody td,
  .admin-logs-table tbody td,
  .admin-system-events-table tbody td {
    gap: 10px;
  }

  .results-table tbody td::before,
  .completed-table tbody td::before,
  .downloads-table tbody td::before,
  .admin-users-table tbody td::before,
  .admin-logs-table tbody td::before,
  .admin-system-events-table tbody td::before {
    flex: 0 0 min(42%, 12rem);
  }

  .admin-system-events-table tbody td:last-child {
    border-bottom: 0;
  }

  body:not(.mobile-show-details) .admin-system-events-table thead th:nth-child(5),
  body:not(.mobile-show-details) .admin-system-events-table tbody td:nth-child(5) {
    display: none;
  }

  .results-table .sticky-right .btn,
  .completed-table .completed-action-cell .btn,
  .completed-table .completed-action-cell .download-link,
  .admin-actions .btn {
    min-height: var(--mobile-touch-sm);
  }
}

@media (max-width: 430px) {
  .display-grid label {
    flex-basis: 100%;
  }

  .results-table tbody td,
  .completed-table tbody td,
  .downloads-table tbody td,
  .admin-users-table tbody td,
  .admin-logs-table tbody td,
  .admin-system-events-table tbody td {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .results-table tbody td::before,
  .completed-table tbody td::before,
  .downloads-table tbody td::before,
  .admin-users-table tbody td::before,
  .admin-logs-table tbody td::before,
  .admin-system-events-table tbody td::before {
    flex: none;
  }

  .results-table .sticky-left,
  .completed-table .completed-check-cell {
    flex-direction: row;
    align-items: center;
  }

  .results-table .sticky-right,
  .completed-table .completed-action-cell {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }

  button:hover:not(:disabled),
  .btn:hover:not(.disabled-link) {
    transform: none;
  }
}
