/* ============================================================
   e-Parapheur — Stylesheet
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette — Midnight + Teal, palette 2026 */
  --primary: #0B1F3A;          /* midnight navy */
  --primary-light: #16335A;
  --accent: #0D9488;           /* teal 600 */
  --accent-hover: #0F766E;     /* teal 700 */
  --accent-soft: #CCFBF1;      /* teal 100 */
  --gold: #D4A574;             /* accent sable (citations, highlights) */
  --success: #10B981;
  --success-soft: #D1FAE5;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;
  --danger:  #EF4444;
  --danger-soft: #FEE2E2;
  --info:    #3B82F6;
  --info-soft: #DBEAFE;

  /* Surfaces & texte */
  --bg: #F6F8FB;
  --bg-alt: #EEF2F7;
  --surface: #FFFFFF;
  --surface-muted: #F8FAFC;
  --border: #E5EAF2;
  --border-strong: #D1D9E6;
  --text: #0F172A;
  --text-soft: #334155;
  --text-muted: #64748B;

  /* Sidebar — dégradé midnight */
  --sidebar-bg: linear-gradient(180deg, #0B1F3A 0%, #0A1A30 60%, #07142A 100%);
  --sidebar-solid: #0B1F3A;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: linear-gradient(135deg, #0D9488 0%, #0F766E 100%);
  --sidebar-text: #B6C4D8;
  --sidebar-text-active: #ffffff;

  /* Rayons, ombres, transitions */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 4px 14px rgba(15,23,42,0.05);
  --shadow-md: 0 4px 18px rgba(15,23,42,0.08), 0 2px 6px rgba(15,23,42,0.05);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.14), 0 4px 12px rgba(15,23,42,0.06);
  --shadow-glow: 0 0 0 3px rgba(13,148,136,0.18);
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 260px;
  --topbar-height: 64px;

  /* Typographie */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

body { font-family: var(--font-sans); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; overflow-x: hidden; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* === SCREENS === */
.screen { display: none; }
.screen.active { display: flex; }

/* === LOGIN === */
#login-screen {
  min-height: 100vh; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(13,148,136,0.28) 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(212,165,116,0.16) 0%, transparent 55%),
    linear-gradient(135deg, #07142A 0%, #0B1F3A 55%, #16335A 100%);
  position: relative; overflow: hidden;
}
#login-screen::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  pointer-events: none;
}
#login-screen::after {
  content: ''; position: absolute; width: 420px; height: 420px; right: -120px; top: -120px;
  background: radial-gradient(circle, rgba(13,148,136,0.35), transparent 70%);
  filter: blur(20px); pointer-events: none;
}

.login-container {
  background: rgba(255,255,255,0.98);
  border-radius: var(--radius-xl);
  padding: 2.75rem 2.5rem 2rem;
  width: 420px; max-width: calc(100% - 2rem);
  box-shadow: 0 30px 80px -20px rgba(7,20,42,0.55), 0 10px 30px rgba(7,20,42,0.25);
  position: relative; z-index: 1;
  border: 1px solid rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
}
.login-container::before {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius-xl);
  padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(13,148,136,0.4), transparent 40%, rgba(212,165,116,0.3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.logo-icon { width: 72px; height: 72px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 18px; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; box-shadow: 0 8px 24px rgba(13,148,136,0.4); }
.logo-icon i { font-size: 2rem; color: #fff; }
.login-logo h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.login-logo p { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

.login-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-weight: 600; font-size: 0.8125rem; color: var(--text-soft); display: flex; align-items: center; gap: 0.5rem; letter-spacing: 0.01em; }
.form-group label i { color: var(--accent); width: 14px; }
.form-group input {
  padding: 0.75rem 0.95rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  background: var(--surface-muted); font-size: 0.9375rem; color: var(--text);
}
.form-group input::placeholder { color: #94A3B8; }
.form-group input:hover { border-color: var(--border-strong); }
.form-group input:focus { border-color: var(--accent); background: #fff; box-shadow: var(--shadow-glow); }
.login-footer { text-align: center; margin-top: 1.5rem; color: var(--text-muted); padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* === LAYOUT === */
#app-screen { height: 100vh; width: 100%; overflow: hidden; flex-direction: row; }

.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  transition: width var(--transition-slow); z-index: 100; flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
  position: relative;
}
.sidebar::after {
  content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(13,148,136,0.4) 40%, rgba(13,148,136,0.4) 60%, transparent);
  opacity: 0.6;
}
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .menu-label, .sidebar.collapsed .menu-item span:not(.badge), .sidebar.collapsed .user-details, .sidebar.collapsed .sidebar-logo span { display: none; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 0.75rem; }
.sidebar.collapsed .badge { display: none; }

.sidebar-header { padding: 1.125rem 1rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: -0.3px; }
.sidebar-logo i { font-size: 1.25rem; color: var(--accent); flex-shrink: 0; }
.sidebar-toggle {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  color: var(--sidebar-text); cursor: pointer; padding: 0.45rem 0.55rem;
  border-radius: 8px; transition: all var(--transition);
}
.sidebar-toggle:hover { background: rgba(13,148,136,0.2); color: #fff; border-color: rgba(13,148,136,0.4); }

.sidebar-menu { flex: 1; padding: 1rem 0.7rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.25rem; }
.menu-section { display: flex; flex-direction: column; gap: 0.2rem; }
.menu-label { font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(182,196,216,0.45); padding: 0 0.6rem 0.375rem; }

.menu-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.625rem 0.8rem; border-radius: 10px;
  color: var(--sidebar-text);
  transition: all var(--transition); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  font-size: 0.875rem; font-weight: 500; position: relative;
  letter-spacing: 0.005em;
}
.menu-item::before {
  content: ''; position: absolute; left: -0.7rem; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0;
  background: var(--accent); transition: transform var(--transition);
}
.menu-item:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.active {
  background: var(--sidebar-active-bg); color: #fff;
  box-shadow: 0 6px 18px -6px rgba(13,148,136,0.55);
}
.menu-item.active::before { transform: translateY(-50%) scaleY(1); }
.menu-item i { width: 18px; text-align: center; font-size: 1rem; flex-shrink: 0; opacity: 0.9; }
.menu-item.active i { opacity: 1; }
.menu-item span { flex: 1; }

.sidebar-footer { padding: 0.9rem 0.8rem; border-top: 1px solid rgba(255,255,255,0.06); }
.user-info {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem; border-radius: 10px;
  background: rgba(255,255,255,0.03);
  transition: background var(--transition);
}
.user-info:hover { background: rgba(255,255,255,0.06); }
.user-avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex-shrink: 0; box-shadow: 0 3px 10px rgba(13,148,136,0.35); letter-spacing: 0.02em; }
.user-avatar-sm { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; box-shadow: 0 2px 8px rgba(13,148,136,0.3); letter-spacing: 0.02em; }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.8125rem; font-weight: 600; color: #fff; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-role { font-size: 0.6875rem; color: var(--sidebar-text); }

.main-content { flex: 1; display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; background: var(--bg); }
.topbar {
  height: var(--topbar-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.breadcrumb { font-size: 0.9375rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.breadcrumb .sep { color: var(--text-muted); margin: 0 0.5rem; font-weight: 400; }
.breadcrumb .sub { font-weight: 500; color: var(--text-muted); }

.page-content { flex: 1; overflow-y: auto; padding: 1.75rem; }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 0.875rem; line-height: 1.25;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none; letter-spacing: 0.005em;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8125rem; border-radius: 8px; }
.btn-lg { padding: 0.85rem 1.35rem; font-size: 0.9375rem; border-radius: 12px; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff; box-shadow: 0 4px 12px -2px rgba(13,148,136,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover { box-shadow: 0 8px 22px -4px rgba(13,148,136,0.5), inset 0 1px 0 rgba(255,255,255,0.2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; box-shadow: 0 4px 12px -2px rgba(16,185,129,0.35); }
.btn-success:hover { box-shadow: 0 8px 22px -4px rgba(16,185,129,0.5); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #DC2626); color: #fff; box-shadow: 0 4px 12px -2px rgba(239,68,68,0.35); }
.btn-danger:hover { box-shadow: 0 8px 22px -4px rgba(239,68,68,0.5); transform: translateY(-1px); }
.btn-warning { background: linear-gradient(135deg, var(--warning), #D97706); color: #fff; box-shadow: 0 4px 12px -2px rgba(245,158,11,0.35); }
.btn-warning:hover { box-shadow: 0 8px 22px -4px rgba(245,158,11,0.5); transform: translateY(-1px); }
.btn-collab { background: linear-gradient(135deg, #FF6F3C, #ff8c42); color: #fff; box-shadow: 0 4px 12px -2px rgba(255,111,60,0.35); }
.btn-collab:hover { box-shadow: 0 8px 22px -4px rgba(255,111,60,0.5); transform: translateY(-1px); }

.btn-outline { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: #fff; box-shadow: 0 4px 12px -2px rgba(13,148,136,0.4); }
.btn-ghost { background: none; border: none; color: var(--text-muted); padding: 0.4rem 0.6rem; }
.btn-ghost:hover { color: var(--text); background: var(--bg-alt); }

.btn-icon {
  background: transparent; border: 1px solid transparent;
  cursor: pointer; padding: 0.55rem;
  border-radius: 10px; color: var(--text-soft);
  transition: all var(--transition);
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
}
.btn-icon:hover { color: var(--accent); background: var(--accent-soft); border-color: rgba(13,148,136,0.18); }

.btn-text { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 0.5rem; border-radius: 10px; transition: all var(--transition); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.btn-text:hover { color: var(--danger); background: var(--danger-soft); }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; line-height: 1; letter-spacing: 0.02em; }
.badge-danger { background: var(--danger); color: #fff; box-shadow: 0 2px 6px rgba(239,68,68,0.35); }
.badge-success { background: var(--success); color: #fff; box-shadow: 0 2px 6px rgba(16,185,129,0.35); }
.badge-warning { background: var(--warning); color: #fff; box-shadow: 0 2px 6px rgba(245,158,11,0.35); }
.badge-info { background: var(--info); color: #fff; }
.badge-muted { background: var(--bg-alt); color: var(--text-muted); }
.badge-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(13,148,136,0.35); }
.badge-purple  { background: #A855F7; color: #fff; }

/* === CARDS === */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 1.4rem; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.9375rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.6rem; letter-spacing: -0.01em; }
.card-title i {
  color: var(--accent); background: var(--accent-soft);
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
}

/* === STATS GRID === */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; margin-bottom: 1.75rem; }
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 4px;
  border-radius: 4px 0 0 4px;
}
.stat-card.blue::before { background: linear-gradient(180deg, var(--accent), var(--accent-hover)); }
.stat-card.green::before { background: linear-gradient(180deg, var(--success), #059669); }
.stat-card.orange::before { background: linear-gradient(180deg, var(--warning), #D97706); }
.stat-card.red::before { background: linear-gradient(180deg, var(--danger), #DC2626); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.04);
}
.stat-card.blue .stat-icon { background: var(--accent-soft); color: var(--accent-hover); }
.stat-card.green .stat-icon { background: var(--success-soft); color: #047857; }
.stat-card.orange .stat-icon { background: var(--warning-soft); color: #B45309; }
.stat-card.red .stat-icon { background: var(--danger-soft); color: #B91C1C; }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.85rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.35rem; font-weight: 500; }

/* === TABLES === */
.table-container { overflow-x: auto; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-muted); }
th { padding: 0.85rem 1.1rem; text-align: left; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0.95rem 1.1rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 0.875rem; color: var(--text-soft); }
tr { transition: background var(--transition); }
tr:hover td { background: var(--surface-muted); }
tr:last-child td { border-bottom: none; }

/* === DOCUMENT LIST === */
.doc-row { cursor: pointer; transition: background var(--transition); }
.doc-row:hover td { background: #f0f5ff; }
.doc-title-cell { display: flex; flex-direction: column; gap: 0.125rem; }
.doc-title { font-weight: 600; color: var(--text); font-size: 0.875rem; }
.doc-ref { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; }
.doc-sender { display: flex; align-items: center; gap: 0.5rem; }
.doc-sender .user-avatar { width: 24px; height: 24px; font-size: 0.625rem; }

.status-badge { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.7rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.status-pending { background: var(--warning-soft); color: #B45309; }
.status-signed { background: var(--success-soft); color: #047857; }
.status-refused { background: var(--danger-soft); color: #B91C1C; }
.status-visa { background: var(--accent-soft); color: var(--accent-hover); }

.urgent-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* === FILTERS === */
.filters-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.filter-tabs { display: flex; background: var(--bg-alt); border-radius: 10px; padding: 4px; gap: 2px; border: 1px solid var(--border); }
.filter-tab { padding: 0.45rem 1rem; border-radius: 7px; border: none; background: none; cursor: pointer; font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); transition: all var(--transition); }
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 2px 6px rgba(15,23,42,0.08), 0 0 0 1px var(--border); }
.search-input-wrap { position: relative; flex: 1; max-width: 320px; }
.search-input-wrap i { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.875rem; pointer-events: none; }
.search-input { width: 100%; padding: 0.6rem 0.9rem 0.6rem 2.4rem; border: 1px solid var(--border-strong); border-radius: 10px; outline: none; background: var(--surface); transition: border-color var(--transition), box-shadow var(--transition); font-size: 0.875rem; }
.search-input:focus { border-color: var(--accent); box-shadow: var(--shadow-glow); }

/* === CIRCUIT VISUALIZER === */
.circuit-flow { display: flex; align-items: center; gap: 0; flex-wrap: wrap; padding: 0.5rem 0; }
.circuit-step { display: flex; align-items: center; gap: 0; }
.step-node { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; }
.step-bubble { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.875rem; font-weight: 700; border: 2px solid; transition: all var(--transition); }
.step-bubble.type-visa { background: #eaf4fb; border-color: #2980b9; color: #1a5276; }
.step-bubble.type-signature { background: #eafaf1; border-color: #27ae60; color: #1a5c2a; }
.step-bubble.type-cachet { background: #fef9e7; border-color: #e67e22; color: #7d4a0f; }
.step-bubble.status-done { background: var(--success); border-color: var(--success); color: #fff; }
.step-bubble.status-current { box-shadow: 0 0 0 4px rgba(41,128,185,0.25); animation: stepPulse 2s infinite; }
@keyframes stepPulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(41,128,185,0.25); } 50% { box-shadow: 0 0 0 6px rgba(41,128,185,0.1); } }
.step-label { font-size: 0.6875rem; color: var(--text-muted); text-align: center; max-width: 80px; }
.step-connector { width: 40px; height: 2px; background: var(--border); position: relative; margin: 0 4px; flex-shrink: 0; }
.step-connector.done { background: var(--success); }
.step-connector::after { content: '▶'; position: absolute; right: -6px; top: 50%; transform: translateY(-50%); font-size: 0.5rem; color: inherit; }

/* === PDF VIEWER === */
.viewer-layout { display: flex; height: calc(100vh - var(--topbar-height) - 3rem); gap: 1rem; }
.viewer-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.viewer-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; padding: 0.625rem 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.toolbar-group { display: flex; align-items: center; gap: 0.25rem; }
.toolbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 0.25rem; }
.tool-btn { padding: 0.375rem 0.625rem; border: 1.5px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--text-muted); transition: all var(--transition); font-size: 0.875rem; display: flex; align-items: center; gap: 0.375rem; font-weight: 500; }
.tool-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.tool-btn.active { background: rgba(41,128,185,0.1); color: var(--accent); border-color: rgba(41,128,185,0.3); }
.zoom-display { font-size: 0.8125rem; font-weight: 700; color: var(--text); min-width: 50px; text-align: center; }
.page-nav { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-muted); }

.viewer-doc { flex: 1; overflow-y: auto; background: #525659; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); display: flex; flex-direction: column; align-items: center; padding: 1.5rem; gap: 1rem; position: relative; }

.pdf-page { background: #fff; width: 595px; min-height: 842px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); border-radius: 2px; position: relative; padding: 3rem 3.5rem; display: flex; flex-direction: column; }
.pdf-page.zoom-75 { width: 446px; min-height: 632px; padding: 2.25rem 2.625rem; }
.pdf-page.zoom-125 { width: 744px; min-height: 1053px; padding: 3.75rem 4.375rem; }
/* Viewer "page" wrapper for real uploaded files. Fixed width so DOCX/PDF
   keep a predictable A4-ish proportion independent of the side panel width.
   IMPORTANT: override .pdf-page's `min-height: 842px` and `display: flex`
   so the wrapper grows to fit multi-page DOCX content and the outer
   .viewer-doc scrolls. Width is fixed per zoom, height is intrinsic. */
.pdf-page.pdf-page-file { width: 794px; padding: 0; background: #fff; display: block; min-height: 1040px; height: auto; }
.pdf-page.pdf-page-file.zoom-75 { width: 596px; padding: 0; min-height: 1040px; }
.pdf-page.pdf-page-file.zoom-125 { width: 992px; padding: 0; min-height: 1040px; }
/* OnlyOffice inline viewer — needs a positioned parent with concrete height
   so the iframe (width:100%;height:100%) can resolve its dimensions. Using
   position:relative + fixed height prevents the collapse observed after
   visa when the editor re-mounts with a new document key. */
.oo-inline-wrap { position: relative; width: 100%; height: 900px; background: #f8fafc; }
.oo-inline-wrap > .oo-inline-target { position: absolute; inset: 0; width: 100%; height: 100%; }
.oo-inline-wrap > .oo-inline-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #f8fafc; z-index: 2; pointer-events: none; }

/* DOCX rendering — emulate a Word A4 page.
   794px ≈ 21cm at 96dpi. Margin 2.54cm (1 inch) ≈ 96px to match Word default.
   No `min-height` here: the container grows freely with the full document
   content (mammoth outputs a single continuous HTML flow, not paginated). */
.docx-page { background: #fff; padding: 96px 96px 64px 96px; }
.pdf-page.pdf-page-file.zoom-75 .docx-page { padding: 72px 72px 48px 72px; }
.pdf-page.pdf-page-file.zoom-125 .docx-page { padding: 120px 120px 80px 120px; }
.docx-render { font-family: "Calibri", "Carlito", Arial, sans-serif; font-size: 11pt; line-height: 1.5; color: #000; }
.docx-render h1, .docx-render h2, .docx-render h3 { color: #000; margin: 1rem 0 0.75rem; font-weight: 700; }
.docx-render h1 { font-size: 1.5rem; }
.docx-render h2 { font-size: 1.25rem; }
.docx-render h3 { font-size: 1.1rem; }
.docx-render h1.doc-title { text-align: center; font-size: 1.4rem; }
.docx-render p.doc-subtitle { text-align: center; color: #444; font-size: 1rem; margin-top: -0.25rem; }
.docx-render p { margin: 0 0 0.5rem; line-height: 1.5; }
.docx-render p.text-center { text-align: center; }
.docx-render p.text-right { text-align: right; }
.docx-render p.text-justify { text-align: justify; }
.docx-render table { border-collapse: collapse; margin: 0.75rem 0; width: 100%; }
.docx-render table td, .docx-render table th { border: 1px solid #999; padding: 0.375rem 0.5rem; vertical-align: top; }
.docx-render ul, .docx-render ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.docx-render img { max-width: 100%; height: auto; display: inline-block; }
.docx-render strong { font-weight: 700; }
.docx-render em { font-style: italic; }
.docx-render mark { background: #fff59d; color: inherit; padding: 0 2px; }
.docx-render a { color: #1a5c8e; text-decoration: underline; }

/* === ÉDITEUR DOCX ENRICHI (fallback Mammoth) === */
.docx-editor-wrap { background: #fff; }
.docx-editor-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 0.5rem 0.75rem; background: #f0f3f7;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; position: sticky; top: 0; z-index: 10;
}
.docx-editor-toolbar button {
  padding: 0.3rem 0.55rem; border: 1px solid transparent; border-radius: 4px;
  background: transparent; cursor: pointer; font-size: 0.875rem; color: var(--text);
  transition: background 0.15s, border-color 0.15s; line-height: 1;
}
.docx-editor-toolbar button:hover { background: #dde3ec; border-color: var(--border); }
.docx-editor-toolbar button.active { background: #d0e4f5; border-color: var(--accent); color: var(--accent); }
.docx-editor-toolbar .tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.docx-editor-toolbar .tb-select {
  padding: 0.25rem 0.375rem; border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.8125rem; background: #fff; cursor: pointer; color: var(--text);
}
.docx-editor-toolbar .tb-save {
  margin-left: auto; background: var(--accent) !important; color: #fff !important;
  border-color: var(--accent) !important; padding: 0.3rem 0.75rem !important; font-weight: 600;
}
.docx-editor-toolbar .tb-save:hover { background: var(--accent-hover) !important; }
.docx-editor-toolbar .tb-saved {
  margin-left: auto; background: var(--success) !important; color: #fff !important;
  border-color: var(--success) !important; padding: 0.3rem 0.75rem !important; font-weight: 600;
}
.docx-editable {
  font-family: "Calibri", "Carlito", Arial, sans-serif; font-size: 11pt;
  line-height: 1.5; color: #000; outline: none;
  padding: 96px 96px 64px 96px; min-height: 900px;
  caret-color: var(--accent);
}
.docx-editable:focus { box-shadow: inset 0 0 0 2px rgba(41,128,185,0.18); }
.docx-editable h1, .docx-editable h2, .docx-editable h3 { color: #000; margin: 1rem 0 0.75rem; font-weight: 700; }
.docx-editable h1 { font-size: 1.5rem; }
.docx-editable h2 { font-size: 1.25rem; }
.docx-editable h3 { font-size: 1.1rem; }
.docx-editable p { margin: 0 0 0.5rem; line-height: 1.5; }
.docx-editable table { border-collapse: collapse; margin: 0.75rem 0; width: 100%; }
.docx-editable table td, .docx-editable table th { border: 1px solid #999; padding: 0.375rem 0.5rem; vertical-align: top; }
.docx-editable ul, .docx-editable ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.docx-editable img { max-width: 100%; height: auto; }
.docx-editable strong { font-weight: 700; }
.docx-editable em { font-style: italic; }
.docx-editable mark { background: #fff59d; color: inherit; padding: 0 2px; }
.docx-editable a { color: #1a5c8e; text-decoration: underline; }
.pdf-header { border-bottom: 2px solid var(--primary); padding-bottom: 1rem; margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: flex-start; }
.pdf-org { font-size: 0.875rem; font-weight: 700; color: var(--primary); }
.pdf-org-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.pdf-logo-placeholder { width: 60px; height: 60px; border: 2px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.25rem; }
.pdf-body h2 { font-size: 1rem; font-weight: 800; text-align: center; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1.5rem; }
.pdf-body p { font-size: 0.8125rem; color: #333; line-height: 1.8; margin-bottom: 0.75rem; text-align: justify; }
.pdf-body .article { margin: 1rem 0; padding: 0.75rem; background: #f8fafc; border-left: 3px solid var(--accent); border-radius: 0 4px 4px 0; }
.pdf-body .article strong { font-size: 0.8125rem; color: var(--primary); }
.pdf-footer { margin-top: auto; padding-top: 2rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; align-items: flex-end; }
.signature-zone { width: 240px; border: 2px dashed var(--border); border-radius: 6px; padding: 0.75rem; text-align: center; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.375rem; font-size: 0.6875rem; color: var(--text-muted); transition: all var(--transition); cursor: pointer; overflow: hidden; }
.signature-zone:hover { border-color: var(--accent); background: rgba(41,128,185,0.04); }
.signature-zone.signed { border-color: var(--success); background: rgba(39,174,96,0.06); color: var(--success); }
.signature-zone img { max-width: 210px; max-height: 100px; object-fit: contain; display: block; margin: 0 auto; }
.sig-label { font-weight: 700; font-size: 0.75rem; }

.annotation-layer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.annotation-note { position: absolute; background: rgba(52,152,219,0.15); border: 2px solid var(--info); border-radius: 4px; padding: 0.375rem 0.5rem; font-size: 0.6875rem; color: var(--info); max-width: 160px; pointer-events: auto; cursor: pointer; }

/* === SIDE PANEL === */
.viewer-panel { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto; }
.panel-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-section-header { padding: 0.75rem 1rem; font-size: 0.8125rem; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.panel-section-header i { color: var(--accent); margin-right: 0.5rem; }
.panel-section-body { padding: 0.75rem 1rem; }

.meta-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 0.375rem 0; border-bottom: 1px solid #f0f3f7; gap: 0.5rem; }
.meta-item:last-child { border-bottom: none; }
.meta-key { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.meta-value { font-size: 0.75rem; color: var(--text); font-weight: 500; text-align: right; }

.action-btns { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; }

/* === CIRCUIT BUILDER === */
.circuit-builder { display: flex; gap: 1.5rem; }
.circuit-steps-list { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; }
.circuit-step-item { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; align-items: center; gap: 1rem; transition: all var(--transition); }
.circuit-step-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(41,128,185,0.1); }
.step-order-badge { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.875rem; color: #fff; flex-shrink: 0; }
.step-info { flex: 1; }
.step-name { font-weight: 700; font-size: 0.875rem; color: var(--text); }
.step-user { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.step-type-badge { padding: 0.2rem 0.625rem; border-radius: 20px; font-size: 0.6875rem; font-weight: 700; }
.type-visa { background: #eaf4fb; color: #1a5276; }
.type-signature { background: #eafaf1; color: #1e8449; }
.type-cachet { background: #fef9e7; color: #d35400; }
.step-drag { color: var(--text-muted); cursor: grab; padding: 0 0.25rem; }

/* === TRACKING === */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 1rem; padding: 0.875rem 0; position: relative; }
.timeline-item:not(:last-child)::after { content: ''; position: absolute; left: 17px; top: 48px; bottom: 0; width: 2px; background: var(--border); }
.timeline-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.875rem; flex-shrink: 0; z-index: 1; }
.timeline-icon.upload { background: rgba(52,152,219,0.15); color: var(--info); }
.timeline-icon.visa { background: rgba(41,128,185,0.15); color: var(--accent); }
.timeline-icon.signature { background: rgba(39,174,96,0.15); color: var(--success); }
.timeline-icon.cachet { background: rgba(230,126,34,0.15); color: var(--warning); }
.timeline-icon.refus { background: rgba(231,76,60,0.15); color: var(--danger); }
.timeline-icon.notification { background: rgba(108,117,125,0.15); color: var(--text-muted); }
.timeline-icon.login { background: rgba(52,152,219,0.12); color: var(--info); }
.timeline-body { flex: 1; }
.timeline-title { font-weight: 600; font-size: 0.875rem; color: var(--text); }
.timeline-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.timeline-comment { font-size: 0.8125rem; color: var(--text); margin-top: 0.375rem; background: #f8fafc; padding: 0.5rem 0.75rem; border-radius: var(--radius); border-left: 3px solid var(--border); }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(7,20,42,0.55); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: overlayIn 0.2s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.hidden { display: none; }
.modal-container { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 560px; max-width: calc(100vw - 2rem); max-height: calc(100vh - 4rem); display: flex; flex-direction: column; animation: modalIn 0.2s ease; }
.modal-container.modal-lg { width: 720px; }
.modal-container.modal-xl { width: 960px; }
.modal-container.modal-sm { width: 420px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.625rem; }
.modal-header h3 i { color: var(--accent); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.125rem; padding: 0.25rem; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { color: var(--danger); background: rgba(231,76,60,0.1); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; flex-shrink: 0; }

/* === SIGNATURE PAD === */
.sig-pad-container { border: 2px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; cursor: crosshair; }
.sig-pad-container canvas { display: block; }
.sig-pad-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; }
.sig-type-tabs { display: flex; gap: 0.5rem; }
.sig-type-tab { padding: 0.375rem 0.75rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 0.8125rem; font-weight: 600; background: none; cursor: pointer; color: var(--text-muted); transition: all var(--transition); }
.sig-type-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(41,128,185,0.06); }

/* === FORMS === */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-field { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }
.form-field label { font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.form-field input, .form-field select, .form-field textarea { padding: 0.5rem 0.75rem; border: 1.5px solid var(--border); border-radius: var(--radius); outline: none; background: var(--surface); transition: border-color var(--transition); }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(41,128,185,0.1); }
.form-field textarea { resize: vertical; min-height: 80px; }
.form-field .hint { font-size: 0.75rem; color: var(--text-muted); }

/* === ADMIN === */
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.admin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; text-align: center; cursor: pointer; transition: all var(--transition); }
.admin-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(41,128,185,0.15); transform: translateY(-2px); }
.admin-card-icon { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #fff; margin: 0 auto 0.75rem; }
.admin-card-title { font-weight: 700; color: var(--text); }
.admin-card-desc { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

/* === TOAST === */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.875rem 1.125rem; box-shadow: var(--shadow-lg); min-width: 280px; max-width: 380px; display: flex; align-items: flex-start; gap: 0.75rem; pointer-events: auto; animation: toastIn 0.3s ease; border-left: 4px solid var(--info); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }
.toast-content { flex: 1; }
.toast-title { font-weight: 700; font-size: 0.875rem; color: var(--text); }
.toast-msg { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.125rem; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); max-height: 0; padding: 0; margin: 0; } }

/* === NOTIFICATION DOT === */
.notification-dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }

/* === PROGRESS === */
.progress-bar { height: 6px; background: var(--border); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 20px; background: var(--accent); transition: width 0.5s ease; }

/* === PAGE HEADER === */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; gap: 1rem; flex-wrap: wrap; }
.page-header-left h2 { font-size: 1.55rem; font-weight: 800; color: var(--text); letter-spacing: -0.025em; }
.page-header-left p { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; }

/* === EMPTY STATE === */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem; color: var(--text-muted); text-align: center; }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 0.375rem; }
.empty-state p { font-size: 0.875rem; }

/* === UPLOAD ZONE === */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 2.5rem; text-align: center; cursor: pointer; transition: all var(--transition); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: rgba(41,128,185,0.04); }
.upload-zone i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 0.75rem; display: block; }
.upload-zone p { color: var(--text-muted); font-size: 0.875rem; }
.upload-zone strong { color: var(--accent); }

/* === UTILITY === */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* === RESPONSIVE === */
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -248px; top: 0; height: 100vh; transition: left var(--transition); }
  .sidebar.mobile-open { left: 0; }
  .main-content { margin-left: 0 !important; }
  .viewer-layout { flex-direction: column; height: auto; }
  .viewer-panel { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* =============================================================
   DESIGN SYSTEM v3 — "Institutionnel sobre"
   Override layer : palette, typo IBM Plex, sidebar/topbar/buttons/cards
   aplatis, badges à puce. Préserve les noms de classes existants.
   ============================================================= */
:root {
  /* Core palette — navy institutional */
  --navy-900: #0B1F3A;
  --navy-800: #12284A;
  --navy-700: #1B3563;
  --navy-600: #2A4575;
  --navy-500: #3D5A8C;
  --navy-100: #E8EDF5;
  --navy-50:  #F2F5FA;

  --ink-900: #0E1420;
  --ink-700: #2B3240;
  --ink-500: #5A6475;
  --ink-400: #8892A3;
  --ink-300: #B9C0CC;
  --ink-200: #D9DEE6;
  --ink-100: #EDF0F5;
  --ink-50:  #F7F8FA;

  --teal-700: #0A6153;
  --teal-600: #0E7C6B;
  --teal-500: #13998A;
  --teal-100: #D6EEE9;
  --teal-50:  #ECF7F5;

  --warn-700: #8A5A00;
  --warn-500: #C38100;
  --warn-100: #FBEFD4;
  --danger-700: #8B1F2E;
  --danger-500: #C2384A;
  --danger-100: #F8E2E5;
  --info-700: #0E4E8A;
  --info-500: #2E78C2;
  --info-100: #DDE9F7;

  /* Re-map des tokens hérités vers la nouvelle palette pour
     que TOUT l'existant s'aligne sans toucher au HTML/JS. */
  --primary: var(--navy-900);
  --primary-light: var(--navy-700);
  --accent: var(--teal-600);
  --accent-hover: var(--teal-700);
  --accent-soft: var(--teal-50);
  --success: var(--teal-600);
  --success-soft: var(--teal-50);
  --warning: var(--warn-500);
  --warning-soft: var(--warn-100);
  --danger:  var(--danger-500);
  --danger-soft: var(--danger-100);
  --info:    var(--info-500);
  --info-soft: var(--info-100);

  --bg: var(--ink-50);
  --bg-alt: var(--ink-100);
  --surface: #FFFFFF;
  --surface-muted: var(--ink-50);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-soft: var(--ink-700);
  --text-muted: var(--ink-500);

  --sidebar-bg: var(--navy-900);
  --sidebar-solid: var(--navy-900);
  --sidebar-hover: rgba(255,255,255,0.04);
  --sidebar-active-bg: rgba(255,255,255,0.06);
  --sidebar-text: var(--ink-300);
  --sidebar-text-active: #ffffff;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --shadow-xs: 0 1px 0 rgba(11,31,58,0.04);
  --shadow:    0 1px 2px rgba(11,31,58,0.06), 0 0 0 1px rgba(11,31,58,0.04);
  --shadow-md: 0 4px 12px rgba(11,31,58,0.06), 0 0 0 1px rgba(11,31,58,0.05);
  --shadow-lg: 0 12px 32px rgba(11,31,58,0.10), 0 0 0 1px rgba(11,31,58,0.06);
  --shadow-glow: 0 0 0 3px var(--teal-50);

  --sidebar-width: 252px;
  --topbar-height: 56px;

  --font-sans:    "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "IBM Plex Sans", "IBM Plex Serif", Georgia, serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

body { font-family: var(--font-sans); font-feature-settings: normal; font-size: 14px; }

/* ---- SIDEBAR (à plat, navy-900) ---- */
.sidebar { background: var(--navy-900) !important; border-right: 1px solid rgba(255,255,255,0.04); }
.sidebar::after { display: none; }
.sidebar-header { min-height: 68px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.menu-label { color: rgba(255,255,255,0.4); letter-spacing: 0.12em; font-weight: 500; font-size: 10.5px; }
.menu-item { font-weight: 450; font-size: 13.5px; border-radius: var(--radius); min-height: 36px; }
.menu-item::before { background: var(--teal-500); width: 2px; height: calc(100% - 16px); top: 8px; border-radius: 0 2px 2px 0; left: -10px; }
.menu-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.menu-item.active { background: rgba(255,255,255,0.06); color: #fff; box-shadow: none; }
.user-avatar { background: var(--teal-600) !important; border-radius: 50% !important; box-shadow: none !important; font-weight: 600; }
.user-avatar-sm { background: var(--teal-600) !important; border-radius: 50% !important; box-shadow: none !important; font-weight: 600; }

/* ---- TOPBAR (à plat, blanc) ---- */
.topbar { background: #fff !important; backdrop-filter: none; -webkit-backdrop-filter: none; height: var(--topbar-height); }
.breadcrumb { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.btn-icon { width: 34px; height: 34px; border-radius: var(--radius); color: var(--ink-500); }
.btn-icon:hover { background: var(--ink-100); color: var(--ink-900); border-color: transparent; }
.notification-dot { background: var(--danger-500); border: 1.5px solid #fff; }

/* ---- BUTTONS (à plat) ---- */
.btn { height: 36px; padding: 0 16px; border-radius: var(--radius); font-weight: 500; font-size: 13.5px; letter-spacing: normal; box-shadow: none !important; }
.btn:active { transform: none; }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12.5px; border-radius: var(--radius); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: var(--radius); }
.btn-primary { background: var(--teal-600) !important; color: #fff !important; border: 1px solid var(--teal-600); }
.btn-primary:hover { background: var(--teal-700) !important; transform: none; }
.btn-success { background: var(--teal-600) !important; border: 1px solid var(--teal-600); }
.btn-success:hover { background: var(--teal-700) !important; transform: none; }
.btn-danger  { background: #fff !important; color: var(--danger-700) !important; border: 1px solid var(--danger-100) !important; }
.btn-danger:hover { background: var(--danger-100) !important; transform: none; }
.btn-warning { background: var(--warn-500) !important; color: #fff; border: 1px solid var(--warn-500); }
.btn-warning:hover { background: var(--warn-700) !important; transform: none; }
.btn-outline { background: #fff; border: 1px solid var(--ink-200); color: var(--navy-900); }
.btn-outline:hover { background: var(--ink-50); border-color: var(--ink-300); color: var(--navy-900); }
.btn-outline-primary { background: transparent; border: 1px solid var(--teal-600); color: var(--teal-700); }
.btn-outline-primary:hover { background: var(--teal-50); color: var(--teal-700); box-shadow: none; }

/* ---- CARDS (à plat) ---- */
.card { box-shadow: none; border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 20px; }
.card:hover { box-shadow: none; }
.card-header { padding-bottom: 12px; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--ink-900); letter-spacing: -0.1px; }
.card-title i { background: var(--teal-50); color: var(--teal-700); width: 28px; height: 28px; border-radius: var(--radius-sm); font-size: 13px; }

/* ---- STATS / KPI (à plat) ---- */
.stat-card { box-shadow: none; border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 20px; }
.stat-card:hover { transform: none; box-shadow: none; border-color: var(--ink-300); }
.stat-card::before { width: 3px; border-radius: 0; }
.stat-card.blue::before   { background: var(--teal-500); }
.stat-card.green::before  { background: var(--teal-500); }
.stat-card.orange::before { background: var(--warn-500); }
.stat-card.red::before    { background: var(--danger-500); }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); box-shadow: none; font-size: 1.1rem; }
.stat-value { font-size: 2rem; font-weight: 600; color: var(--navy-900); letter-spacing: -0.8px; }
.stat-label { font-size: 11.5px; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }

/* ---- TABLES ---- */
.table-container { box-shadow: none; border-radius: var(--radius-lg); }
thead tr { background: var(--ink-50); }
th { padding: 12px 16px; font-size: 11.5px; letter-spacing: 0.06em; color: var(--ink-500); font-weight: 500; }
td { padding: 12px 16px; font-size: 13px; color: var(--ink-700); }
tr:hover td { background: var(--ink-50); }
.doc-row:hover td { background: var(--ink-50); }
.doc-title { color: var(--navy-900); }
.doc-ref { font-family: var(--font-mono); }

/* ---- BADGES (pilules à puce) ---- */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 11.5px; font-weight: 500; letter-spacing: 0.1px; border: 1px solid transparent; box-shadow: none !important; }
.badge-primary { background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-100); }
.badge-success { background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-100); }
.badge-danger  { background: var(--danger-100); color: var(--danger-700); border-color: #EFCED3; }
.badge-warning { background: var(--warn-100); color: var(--warn-700); border-color: #F2DEA6; }
.badge-info    { background: var(--info-100); color: var(--info-700); border-color: #C9DCEE; }
.badge-muted   { background: var(--ink-100); color: var(--ink-700); }

/* ---- STATUT PILLS (à puce fixe) ---- */
.status-badge { padding: 3px 10px; font-size: 11.5px; font-weight: 500; letter-spacing: 0.1px; border-radius: 12px; border: 1px solid transparent; }
.status-badge::before { box-shadow: none; }
.status-pending { background: var(--warn-100); color: var(--warn-700); border-color: #F2DEA6; }
.status-signed  { background: var(--teal-50);  color: var(--teal-700);  border-color: var(--teal-100); }
.status-refused { background: var(--danger-100); color: var(--danger-700); border-color: #EFCED3; }
.status-visa    { background: var(--navy-50); color: var(--navy-700); border-color: var(--navy-100); }

/* ---- FILTRES / SEGMENTS ---- */
.filter-tabs { background: var(--ink-100); border: none; padding: 2px; border-radius: var(--radius); }
.filter-tab { font-size: 12.5px; padding: 5px 12px; border-radius: 4px; font-weight: 500; }
.filter-tab.active { background: #fff; color: var(--navy-900); box-shadow: var(--shadow-xs), 0 1px 2px rgba(11,31,58,0.08); }
.search-input { height: 36px; border-radius: var(--radius); border: 1px solid var(--ink-200); }
.search-input:focus { border-color: var(--teal-600); box-shadow: var(--shadow-glow); }

/* ---- FORMULAIRES (à plat) ---- */
.form-group input, .form-group select, .form-group textarea {
  border-radius: var(--radius); border: 1px solid var(--ink-200) !important; background: #fff !important;
  font-size: 13.5px; padding: 8px 12px; height: 38px;
}
.form-group textarea { height: auto; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--teal-600) !important; box-shadow: var(--shadow-glow);
}
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--ink-700); }
.form-group label i { color: var(--teal-600); }

/* ---- PAGE HEADER ---- */
.page-header h2 { font-size: 24px; font-weight: 600; color: var(--navy-900); letter-spacing: -0.4px; }
.page-header p  { font-size: 13.5px; color: var(--ink-500); }

/* ---- LOGO DE LA SIDEBAR (conservé, pas d'effet brillant) ---- */
.sidebar-logo img { filter: brightness(0) invert(1) !important; }

/* ---- LOGIN (panneau à plat, grille 2 colonnes conservée via override) ---- */
#login-screen { background: var(--navy-900) !important; }
#login-screen::before { background-size: 48px 48px; opacity: 0.6; }
#login-screen::after { display: none; }
.login-container {
  background: #fff !important; border: 1px solid var(--ink-200);
  box-shadow: 0 30px 80px -20px rgba(11,31,58,0.45), 0 10px 30px rgba(11,31,58,0.2);
  border-radius: var(--radius-lg);
}
.login-container::before { display: none; }
.login-logo h1 { color: var(--navy-900); font-weight: 600; letter-spacing: -0.4px; }
.logo-icon { background: var(--teal-600) !important; box-shadow: none !important; border-radius: var(--radius) !important; }

/* ---- TOASTS ---- */
.toast { border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--ink-200); }

/* ---- MODALS ---- */
.modal-container { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--navy-900); }

/* ---- ONLYOFFICE PLEINE LARGEUR ----
   Quand un document Word est ouvert via OnlyOffice inline, le wrapper
   .pdf-page.pdf-page-file impose une largeur A4 (794px) qui tronque
   l'éditeur et force un scroll horizontal. On neutralise ces contraintes
   dès qu'un .oo-inline-wrap est présent à l'intérieur. */
.viewer-doc:has(.oo-inline-wrap) { padding: 0 !important; background: #f8fafc !important; }
.pdf-page.pdf-page-file:has(.oo-inline-wrap),
.pdf-page:has(.oo-inline-wrap) {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  background: #f8fafc !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
.oo-inline-wrap { height: calc(100vh - var(--topbar-height) - 140px) !important; min-height: 720px; width: 100%; }
.oo-inline-wrap > .oo-inline-target > iframe { width: 100% !important; height: 100% !important; border: 0; display: block; }

/* ---- TIMELINE (documents) ---- */
.timeline-step.done .step-bubble,
.step-bubble.status-done { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }


