/* ==========================================================================
   TRANSCRILIVE Admin — Design system « COSS Origin » (coss.com/ui)
   Compatible avec le vocabulaire de classes historique du site
   (.dashboard-section, .table, .badge-*, .btn-*, .stat-card, .alert-*, …)
   Light + dark mode via [data-theme] sur <html>.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --radius: 0.625rem;
  --radius-sm: 0.4rem;
  --radius-lg: 0.875rem;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  /* Palette neutre */
  --n-50: #fafafa;
  --n-100: #f5f5f5;
  --n-200: #e5e5e5;
  --n-300: #d4d4d4;
  --n-400: #a3a3a3;
  --n-500: #737373;
  --n-600: #525252;
  --n-700: #404040;
  --n-800: #262626;
  --n-900: #171717;
  --n-950: #0a0a0a;

  /* Statuts */
  --red-500: #ef4444;
  --red-700: #b91c1c;
  --red-400: #f87171;
  --blue-500: #3b82f6;
  --blue-700: #1d4ed8;
  --blue-400: #60a5fa;
  --emerald-500: #10b981;
  --emerald-700: #047857;
  --emerald-400: #34d399;
  --amber-500: #f59e0b;
  --amber-700: #b45309;
  --amber-400: #fbbf24;
  --violet-500: #8b5cf6;
  --violet-700: #6d28d9;
  --violet-400: #a78bfa;

  /* Sémantique — light */
  --background: #ffffff;
  --foreground: var(--n-800);
  --card: #ffffff;
  --card-foreground: var(--n-800);
  --popover: #ffffff;
  --muted: rgba(0, 0, 0, 0.04);
  --muted-foreground: #6f6f6f;
  --accent: rgba(0, 0, 0, 0.04);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --input: rgba(0, 0, 0, 0.1);
  --ring: var(--n-400);
  --primary: var(--n-800);
  --primary-foreground: var(--n-50);
  --destructive: var(--red-500);
  --destructive-foreground: var(--red-700);
  --info: var(--blue-500);
  --info-foreground: var(--blue-700);
  --success: var(--emerald-500);
  --success-foreground: var(--emerald-700);
  --warning: var(--amber-500);
  --warning-foreground: var(--amber-700);
  --row-hover: #f6f6f6;
  --sidebar: var(--n-50);
  --sidebar-foreground: #5c5c5c;
  --sidebar-border: rgba(0, 0, 0, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  --background: #0e0e0e;
  --foreground: var(--n-100);
  --card: #151515;
  --card-foreground: var(--n-100);
  --popover: #191919;
  --muted: rgba(255, 255, 255, 0.05);
  --muted-foreground: #9c9c9c;
  --accent: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --input: rgba(255, 255, 255, 0.08);
  --ring: var(--n-500);
  --primary: var(--n-100);
  --primary-foreground: var(--n-800);
  --destructive-foreground: var(--red-400);
  --info-foreground: var(--blue-400);
  --success-foreground: var(--emerald-400);
  --warning-foreground: var(--amber-400);
  --row-hover: #1c1c1c;
  --sidebar: #111111;
  --sidebar-foreground: #9c9c9c;
  --sidebar-border: rgba(255, 255, 255, 0.05);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.55);
}

/* ---------- Base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.55;
  font-size: 14.5px;
  min-height: 100vh;
}

h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 0.95rem; font-weight: 600; }

a { color: var(--info-foreground); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.45em;
  word-break: break-all;
}

::selection { background: rgba(59, 130, 246, 0.25); }

/* ---------- Layout : sidebar + main ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
}

.sidebar-brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-500), var(--violet-500));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-brand .name {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--foreground);
  line-height: 1.15;
}

.sidebar-brand .name small {
  display: block;
  font-weight: 450;
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

.sidebar-nav {
  padding: 6px 10px 12px;
  flex: 1;
}

.sidebar-nav .nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  padding: 14px 8px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  margin: 1px 0;
  border-radius: calc(var(--radius) - 2px);
  color: var(--sidebar-foreground);
  font-weight: 500;
  font-size: 0.86rem;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.sidebar-nav a:hover {
  background: var(--accent);
  color: var(--foreground);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--accent);
  color: var(--foreground);
  font-weight: 600;
}

.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-badge {
  margin-left: auto;
  background: var(--amber-500);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--background);
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
}

.topbar h1 { font-size: 1.05rem; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  padding: 24px 28px 48px;
  max-width: 1440px;
  width: 100%;
}

/* compat : anciennes pages qui ouvrent leur propre .container */
.content .container {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 0;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 550;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
  -webkit-appearance: none;
  appearance: none;
}

.btn:hover { text-decoration: none; }

.btn:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { opacity: 0.88; }

.btn-secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}
.btn-ghost:hover { background: var(--accent); color: var(--foreground); }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive-foreground);
  border-color: rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }

.btn-danger-solid {
  background: var(--red-500);
  color: #fff;
}
.btn-danger-solid:hover { background: var(--red-700); }

.btn-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success-foreground);
  border-color: rgba(16, 185, 129, 0.28);
}
.btn-success:hover { background: rgba(16, 185, 129, 0.2); }

.btn-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-foreground);
  border-color: rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.2); }

.btn-sm { padding: 4px 9px; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.btn-group { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* compat anciennes classes */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.action-btn.btn-primary { background: var(--muted); color: var(--foreground); border-color: var(--border-strong); }
.action-btn.btn-primary:hover { background: var(--accent); }
.action-btn.btn-secondary { background: var(--card); color: var(--foreground); border-color: var(--border-strong); }
.action-btn.btn-secondary:hover { background: var(--accent); }

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

/* ---------- Cartes / sections ---------- */
.dashboard-section,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  margin-bottom: 22px;
}

.dashboard-section h2,
.card h2 {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 20px;
  align-items: start;
}

.dashboard-grid .dashboard-section { margin-bottom: 0; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-head h2 { margin-bottom: 0; }

.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s, background 0.12s;
  position: relative;
}

a.stat-card:hover {
  border-color: var(--border-strong);
  background: var(--accent);
  text-decoration: none;
}

.stat-card .stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-card .stat-label,
.stat-card .stat-content p {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  font-weight: 500;
  margin: 0;
}

.stat-card .stat-value,
.stat-card .stat-content h3 {
  font-size: 1.6rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--foreground);
  line-height: 1.2;
  margin: 0;
}

.stat-card .stat-icon {
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card.stat-warning { border-color: rgba(245, 158, 11, 0.45); }
.stat-card.stat-warning .stat-value,
.stat-card.stat-warning .stat-content h3 { color: var(--warning-foreground); }

.stat-card.stat-danger { border-color: rgba(239, 68, 68, 0.45); }
.stat-card.stat-danger .stat-value { color: var(--destructive-foreground); }

.stat-card .stat-hint {
  font-size: 0.72rem;
  color: var(--muted-foreground);
}

/* compat ancien markup (icône + contenu côte à côte) */
.stat-card .stat-content { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Tableaux ---------- */
.table-responsive { overflow-x: auto; }

.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  font-size: 0.86rem;
}

.table thead,
.data-table thead {
  background: transparent;
  color: var(--muted-foreground);
}

.table th,
.data-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover,
.data-table tbody tr:hover { background: var(--row-hover); }

.table .row-muted { opacity: 0.55; }

/* colonne Actions collée à droite (toujours visible malgré le scroll) */
.table-sticky-actions th:last-child,
.table-sticky-actions td:last-child {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: -10px 0 10px -10px rgba(0, 0, 0, 0.25);
}

.table-sticky-actions thead th:last-child { background: var(--card); z-index: 2; }
.table-sticky-actions tbody tr:hover td:last-child { background: var(--row-hover); }
.table-sticky-actions tr.details-row > td { position: static; box-shadow: none; }

/* en-têtes triables */
th[data-sort] {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

th[data-sort]:hover { color: var(--foreground); }

th[data-sort]::after {
  content: "↕";
  margin-left: 5px;
  opacity: 0.4;
  font-size: 0.85em;
}

th[data-sort][data-sort-dir="asc"]::after { content: "↑"; opacity: 1; }
th[data-sort][data-sort-dir="desc"]::after { content: "↓"; opacity: 1; }

/* ligne cliquable (ouvre les détails) */
tr[data-toggle-details] { cursor: pointer; }

.cell-main { font-weight: 600; color: var(--foreground); }
.cell-sub { font-size: 0.78rem; color: var(--muted-foreground); }

.text-center { text-align: center; }

.no-data {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted-foreground);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success-foreground);
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-foreground);
  border-color: rgba(245, 158, 11, 0.28);
}

.badge-error,
.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive-foreground);
  border-color: rgba(239, 68, 68, 0.25);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info-foreground);
  border-color: rgba(59, 130, 246, 0.25);
}

.badge-neutral {
  background: var(--muted);
  color: var(--muted-foreground);
  border-color: var(--border);
}

/* types de licence */
.badge-trial { background: rgba(245, 158, 11, 0.12); color: var(--warning-foreground); border-color: rgba(245, 158, 11, 0.28); }
.badge-standard { background: rgba(59, 130, 246, 0.1); color: var(--info-foreground); border-color: rgba(59, 130, 246, 0.25); }
.badge-pro { background: rgba(16, 185, 129, 0.12); color: var(--success-foreground); border-color: rgba(16, 185, 129, 0.25); }
.badge-lifetime,
.badge-perpetual { background: rgba(139, 92, 246, 0.12); color: var(--violet-700); border-color: rgba(139, 92, 246, 0.28); }
[data-theme="dark"] .badge-lifetime,
[data-theme="dark"] .badge-perpetual { color: var(--violet-400); }
.badge-monthly,
.badge-monthly_subscription { background: rgba(59, 130, 246, 0.1); color: var(--info-foreground); border-color: rgba(59, 130, 246, 0.25); }
.badge-yearly,
.badge-annual_subscription { background: rgba(16, 185, 129, 0.12); color: var(--success-foreground); border-color: rgba(16, 185, 129, 0.25); }

/* produits */
.badge-product-transcrilive { background: rgba(59, 130, 246, 0.1); color: var(--info-foreground); border-color: rgba(59, 130, 246, 0.25); }
.badge-product-transcribia { background: rgba(16, 185, 129, 0.12); color: var(--success-foreground); border-color: rgba(16, 185, 129, 0.25); }
.badge-product-other { background: rgba(139, 92, 246, 0.12); color: var(--violet-700); border-color: rgba(139, 92, 246, 0.28); }
[data-theme="dark"] .badge-product-other { color: var(--violet-400); }

/* ---------- Alertes ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  font-size: 0.88rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.07);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--destructive-foreground);
}

.alert-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--success-foreground);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.28);
  color: var(--warning-foreground);
}

.alert-info {
  background: rgba(59, 130, 246, 0.07);
  border-color: rgba(59, 130, 246, 0.25);
  color: var(--info-foreground);
}

/* ---------- Formulaires ---------- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 550;
  font-size: 0.84rem;
  color: var(--foreground);
}

.form-group small {
  display: block;
  margin-top: 5px;
  font-size: 0.76rem;
  color: var(--muted-foreground);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--foreground);
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(115, 115, 115, 0.25);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}

input::placeholder,
textarea::placeholder { color: var(--muted-foreground); opacity: 0.7; }

textarea { resize: vertical; min-height: 90px; }

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.form-actions { display: flex; gap: 8px; margin-top: 18px; }

.input-mono { font-family: var(--font-mono); font-size: 0.82rem !important; }

/* champ recherche avec icône */
.search-box { position: relative; min-width: 220px; }
.search-box input { padding-left: 32px; }
.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted-foreground);
  pointer-events: none;
}

/* ---------- Filtres segmentés ---------- */
.filters,
.segmented {
  display: inline-flex;
  gap: 2px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px);
  padding: 3px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 12px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-btn:hover { color: var(--foreground); text-decoration: none; }

.filter-btn.active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 4px 11px;
}

.filter-btn .count {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--muted);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  border-radius: 999px;
  padding: 0 6px;
  min-width: 17px;
  text-align: center;
}

.filter-btn.active .count { background: var(--accent); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-content {
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 22px 24px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-content h2 { margin-bottom: 14px; }

/* ---------- Toast ---------- */
.toast-zone {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: var(--popover);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.18s ease-out;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); color: var(--success-foreground); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: var(--destructive-foreground); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Détails de ligne (drawer inline) ---------- */
.request-details,
tr.details-row > td {
  background: var(--muted);
  padding: 16px 18px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.details-grid > div {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.84rem;
}

.details-grid strong {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 3px;
}

/* ---------- Description list (fiches) ---------- */
.kv {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 6px 14px;
  font-size: 0.87rem;
}

.kv dt { color: var(--muted-foreground); font-weight: 500; }
.kv dd { margin: 0; }

/* ---------- Page login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--background);
  background-image:
    radial-gradient(ellipse 60% 45% at 50% -5%, rgba(59, 130, 246, 0.12), transparent),
    radial-gradient(ellipse 45% 35% at 85% 105%, rgba(139, 92, 246, 0.1), transparent);
}

.login-container { width: 100%; max-width: 380px; padding: 20px; }

.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 32px;
}

.login-box .logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-500), var(--violet-500));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 21px;
  margin: 0 auto 14px;
}

.login-box h1 {
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 4px;
}

.login-box h2 {
  font-size: 0.84rem;
  font-weight: 450;
  color: var(--muted-foreground);
  text-align: center;
  margin-bottom: 22px;
}

.login-footer {
  margin-top: 16px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.78rem;
  text-align: center;
  background: transparent;
}

.footer a { color: var(--muted-foreground); text-decoration: underline; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 30px;
  height: 30px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  padding: 0;
}

.theme-toggle:hover { background: var(--accent); color: var(--foreground); }
.theme-toggle svg { width: 15px; height: 15px; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }

/* ---------- Compat pages secondaires ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.info-card {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.info-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 3px;
}

.info-value { font-size: 0.9rem; font-weight: 550; }

.inactive-row { opacity: 0.5; }

.btn-small { padding: 4px 9px; font-size: 0.78rem; border-radius: var(--radius-sm); }

/* ---------- Utilitaires ---------- */
.text-muted { color: var(--muted-foreground); }
.mono { font-family: var(--font-mono); font-size: 0.82em; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.copy-btn { cursor: pointer; }

/* ---------- Responsive ---------- */
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-nav { display: none; padding-bottom: 8px; }
  .sidebar.open .sidebar-nav { display: block; }
  .sidebar-foot { display: none; }
  .sidebar.open .sidebar-foot { display: flex; }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .sidebar-brand { padding: 12px 14px; }

  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }

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

  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}

@media print {
  .sidebar, .topbar, .footer, .btn, .filters { display: none !important; }
}
