:root {

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: #0f172a;
  --primary: var(--accent, #0f172a);
  --primary-hover: #1e293b;
  --primary-light: #f1f5f9;
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --emerald-bg: #ecfdf5;
  --emerald-text: #065f46;
  --emerald-border: #a7f3d0;

  --amber-bg: #fffbeb;
  --amber-text: #92400e;
  --amber-border: #fde68a;

  --blue-bg: #eff6ff;
  --blue-text: #1e40af;
  --blue-border: #bfdbfe;

  --rose-bg: #fff1f2;
  --rose-text: #9f1239;
  --rose-border: #fecdd3;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}



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

html {
  background: var(--bg-body);
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text-main);
  background: var(--bg-body);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 500;
}

/* App Shell Layout */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

/* Modern Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.02);
  z-index: 40;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border);
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.brand-mark,
.guest-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: .06em;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand span,
.user-chip span,
.topbar span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 1px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 16px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: #334155;
  transition: all var(--transition-fast);
}

.nav a .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.75;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav a:hover {
  background: #f1f5f9;
  color: var(--text-main);
  transform: translateX(2px);
}

.nav a:hover .nav-icon {
  opacity: 1;
}

.nav a.active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.nav a.active .nav-icon {
  opacity: 1;
  filter: brightness(0) invert(1);
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 18px 12px 6px;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-chip {
  padding: 6px 10px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid #f1f5f9;
}

.user-chip strong {
  display: block;
  font-size: 13px;
  color: var(--text-main);
}

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

/* Modern Topbar */
.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 16px;
}

/* Quick Search Trigger in Topbar */
.quick-search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-search-trigger:hover {
  background: #e2e8f0;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.quick-search-trigger kbd {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-muted);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

/* Scan Agent Status in Topbar */
.scan-agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.scan-agent-pill .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.scan-agent-pill.online {
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border-color: var(--emerald-border);
}

.scan-agent-pill.online .pulse-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Content Area */
.content-wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px;
  width: 100%;
}

/* Page Head */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.head-actions,
.actions,
.form-actions,
.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Panels & Cards */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.panel h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
}

.muted,
.hint {
  color: var(--text-muted);
}

.note {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin: 16px 0;
  font-size: 13.5px;
}

.warning {
  color: var(--rose-text);
  font-weight: 600;
}

/* Modern Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
  filter: none;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.18);
}

.btn-danger {
  border-color: var(--rose-border);
  color: var(--rose-text);
  background: var(--rose-bg);
}

.btn-danger:hover {
  background: #ffe4e6;
  border-color: #f43f5e;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: #f1f5f9;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-large {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* Form Inputs */
.input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  outline: none;
  font-size: 13.5px;
  transition: all var(--transition-fast);
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.stack {
  display: grid;
  gap: 13px;
}

.top-gap {
  margin-top: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form .input {
  min-width: 180px;
}

.compact-form {
  border-top: 1px dashed var(--border);
  margin-top: 14px;
  padding-top: 14px;
}

.settings-form {
  max-width: 1000px;
}

.form-section {
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.form-section:last-of-type {
  border: 0;
}

.color-input {
  height: 42px;
  padding: 4px;
  border-radius: var(--radius-md);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
}

.checkbox-row input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.checkbox-row span small {
  display: block;
  color: var(--text-muted);
}

/* Filter Grid */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: flex-end;
}

.filter-grid label {
  display: grid;
  gap: 5px;
  font-weight: 600;
  font-size: 12.5px;
  color: #334155;
}

.span-2 {
  grid-column: span 2;
}

.filter-actions {
  grid-column: 1 / -1;
  padding-top: 4px;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-2.wide-left {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(320px, 0.95fr);
  gap: 18px;
  align-items: start;
}

/* Sticky Panel on Desktop & Laptops with Independent Scrolling */
.sticky-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sticky-panel::-webkit-scrollbar {
  width: 5px;
}

.sticky-panel::-webkit-scrollbar-track {
  background: transparent;
}

.sticky-panel::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.sticky-panel::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Compact Document Table Utilities */
.doc-table {
  min-width: 500px;
}

.doc-context-line {
  font-size: 11px;
  color: #475569;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.35;
  word-break: break-word;
}

.badge-domain {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.doc-size-badge {
  color: #64748b;
  font-weight: 500;
}

/* Form Row Compact for Dropzone and Sidebars */
.form-row-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-row-compact > * {
  min-width: 0;
}

.form-row-compact input,
.form-row-compact select {
  min-width: 0;
  width: 100%;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.ref-grid .panel {
  margin: 0;
}

/* Metric Cards & Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0.8;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card span {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
}

.metric-card strong {
  display: block;
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row span small {
  display: block;
  color: var(--text-muted);
}

/* Dashboard Progress Track & Bars */
.progress-track {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.blue { background: #2563eb; }
.progress-fill.emerald { background: #10b981; }
.progress-fill.amber { background: #f59e0b; }
.progress-fill.purple { background: #8b5cf6; }

/* Dashboard Action & Distribution Rows */
.dash-item-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-item-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.dash-item-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.empty-queue-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 24px 20px;
  text-align: center;
  color: #065f46;
}

/* Technical Health Grid */
.health-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.health-grid>div {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #f8fafc;
}

.health-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.health-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.status-ok {
  color: var(--emerald-text);
  font-weight: 700;
}

.status-bad {
  color: var(--rose-text);
  font-weight: 700;
}

/* Modern Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

/* Document Repository Table - Zero Horizontal Scroll, 100% Fluid & Readable */
.table-wrap.doc-table-wrap {
  overflow-x: hidden !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

table.doc-table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: auto;
}

table.doc-table th,
table.doc-table td {
  padding: 10px 8px;
}

table.doc-table th:first-child,
table.doc-table td:first-child {
  padding-left: 12px;
}

table.doc-table th:last-child,
table.doc-table td:last-child {
  padding-right: 12px;
}

table.doc-table .actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

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

th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: #f8fafc;
}

td small {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
}

.text-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.text-link:hover {
  text-decoration: underline;
  color: #1d4ed8;
}

/* Semantic Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  letter-spacing: 0.02em;
}

.badge-ok,
.badge-valide,
[data-badge="VALIDE"] {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
}

.badge-a_indexer,
[data-badge="A_INDEXER"] {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.badge-indexe,
[data-badge="INDEXE"] {
  background: var(--blue-bg);
  border-color: var(--blue-border);
  color: var(--blue-text);
}

.badge-archive,
[data-badge="ARCHIVE"] {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

.badge-a_corriger,
[data-badge="A_CORRIGER"],
.badge-danger {
  background: var(--rose-bg);
  border-color: var(--rose-border);
  color: var(--rose-text);
}

.badge-off {
  color: var(--text-light);
}

/* Alerts */
.alert {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.alert-success {
  border-color: var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-text);
}

.alert-error {
  border-color: var(--rose-border);
  background: var(--rose-bg);
  color: var(--rose-text);
}

/* Detail Grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.detail-grid>div {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
}

.detail-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-main);
}

.prose {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 14px;
}

/* Tree view in Folders */
.tree-name {
  padding-left: calc(var(--depth, 0) * 20px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-name small {
  margin: 0;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.folder-icon {
  font-size: 16px;
  color: #eab308;
}

.sticky-panel {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 105px);
  overflow-y: auto;
}

/* Operation Menu Popover */
.op-menu {
  position: relative;
}

.op-menu>summary {
  list-style: none;
}

.op-menu>summary::-webkit-details-marker {
  display: none;
}

.op-pop {
  position: absolute;
  z-index: 50;
  right: 0;
  top: calc(100% + 6px);
  min-width: 290px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-xl);
  animation: popIn 0.15s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.op-pop.right {
  right: 0;
}

/* Modals (Div Backdrops) */
div.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal.hidden,
div.modal.hidden,
dialog.modal.hidden,
dialog.modal:not([open]) {
  display: none !important;
}

.modal-card {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-modal);
  animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-card.modal-preview-card {
  width: min(1000px, 95vw);
  height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
}

.preview-body {
  flex: 1;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f8fafc;
  display: grid;
  place-items: center;
  margin-top: 12px;
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Drag & Drop Visual Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.dropzone.dragover {
  transform: scale(1.01);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 6px;
  display: block;
}

.dropzone-text {
  font-weight: 600;
  color: var(--text-main);
  display: block;
  font-size: 13.5px;
}

.dropzone-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  display: block;
  margin-top: 3px;
}

.dropzone-file-info {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
}

/* Copyable Reference Pill */
.copyable {
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.copyable:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.copyable::after {
  content: "📋";
  font-size: 10px;
  opacity: 0.6;
}

/* Toast Container & Notification */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.25s ease-in 2.75s forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Instant Table Live Filter Input */
.table-live-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.table-live-filter input {
  max-width: 320px;
}

#doc-preview-modal .table-live-filter,
.docx-paper .table-live-filter,
.doc-preview-card .table-live-filter,
.doc-preview-stage .table-live-filter,
.doc-viewer-container .table-live-filter,
.modal .table-live-filter,
dialog .table-live-filter,
[data-no-filter] .table-live-filter,
[data-no-filter]+.table-live-filter {
  display: none !important;
}

/* Scan status */
.scan-status {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  font-size: 13px;
}

/* Permissions grid */
.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.permission-grid fieldset,
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.permission-grid legend,
fieldset legend {
  font-weight: 700;
  padding: 0 6px;
  color: var(--text-main);
}

/* Guest / Login Layout */
.guest-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 10%, #f1f5f9 0%, #e2e8f0 100%);
}

.guest-card {
  width: min(530px, 100%);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 34px;
  box-shadow: var(--shadow-xl);
}

.guest-logo {
  margin-bottom: 24px;
}

.guest-head h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.guest-head p {
  color: var(--text-muted);
  margin: 6px 0 24px;
  font-size: 14px;
}

.center {
  text-align: center;
}

.guest-card .btn-large {
  width: 100%;
  margin-top: 8px;
}

/* Guest Test Accounts (Recette Locale) */
.test-accounts-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
}

.test-accounts-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.test-accounts-divider::before,
.test-accounts-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.test-accounts-divider span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.test-accounts-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  line-height: 1.45;
  color: #92400e;
}

.test-accounts-alert strong {
  color: #78350f;
}

.test-accounts-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}

.test-accounts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (max-width: 480px) {
  .test-accounts-grid {
    grid-template-columns: 1fr;
  }

  .guest-card {
    padding: 24px 18px;
  }
}

.test-account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-main);
  font-family: inherit;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.test-account-btn:hover {
  background: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 10px -2px rgba(59, 130, 246, 0.12);
  transform: translateY(-1px);
}

.test-account-btn:active {
  transform: translateY(0);
}

.test-account-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
}

.test-account-btn.is-active {
  border-color: #10b981;
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.test-account-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.test-account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.test-account-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.test-account-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.test-account-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.test-account-arrow {
  color: var(--text-light);
  font-size: 12px;
  transition: transform var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.test-account-btn:hover .test-account-arrow {
  color: #3b82f6;
  transform: translateX(2px);
}

/* Modal & Dialog UI (Accessible, High-Contrast & 100% Opaque) */
dialog.modal {
  display: none;
  background: #ffffff !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35) !important;
  padding: 0 !important;
  margin: auto !important;
  overflow: hidden !important;
  max-height: 90vh;
  z-index: 9999;
}

dialog.modal:not([open]),
dialog.modal.hidden {
  display: none !important;
}

dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.65) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
}

dialog.modal[open]:not(.hidden) {
  display: flex !important;
  flex-direction: column !important;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

dialog.modal form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 18px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  background: #ffffff !important;
  color: var(--text-main);
}

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Scan Progress & Status UI */
.scan-status {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.45;
}

.scan-progress-wrap {
  margin: 12px 0;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.scan-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.scan-progress-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   ARBORESCENCE & EXPLORATEUR DE DOSSIERS INSTITUTIONNEL (SATECH PRO)
   ========================================================================== */
.tree-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
}

.tree-search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.tree-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-light);
  pointer-events: none;
}

.tree-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-body);
  font-size: 13px;
  transition: var(--transition-fast);
}

.tree-search-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.tree-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.view-toggle-pills {
  display: inline-flex;
  background: var(--bg-body);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  cursor: pointer;
}

.view-toggle-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

/* Tree Table & Row Components */
.tree-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.tree-node-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color var(--transition-fast);
  position: relative;
}

.tree-node-row:hover {
  background-color: #f8fafc;
}

.tree-node-row.selected {
  background-color: #f0fdfa;
  border-left: 3px solid #0f766e;
}

.tree-cell-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-left: calc(var(--depth, 0) * 26px);
  position: relative;
}

/* Lignes de guide hiérarchique */
.tree-node-row[data-depth="1"] .tree-cell-main::before,
.tree-node-row[data-depth="2"] .tree-cell-main::before,
.tree-node-row[data-depth="3"] .tree-cell-main::before {
  content: "";
  position: absolute;
  left: calc((var(--depth, 1) - 1) * 26px + 12px);
  top: -12px;
  bottom: 50%;
  width: 12px;
  border-left: 1.5px dashed #cbd5e1;
  border-bottom: 1.5px dashed #cbd5e1;
  border-bottom-left-radius: 4px;
}

.tree-toggle-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: var(--text-light);
  cursor: pointer;
  transition: transform 0.2s ease, color var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
}

.tree-toggle-caret:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.tree-toggle-caret.expanded svg {
  transform: rotate(90deg);
}

.tree-toggle-caret svg {
  transition: transform 0.2s ease;
}

.tree-toggle-spacer {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}

.tree-folder-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #3b82f6;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.tree-node-row:hover .tree-folder-badge-icon {
  transform: scale(1.05);
}

.tree-folder-badge-icon.bailleur-gavi {
  background: #eff6ff;
  color: #2563eb;
}

.tree-folder-badge-icon.bailleur-fm {
  background: #fef2f2;
  color: #dc2626;
}

.tree-folder-badge-icon.bailleur-bmgf {
  background: #fffbeb;
  color: #d97706;
}

.tree-folder-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tree-folder-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tree-folder-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.tree-folder-title:hover {
  color: #2563eb;
}

.tree-folder-code {
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.tree-folder-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.tree-cell-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-doc-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.tree-doc-count-pill.has-docs {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.tree-cell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Grille de cartes de dossiers (Vue alternative) */
.folder-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.folder-card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
}

.folder-card-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.folder-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.folder-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  margin-top: 12px;
}

/* Badges & Status Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.badge-ok,
.badge-valide {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.badge-a_indexer,
.badge-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.badge-danger,
.badge-a_corriger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.badge-archive,
.badge-info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.badge-indexe {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

/* Document Table and Elements */
.doc-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.doc-row-icon.mime-pdf {
  background: #fef2f2;
  color: #dc2626;
}

.doc-row-icon.mime-image {
  background: #eff6ff;
  color: #2563eb;
}

.doc-row-icon.mime-word {
  background: #eff6ff;
  color: #1d4ed8;
}

.doc-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  display: block;
}

.doc-item-title:hover {
  color: #2563eb;
}

.doc-subtext {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* Filter pills bar */
.status-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.status-pill-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.status-pill-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.status-pill-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* ======================================================== */
/* Modernized Referentiels & Nomenclatures UI               */
/* ======================================================== */
.ref-tabs-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.ref-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.ref-tab-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.ref-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.ref-tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-muted);
}

.ref-tab-btn.active .ref-tab-count {
  background: #eff6ff;
  color: var(--primary);
}

.ref-tab-pane {
  display: none;
  animation: fadeIn 0.15s ease-out;
}

.ref-tab-pane.active {
  display: block;
}

.ref-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.ref-form-panel {
  position: sticky;
  top: 86px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ref-code-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.ref-mask-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #ecfeff;
  color: #0891b2;
  border: 1px solid #a5f3fc;
  word-break: break-all;
}

/* ======================================================== */
/* Modernized RBAC Roles & Permissions Matrix UI            */
/* ======================================================== */
.rbac-tabs-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.rbac-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.rbac-tab-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.rbac-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.rbac-tab-pane {
  display: none;
  animation: fadeIn 0.15s ease-out;
}

.rbac-tab-pane.active {
  display: block;
}

/* Global Cross Matrix Table */
.rbac-matrix-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.rbac-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.rbac-matrix-table th,
.rbac-matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  vertical-align: middle;
}

.rbac-matrix-table thead th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid #e2e8f0;
}

.rbac-matrix-table tbody tr:hover td {
  background: #f8fafc;
}

.rbac-matrix-table .sticky-col {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 5;
  font-weight: 600;
  min-width: 250px;
}

.rbac-matrix-table thead .sticky-col {
  z-index: 15;
  background: #f8fafc;
}

.matrix-check-cell {
  text-align: center;
  width: 110px;
}

.matrix-badge-yes {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-weight: 800;
  font-size: 13px;
}

.matrix-badge-no {
  display: inline-block;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1;
}

.matrix-domain-row td {
  background: #f1f5f9 !important;
  font-weight: 700;
  font-size: 12px;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
}

/* Role Selector Pills */
.role-pills-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.role-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.role-pill-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.role-pill-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  box-shadow: var(--shadow-sm);
}

.role-pill-btn .role-badge-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
}

.role-pill-btn.active .role-badge-count {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Permission group card */
.perm-group-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.perm-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
}

.perm-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 14px;
}

.perm-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  cursor: pointer;
}

.perm-checkbox-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.perm-checkbox-item.mandatory {
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* ======================================================== */
/* User Management & Modern Modal UI                        */
/* ======================================================== */
.user-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #bfdbfe;
}

.user-avatar-circle.lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.status-indicator-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  margin-right: 5px;
}

.status-indicator-dot.online {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }

  70% {
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* User Manage Modal */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.app-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.app-modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-modal-overlay.active .app-modal-card {
  transform: scale(1);
}

.app-modal-head {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.app-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

.app-modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.modal-section-divider {
  border-top: 1px dashed var(--border);
  margin: 18px 0;
  padding-top: 16px;
}

/* ======================================================== */
/* Audit Center & JSON Inspector UI                        */
/* ======================================================== */
.audit-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

.audit-chip.highlight {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.audit-chip.danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.audit-json-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #334155;
  white-space: pre-wrap;
  word-break: break-all;
}

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

.audit-key-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.audit-key-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.audit-key-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
}

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

  .ref-form-panel {
    position: static;
  }
}

/* ==========================================================================
   MODULE PARAMÈTRES & CONFIGURATION INSTITUTIONNELLE
   ========================================================================== */
.settings-nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.settings-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.settings-nav-tab:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.02);
}

.settings-nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #f8fafc;
}

.settings-tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.settings-tab-pane.active {
  display: block;
}

.settings-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.color-presets-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.color-preset-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
}

.color-preset-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--primary);
}

.color-preset-btn.selected {
  transform: scale(1.15);
  box-shadow: 0 0 0 2.5px #0f172a;
}

.live-theme-preview {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.font-preview-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
  transition: font-family 0.2s ease;
}

.scanner-diagnostic-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scanner-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
}

.system-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.system-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo-preview-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
}

/* Cartes de formules de sauvegarde dans la modale */
.backup-formula-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.backup-formula-card:hover {
  border-color: #0f766e;
  background: #f0fdfa;
}

.backup-formula-card.selected,
.backup-formula-card:has(input:checked) {
  border-color: #0f766e;
  background: #f0fdfa;
  box-shadow: 0 0 0 1px #0f766e;
}

.backup-formula-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

/* ==========================================================================
   MODULE RAPPORTS & ANALYTIQUE INSTITUTIONNELLE
   ========================================================================== */
.report-stat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.report-stat-row:last-child {
  border-bottom: none;
}

.report-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.report-progress-track {
  width: 100%;
  height: 7px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.report-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease-out;
}

.report-activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  padding: 10px 0 20px 0;
  overflow-x: auto;
}

.report-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 22px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.report-chart-bar {
  width: 100%;
  background: #2563eb;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
  min-height: 4px;
}

.report-chart-bar:hover {
  background: #1d4ed8;
}

.report-chart-label {
  font-size: 9.5px;
  color: #64748b;
  margin-top: 4px;
  white-space: nowrap;
}

/* Print optimizations */
@media print {

  .sidebar,
  .topbar,
  .head-actions,
  .filter-toolbar,
  .settings-nav-tabs,
  .btn,
  form,
  input,
  select {
    display: none !important;
  }

  .app-shell,
  .content-wrap {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  .panel {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    margin-bottom: 20px !important;
    break-inside: avoid;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* Responsive queries */
@media (max-width: 1366px) {
  .app-shell {
    grid-template-columns: 220px 1fr;
  }

  .content-wrap {
    padding: 16px 20px;
  }

  .grid-2.wide-left {
    grid-template-columns: minmax(0, 1.8fr) minmax(310px, 0.9fr);
    gap: 16px;
  }

  .panel {
    padding: 16px;
  }
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ref-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .permission-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1080px) {
  .grid-2.wide-left {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -300px;
    z-index: 90;
    width: 270px;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.12);
  }

  body.menu-open .sidebar {
    left: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .content-wrap {
    padding: 18px;
  }

  .grid-2,
  .grid-2.wide-left,
  .grid-3 {
    grid-template-columns: 1fr;
  }

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

  .health-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    padding: 0 18px;
  }

  .page-head {
    flex-direction: column;
  }

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

@media (max-width: 650px) {
  body {
    font-size: 13px;
  }

  .content-wrap {
    padding: 14px;
  }

  .panel {
    padding: 16px;
    border-radius: var(--radius-md);
  }

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

  .filter-grid,
  .ref-grid,
  .permission-grid,
  .form-row,
  .detail-grid,
  .health-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .head-actions {
    width: 100%;
  }

  .head-actions .btn {
    flex: 1;
  }

  .op-pop {
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 14px;
    min-width: 0;
  }

  .sidebar {
    width: 260px;
  }

  .guest-card {
    padding: 24px;
  }
}

/* =========================================================================
   VISIONNEUSE MULTI-FORMATS & APERÇU DIRECT IN-SITU (WORD, PDF, IMAGES, CSV)
   ========================================================================= */
.doc-preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.doc-preview-card {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35);
  width: 94vw;
  max-width: 1280px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.25s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.doc-preview-card.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
  padding: 0;
}

.doc-preview-head {
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.doc-preview-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #f1f5f9;
  position: relative;
}

.doc-preview-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #cbd5e1;
}

.doc-preview-stage.white-stage {
  background: #f8fafc;
}

.doc-preview-drawer {
  width: 320px;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: margin-right 0.2s ease;
}

.doc-preview-drawer.hidden {
  display: none;
}

.docx-paper {
  background: #ffffff;
  width: 100%;
  max-width: 820px;
  min-height: 800px;
  margin: 30px auto;
  padding: 50px 60px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-family: 'Segoe UI', Calibri, Arial, sans-serif;
  color: #1e293b;
  line-height: 1.65;
  box-sizing: border-box;
}

.docx-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.docx-table th,
.docx-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
}

.image-preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 20px;
}

.image-preview-element {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}

.doc-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 8px;
}

.doc-preview-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.doc-preview-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.doc-preview-btn.active {
  background: #2563eb;
  color: #ffffff;
}