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

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

:root {
  --primary: #1a3a5c;
  --primary-light: #2457a4;
  --accent: #2980b9;
  --accent-hover: #2471a3;
  --success: #27ae60;
  --warning: #e67e22;
  --danger: #e74c3c;
  --info: #3498db;
  --bg: #f0f3f7;
  --surface: #ffffff;
  --border: #dde3ec;
  --text: #1c2b3a;
  --text-muted: #6b7a90;
  --sidebar-bg: #0f2a45;
  --sidebar-hover: #1a3a5c;
  --sidebar-active: #2457a4;
  --sidebar-text: #c8d8e8;
  --sidebar-text-active: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --sidebar-width: 248px;
  --topbar-height: 60px;
}

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; overflow-x: hidden; }
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: linear-gradient(135deg, #0f2a45 0%, #1a3a5c 40%, #2457a4 100%); position: relative; overflow: hidden; }
#login-screen::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle at 30% 40%, rgba(41,128,185,0.25) 0%, transparent 50%), radial-gradient(circle at 70% 80%, rgba(15,42,69,0.5) 0%, transparent 50%); pointer-events: none; }

.login-container { background: var(--surface); border-radius: var(--radius-lg); padding: 2.5rem; width: 380px; box-shadow: var(--shadow-lg); position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.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 4px 16px rgba(36,87,164,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.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 600; font-size: 0.8125rem; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.form-group label i { color: var(--text-muted); width: 14px; }
.form-group input { padding: 0.625rem 0.875rem; border: 1.5px solid var(--border); border-radius: var(--radius); outline: none; transition: border-color var(--transition); background: #f8fafc; }
.form-group input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(41,128,185,0.12); }
.login-footer { text-align: center; margin-top: 1.5rem; color: var(--text-muted); }

/* === 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); z-index: 100; flex-shrink: 0; }
.sidebar.collapsed { width: 60px; }
.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: 1rem 1rem 0.75rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.08); }
.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: #5dade2; flex-shrink: 0; }
.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 0.375rem; border-radius: 6px; transition: background var(--transition); }
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.sidebar-menu { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.25rem; }
.menu-section { display: flex; flex-direction: column; gap: 0.25rem; }
.menu-label { font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: rgba(200,216,232,0.5); padding: 0 0.5rem; margin-bottom: 0.25rem; }

.menu-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.75rem; border-radius: var(--radius); color: var(--sidebar-text); transition: background var(--transition), color var(--transition); cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 0.875rem; font-weight: 500; position: relative; }
.menu-item:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.menu-item i { width: 18px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.menu-item span { flex: 1; }

.sidebar-footer { padding: 0.875rem 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.user-avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.6875rem; font-weight: 700; flex-shrink: 0; }
.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; }
.topbar { height: var(--topbar-height); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.breadcrumb { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.breadcrumb .sep { color: var(--text-muted); margin: 0 0.375rem; }
.breadcrumb .sub { font-weight: 400; color: var(--text-muted); }

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

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius); border: none; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all var(--transition); text-decoration: none; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(41,128,185,0.4); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #229954; box-shadow: 0 2px 8px rgba(39,174,96,0.4); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d35400; }
.btn-collab { background: linear-gradient(135deg, #FF6F3C, #ff8c42); color: #fff; }
.btn-collab:hover { background: linear-gradient(135deg, #e55a2b, #ff7a30); box-shadow: 0 2px 8px rgba(255,111,60,0.4); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: rgba(41,128,185,0.06); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: #fff; }
.btn-ghost { background: none; border: none; color: var(--text-muted); padding: 0.375rem 0.5rem; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }
.btn-icon { background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: var(--radius); color: var(--text-muted); transition: all var(--transition); position: relative; display: flex; align-items: center; justify-content: center; }
.btn-icon:hover { color: var(--text); background: var(--bg); }
.btn-text { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 0.375rem; border-radius: var(--radius); transition: color var(--transition); }
.btn-text:hover { color: var(--danger); }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 0.15rem 0.5rem; border-radius: 20px; font-size: 0.6875rem; font-weight: 700; line-height: 1; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-info { background: var(--info); color: #fff; }
.badge-muted { background: #e2e8f0; color: var(--text-muted); }
.badge-primary { background: var(--accent); color: #fff; }

/* === CARDS === */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 0.9375rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.card-title i { color: var(--accent); }

/* === STATS GRID === */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-card.blue .stat-icon { background: rgba(41,128,185,0.12); color: var(--accent); }
.stat-card.green .stat-icon { background: rgba(39,174,96,0.12); color: var(--success); }
.stat-card.orange .stat-icon { background: rgba(230,126,34,0.12); color: var(--warning); }
.stat-card.red .stat-icon { background: rgba(231,76,60,0.12); color: var(--danger); }
.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

/* === TABLES === */
.table-container { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; }
th { padding: 0.75rem 1rem; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0.875rem 1rem; border-bottom: 1px solid #f0f3f7; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
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.375rem; padding: 0.25rem 0.625rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.status-pending { background: #fef9e7; color: #d35400; border: 1px solid #fad7a0; }
.status-signed { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.status-refused { background: #fdf2f2; color: #c0392b; border: 1px solid #f5b7b1; }
.status-visa { background: #eaf4fb; color: #1a5276; border: 1px solid #aed6f1; }

.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: 1rem; flex-wrap: wrap; }
.filter-tabs { display: flex; background: #f0f3f7; border-radius: var(--radius); padding: 3px; gap: 2px; }
.filter-tab { padding: 0.375rem 0.875rem; border-radius: 6px; border: none; background: none; cursor: pointer; font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); transition: all var(--transition); }
.filter-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.search-input-wrap { position: relative; flex: 1; max-width: 280px; }
.search-input-wrap i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.875rem; pointer-events: none; }
.search-input { width: 100%; padding: 0.5rem 0.75rem 0.5rem 2.25rem; border: 1.5px solid var(--border); border-radius: var(--radius); outline: none; background: var(--surface); transition: border-color var(--transition); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(41,128,185,0.1); }

/* === 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. */
.pdf-page.pdf-page-file { width: 794px; padding: 0; background: #fff; }
.pdf-page.pdf-page-file.zoom-75 { width: 596px; padding: 0; }
.pdf-page.pdf-page-file.zoom-125 { width: 992px; padding: 0; }

/* DOCX rendering — emulate a Word A4 page.
   794px ≈ 21cm at 96dpi. Margin 2.54cm (1 inch) ≈ 96px to match Word default. */
.docx-page { background: #fff; padding: 96px 96px 64px 96px; min-height: 1000px; }
.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; }
.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: space-between; align-items: flex-end; }
.signature-zone { width: 160px; border: 2px dashed var(--border); border-radius: 6px; padding: 1rem; text-align: center; min-height: 80px; 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; }
.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); }
.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(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.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-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.5rem; }
.page-header-left h2 { font-size: 1.375rem; font-weight: 800; color: var(--text); }
.page-header-left p { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.125rem; }

/* === 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; }
