/* StockPro — CSS optimisé, responsive, thème sombre par défaut */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --sidebar-w: 260px;
  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --sidebar-text: rgba(226,232,240,.85);
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(96,165,250,.2);
  --sidebar-accent: #60a5fa;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,.25);
  --font: 'Century Gothic', CenturyGothic, AppleGothic, 'Segoe UI', system-ui, sans-serif;
  --topbar-h: 60px;
}

[data-theme="light"] {
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #3b82f6;
  --success: #059669; --danger: #dc2626; --warning: #d97706; --info: #0891b2;
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --text-muted: #64748b; --border: #e2e8f0;
  --sidebar-bg: linear-gradient(180deg, #1e3a5f 0%, #1e293b 100%);
  --sidebar-text: rgba(255,255,255,.9); --sidebar-hover: rgba(255,255,255,.1);
  --sidebar-active: rgba(255,255,255,.15); --sidebar-accent: #93c5fd;
  --shadow: 0 4px 16px rgba(15,23,42,.08);
}
[data-theme="ocean"] {
  --primary: #0e7490; --primary-dark: #155e75; --primary-light: #06b6d4;
  --bg: #ecfeff; --card: #fff; --text: #164e63; --text-muted: #0e7490; --border: #a5f3fc;
  --sidebar-bg: linear-gradient(180deg, #155e75, #0e7490);
  --sidebar-text: rgba(255,255,255,.9); --sidebar-accent: #67e8f9;
}
[data-theme="forest"] {
  --primary: #166534; --primary-dark: #14532d; --primary-light: #22c55e;
  --bg: #f0fdf4; --card: #fff; --text: #14532d; --text-muted: #166534; --border: #bbf7d0;
  --sidebar-bg: linear-gradient(180deg, #14532d, #166534);
  --sidebar-text: rgba(255,255,255,.9); --sidebar-accent: #86efac;
}
[data-theme="sunset"] {
  --primary: #c2410c; --primary-dark: #9a3412; --primary-light: #f97316;
  --bg: #fff7ed; --card: #fff; --text: #7c2d12; --text-muted: #c2410c; --border: #fed7aa;
  --sidebar-bg: linear-gradient(180deg, #9a3412, #c2410c);
  --sidebar-text: rgba(255,255,255,.9); --sidebar-accent: #fdba74;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code { font-size: .85em; background: var(--bg); padding: .15em .4em; border-radius: 2px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.15rem 1.25rem;
  font-weight: 700; font-size: 1.2rem;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand i { font-size: 1.4rem; color: var(--sidebar-accent); }
.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-section {
  padding: .85rem 1.25rem .35rem;
  font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em; opacity: .55; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-link i { width: 1.25rem; text-align: center; opacity: .9; }
.nav-link:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.nav-link.active {
  background: var(--sidebar-active);
  border-left-color: var(--sidebar-accent);
  color: #fff; font-weight: 600;
}
.sidebar-user {
  padding: .85rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.user-info i { font-size: 1.6rem; opacity: .9; }
.user-name { font-weight: 600; font-size: .85rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; opacity: .7; }
.btn-logout {
  color: var(--sidebar-text); padding: .4rem; border-radius: 6px;
  text-decoration: none; flex-shrink: 0;
}
.btn-logout:hover { background: rgba(239,68,68,.25); color: #fecaca; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: var(--topbar-h);
  height: auto;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; gap: .75rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.menu-toggle {
  display: none; background: none; border: 1px solid var(--border);
  color: var(--text); width: 40px; height: 40px; border-radius: 8px;
  cursor: pointer; align-items: center; justify-content: center; font-size: 1.1rem;
}
.content { padding: 1.25rem; flex: 1; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px/*var(--radius)*/;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  padding: .9rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.15rem; }
.form-card { max-width: 720px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1rem 1.15rem;
  display: flex; align-items: center; gap: .9rem;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.active-filter { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,.15); color: var(--primary); font-size: 1.15rem; flex-shrink: 0;
}
.stat-icon.green { background: rgba(16,185,129,.15); color: var(--success); }
.stat-icon.orange { background: rgba(245,158,11,.15); color: var(--warning); }
.stat-icon.purple { background: rgba(139,92,246,.15); color: #a78bfa; }
.stat-icon.blue { background: rgba(59,130,246,.15); color: var(--primary); }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-muted); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.chart-container { position: relative; height: 240px; width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600; background: var(--bg); white-space: nowrap;
}
tr:hover td { background: rgba(59,130,246,.04); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 600; }
.row-inactive { opacity: .55; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.form-control {
  width: 100%; padding: .55rem .75rem;
  border: 1px solid var(--border); 
  border-radius: 3px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.form-control-sm { padding: .35rem .5rem; font-size: .8rem; }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.form-actions {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.form-section-title {
  font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .75rem;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
}
.check-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; }
.filters-bar { margin-bottom: .5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 2px; font-family: inherit; font-size: .875rem;
  font-weight: 600; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.25rem; font-size: 1rem; }
.btn-group { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.btn-remove {
  background: transparent; border: none; color: var(--danger);
  cursor: pointer; padding: .35rem; font-size: 1rem;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info { background: rgba(6,182,212,.15); color: var(--info); }
.badge-secondary { background: rgba(148,163,184,.2); color: var(--text-muted); }

/* Alerts */
.alert {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
  border: 1px solid transparent;
}
.alert-success { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: var(--success); }
.alert-danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); color: var(--danger); }
.alert-info { background: rgba(6,182,212,.12); border-color: rgba(6,182,212,.3); color: var(--info); }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: var(--warning); }

.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-muted); }
.empty-state p { margin-top: .5rem; }

/* Theme switcher */
.theme-switcher { position: relative; }
.theme-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); min-width: 150px; z-index: 200; padding: .35rem;
}
.theme-menu.open { display: block; }
.theme-menu a {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-radius: 6px; color: var(--text); text-decoration: none; font-size: .85rem;
}
.theme-menu a:hover, .theme-menu a.active { background: var(--bg); color: var(--primary); }

/* Roles UI */
.role-picker { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 640px) {
  .role-picker { grid-template-columns: 1fr 1fr; }
}
.role-option {
  display: block; width: 100%; text-align: left;
  padding: .85rem 1rem;
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--bg); color: inherit; font-family: inherit;
}
.role-option:hover { border-color: var(--primary-light); }
.role-option.selected { border-color: var(--primary); background: rgba(59,130,246,.08); }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }
.role-option-title { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .25rem; }
.role-option-desc { display: block; font-size: .78rem; color: var(--text-muted); line-height: 1.4; }

.user-cell { display: flex; align-items: center; gap: .75rem; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(59,130,246,.15); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.role-select { min-width: 140px; max-width: 180px; pointer-events: auto !important; }
.inline-role-form { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }
.filter-hint { margin-bottom: 1rem; font-size: .9rem; color: var(--text-muted); }

.roles-matrix th, .roles-matrix td { text-align: center; }
.roles-matrix .sticky-col { text-align: left; position: sticky; left: 0; background: var(--card); z-index: 1; }
.roles-matrix thead .sticky-col { background: var(--bg); }
.perm-yes { color: var(--success); font-size: 1.1rem; }
.perm-no { color: var(--text-muted); opacity: .35; font-size: 1rem; }
.help-list { padding-left: 1.25rem; color: var(--text-muted); font-size: .9rem; }
.help-list li { margin-bottom: .5rem; }

/* Documents */
.doc-company {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1.5rem; padding-bottom: 1.25rem; margin-bottom: 1.5rem;
  border-bottom: 3px solid var(--doc-color, var(--primary)); flex-wrap: wrap;
}
.doc-company-left { display: flex; gap: 1rem; align-items: flex-start; flex: 1; min-width: 180px; }
.doc-logo { max-height: 70px; max-width: 140px; object-fit: contain; }
.doc-company-name { font-size: 1.25rem; font-weight: 700; }
.doc-company-slogan { font-size: .85rem; color: var(--text-muted); font-style: italic; }
.doc-company-addr { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; line-height: 1.4; }
.doc-company-right { text-align: right; min-width: 140px; }
.doc-title { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.doc-meta { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }
.doc-info {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.doc-info-block h4 { font-size: .75rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: .25rem; }
.doc-conditions {
  margin-top: 1.5rem; padding: .75rem; background: var(--bg);
  border-radius: 6px; font-size: .8rem; color: var(--text-muted);
  border-left: 3px solid var(--border);
}
.print-signatures {
  display: none; grid-template-columns: 1fr 1fr 1fr; gap: 2rem;
  margin-top: 3rem; page-break-inside: avoid;
}
.print-signatures .sig-box {
  border-top: 1px solid #333; padding-top: .5rem; text-align: center; font-size: 9pt;
}
.print-footer { display: none; }
.stock-init-block {
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 10px; padding: 1.25rem; margin-top: 1rem;
}
.lignes-table input, .lignes-table select { min-width: 0; }

/* Overlay mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 999;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); width: min(280px, 85vw); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex !important; }
  .topbar { padding: 0 .85rem; }
  .topbar h1 { font-size: 1rem; }
  .content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .stat-value { font-size: 1.15rem; }
  .form-row { grid-template-columns: 1fr; }
  .form-card { max-width: 100%; }
  .card-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: .75rem; }
  .topbar-right { gap: .35rem; }
  .btn { font-size: .8rem; padding: .45rem .7rem; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .role-picker { grid-template-columns: 1fr; }
  th, td { padding: .55rem .6rem; font-size: .8rem; }
  .login-card { margin: 1rem; padding: 1.75rem 1.25rem; }
}

@media (max-width: 400px) {
  .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
  .stat-value { font-size: 1.05rem; }
}

/* Print */
@media print {
  @page { margin: 1.4cm; size: A4; }
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .sidebar, .topbar, .no-print, .menu-toggle, .theme-switcher, .alerts, .sidebar-overlay { display: none !important; }
  .main { margin-left: 0 !important; width: 100% !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: none !important; }
  .card-body { padding: 0 !important; }
  .doc-company { border-bottom-color: #1e40af !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-signatures, .print-footer { display: grid !important; }
  .print-footer {
    display: block !important; margin-top: 2rem; padding-top: .75rem;
    border-top: 1px solid #ccc; font-size: 9pt; color: #666;
  }
  a { color: #000 !important; text-decoration: none !important; }
}

/* Document print extras */
.doc-banner {
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  padding: .5rem 0 .75rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 1rem;
}
.doc-print-root { width: 100%; }
.print-footer-meta { font-size: .75rem; opacity: .85; }
@media print {
  .doc-banner { color: #555 !important; border-color: #ccc !important; }
  .print-signatures { display: grid !important; }
  .print-footer { display: block !important; margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid #ccc; font-size: 9pt; color: #555; text-align: center; }
}


/* ---- AJAX loader ---- */
#ajax-loader {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 9999; pointer-events: none; opacity: 0; transition: opacity .2s;
}
#ajax-loader.active { opacity: 1; }
#ajax-loader .ajax-loader-bar {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light, #60a5fa));
  animation: ajaxSlide 1s ease-in-out infinite;
  border-radius: 0 2px 2px 0;
}
@keyframes ajaxSlide {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(400%); width: 30%; }
}

/* ---- Bulk selection ---- */
.bulk-bar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.bulk-bar .bulk-count { font-weight: 700; color: var(--primary); }
table.bulk-table th:first-child,
table.bulk-table td:first-child { width: 2.5rem; text-align: center; }
.check-all, .check-row { width: 1.1rem; height: 1.1rem; cursor: pointer; }

.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 2.5rem; }
.btn-toggle-pwd {
  position: absolute; right: .65rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .25rem;
}


/* ---- Layout fixes ---- */
.filter-inline {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}
.filter-inline .form-control {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}
.hidden-form { display: none !important; }
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 15px;
  opacity: 1;
  display: block;
  text-align:center;
}
.empty-state .btn { margin-top: 1rem; }
.form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.form-section-title {
  margin: 1.5rem 0 .75rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topbar-right .btn { white-space: nowrap; }
.topbar-right form {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
table td, table th {
  vertical-align: middle;
}
.btn-group {
  display: inline-flex;
  gap: .3rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.lignes-table .form-control {
  min-width: 0;
  width: 100%;
}
.doc-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}

.role-option {
  position: relative;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  padding: .85rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  transition: border-color .15s, background .15s;
}
.role-option input[type=radio] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.role-option.selected,
.role-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(59,130,246,.08);
}


/* ---- Topbar tools (recherche + actions) ---- */
.topbar {
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding-top: .55rem;
  padding-bottom: .55rem;
  align-items: center;
}
.topbar > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.topbar-right {
  flex: 0 1 auto;
  max-width: 100%;
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .2rem .2rem .2rem .55rem;
}
.topbar-search .form-control {
  border: none;
  background: transparent;
  box-shadow: none;
  min-width: 140px;
  width: 180px;
  max-width: 42vw;
  height: 34px;
  padding: .25rem .4rem;
}
.topbar-search .form-control:focus {
  outline: none;
  box-shadow: none;
}
.topbar-search .btn {
  height: 34px;
  width: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  flex-shrink: 0;
}
.topbar-tools > .btn-primary {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 .9rem;
  flex-shrink: 0;
}
@media (max-width: 700px) {
  .topbar-search .form-control { width: 120px; min-width: 100px; }
  .topbar-tools .btn-label { display: none; }
  .topbar h1 { max-width: 40vw; }
}
