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

:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-sidebar: #1a2332;
    --color-sidebar-hover: #243044;
    --color-sidebar-active: #2a3a52;
    --color-primary: #2563eb;
    --color-primary-light: #dbeafe;
    --color-primary-dark: #1d4ed8;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-success: #059669;
    --color-success-bg: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --sidebar-width: 240px;
    --topbar-height: 64px;
    --transition: 0.2s ease;
}

html {
    font-size: 14px;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: #fff;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    letter-spacing: 0.5px;
}

.logo-subtitle {
    font-size: 11px;
    color: #64748b;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 16px 14px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #e2e8f0;
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: #fff;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-logout-btn:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.05);
}

.sidebar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #475569;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== TOP BAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    min-width: 240px;
}

.search-box svg {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--color-text);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--color-text-muted);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    padding: 28px 32px;
    flex: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ===== CONTENT HEADER ===== */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.content-subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.content-header-right {
    display: flex;
    gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-outline {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: #cbd5e1;
}

.btn-ghost {
    background: none;
    color: var(--color-text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.btn-danger-outline {
    background: var(--color-surface);
    color: var(--color-danger);
    border: 1px solid var(--color-border);
}

.btn-danger-outline:hover {
    background: var(--color-danger-bg);
    border-color: var(--color-danger);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-icon-danger:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.btn-reassign {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border: none; background: transparent;
    color: var(--color-text-muted);
    cursor: pointer; border-radius: 4px;
    margin-left: 4px; vertical-align: middle;
    transition: all .15s;
}
.btn-reassign:hover {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

/* ===== DOCUMENTS TABLE ===== */
.documents-table-wrapper {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.doc-table {
    width: 100%;
    min-width: 800px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.doc-table thead {
    background: var(--color-bg);
}

.doc-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.doc-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 13px;
    vertical-align: middle;
}

.doc-table tbody tr {
    cursor: pointer;
    transition: background var(--transition);
}

.doc-table tbody tr:hover {
    background: var(--color-border-light);
}

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

.doc-filename {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--color-text);
}

.doc-file-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-file-icon img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.doc-file-icon svg {
    color: var(--color-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-category {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-confidence-high {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-confidence-mid {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-confidence-low {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-status {
    font-size: 11px;
    padding: 2px 8px;
}
.badge-status-en_cours {
    background: var(--color-primary-light);
    color: var(--color-primary);
}
.badge-status-termine {
    background: var(--color-success-bg);
    color: var(--color-success);
}
.badge-status-annule {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.doc-summary-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-secondary);
    font-size: 13px;
}

/* ===== DOCUMENT TABLE WORKFLOW SUMMARY ===== */
.doc-wf-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.doc-wf-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.doc-wf-progress {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.doc-wf-holder {
    font-size: 11px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.doc-wf-role {
    font-weight: 700;
    font-size: 10px;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
}

.doc-date {
    color: var(--color-text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.doc-tokens {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ===== DOCUMENT TITLE ===== */
.detail-title-banner {
    grid-column: 1 / -1;
    margin-bottom: 8px;
}

.detail-title-banner h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.2px;
    line-height: 1.3;
}

.doc-title-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.3;
}

.doc-filename-sub {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-top: 1px;
}

/* ===== DOCUMENT DETAIL ===== */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.detail-body,
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    flex: 1;
}

.detail-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.detail-card-header {
    padding: 14px 20px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-card-body {
    padding: 20px;
}

.detail-image-preview {
    text-align: center;
    padding: 16px;
}

.detail-image-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.detail-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-meta-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.detail-meta-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.detail-text-content {
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.detail-summary-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-text);
}

/* ===== WORKFLOW PIPELINE VISUALIZATION ===== */
.pipeline {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px 0;
    padding: 12px 0;
}

.pipeline-step {
    display: flex;
    align-items: center;
}

.pipeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    text-align: center;
}

.pipeline-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: all 0.3s ease;
    margin-bottom: 6px;
}

.pipeline-circle.completed {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

.pipeline-circle.current {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.pipeline-circle.pending {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.pipeline-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.2;
}

.pipeline-action {
    font-size: 10px;
    color: var(--color-text-muted);
    line-height: 1.3;
    margin-top: 2px;
    max-width: 96px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pipeline-arrow {
    width: 24px;
    height: 2px;
    background: var(--color-border);
    position: relative;
    margin: 0 2px;
    margin-top: 17px;
    align-self: flex-start;
    flex-shrink: 0;
}

.pipeline-arrow.completed {
    background: var(--color-success);
}

.pipeline-arrow::after {
    content: '';
    position: absolute;
    right: -1px;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 6px solid var(--color-border);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.pipeline-arrow.completed::after {
    border-left-color: var(--color-success);
}

.pipeline-circle.waiting {
    background: #fbbf24;
    color: #78350f;
    animation: pulse-waiting 2s ease-in-out infinite;
}

@keyframes pulse-waiting {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

/* ===== WORKFLOW ACTION BOXES ===== */
.wf-holder-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 14px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--color-primary);
}
.wf-holder-info strong {
    font-weight: 600;
}

.wf-action-box {
    margin-top: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--color-bg);
}

.wf-action-box.wf-action-pickup {
    border-color: #fbbf24;
    background: #fffbeb;
}

.wf-action-box.wf-action-advance {
    border-color: var(--color-primary);
    background: #f0f4ff;
}

.wf-action-box.wf-action-warning {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
    font-size: 13px;
}

.wf-action-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.wf-action-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.wf-action-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.wf-action-controls select {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: var(--font-family);
    background: #fff;
}

.wf-notes-input {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: var(--font-family);
}

.wf-forward-section {
    margin-bottom: 12px;
}
.wf-forward-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}
.wf-forward-section select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: var(--font-family);
    background: #fff;
}

.wf-action-warning-text {
    font-size: 12px;
    color: #dc2626;
    margin-bottom: 10px;
}

/* ===== WORKFLOW LOGS ===== */
.wf-logs-section {
    margin-top: 16px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

.wf-logs-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.wf-log-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--color-border-light);
    flex-wrap: wrap;
}

.wf-log-action {
    color: var(--color-text);
    font-weight: 500;
}

.wf-log-user {
    color: var(--color-primary);
    font-weight: 500;
}

.wf-log-forward {
    color: var(--color-success);
    font-weight: 500;
}

.wf-log-notes {
    color: var(--color-text-muted);
    font-style: italic;
}

.wf-log-date {
    margin-left: auto;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

/* ===== COMMENT TRAIL ===== */
.wf-comments-section {
    margin-top: 16px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

.wf-comments-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.wf-comment-entry {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 8px;
}

.wf-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.wf-comment-date {
    margin-left: auto;
    font-size: 11px;
    color: var(--color-text-muted);
}

.wf-comment-body {
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ===== COMMENT INPUT ===== */
.wf-comment-section {
    margin-top: 12px;
}

.wf-comment-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.wf-comment-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: var(--font-family);
    resize: vertical;
    min-height: 60px;
    transition: border-color var(--transition);
    box-sizing: border-box;
}

.wf-comment-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wf-comment-input::placeholder {
    color: var(--color-text-muted);
}

.badge-status-en_attente {
    background: #fef3c7;
    color: #92400e;
}

/* ===== USER DETAIL ===== */
.user-cell-clickable {
    cursor: pointer;
    transition: opacity var(--transition);
}
.user-cell-clickable:hover {
    opacity: 0.7;
}
.user-cell-clickable .user-full-name {
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
    text-underline-offset: 2px;
}

.ud-profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ud-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.ud-profile-info {
    min-width: 0;
}

.ud-profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 4px 0;
}

.ud-profile-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ud-absence-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
    color: #92400e;
    font-size: 13px;
}
.ud-absence-banner svg {
    flex-shrink: 0;
    margin-top: 1px;
    stroke: #f59e0b;
}

.ud-empty {
    padding: 20px 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

.ud-doc-filename {
    font-weight: 500;
    color: var(--color-text);
    font-size: 13px;
}

.ud-doc-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}
.ud-doc-link:hover {
    text-decoration: underline;
}

/* ===== COST COMPARISON ===== */
.cost-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.cost-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px;
    position: relative;
    transition: all var(--transition);
}

.cost-card.cost-used {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.cost-card.cost-cheapest {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

.cost-card.cost-cheapest.cost-used {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

.cost-card-label {
    position: absolute;
    top: -8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.cost-label-used {
    background: var(--color-primary);
    color: #fff;
}

.cost-label-cheapest {
    background: var(--color-success);
    color: #fff;
}

.cost-provider-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 2px;
}

.cost-model-name {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.cost-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.cost-unit {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ===== CATEGORIES ===== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 400px));
    gap: 12px;
}

.category-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition);
}

.category-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
}

.category-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.category-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
}

.category-description {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 12px;
    opacity: 0.4;
    transition: opacity .15s;
}

.category-card:hover .category-actions {
    opacity: 1;
}

/* Custom tooltip for category cards */
.category-card[data-tooltip] {
    position: relative;
    cursor: default;
}
.category-card[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: var(--color-text);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    white-space: normal;
    max-width: 320px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 100;
}
.category-card[data-tooltip]::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 100;
}
.category-card[data-tooltip]:hover::after,
.category-card[data-tooltip]:hover::before {
    opacity: 1;
}

/* ===== USERS TABLE ===== */
.users-table-wrapper {
    flex: 1;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.user-name-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.user-full-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
}

.user-row-absent {
    background: #fef9ee;
}

.user-avatar-absent {
    background: #d97706 !important;
    opacity: 0.8;
}

.badge-absent {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.user-interim-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.badge-interim {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: default;
}
.badge-interim small {
    font-weight: 400;
    opacity: 0.7;
}

/* ===== VACANCIES / INTÉRIMS ===== */
.vacancy-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== VACANCY RULES BANNER ===== */
.vacancy-rules-banner {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.vacancy-rules-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.vacancy-rules-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vacancy-rules-list li {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    padding-left: 16px;
    position: relative;
}

.vacancy-rules-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: 700;
}

.vacancy-rules-list li strong {
    color: var(--color-text);
}

/* ===== REQUIRED ROLES ALERT ===== */
.vacancy-required-roles-alert {
    background: #fef9c3;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 12px 0;
}

.vacancy-required-roles-alert .alert-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 8px;
}

.vacancy-required-roles-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.vacancy-required-roles-table th {
    text-align: left;
    font-weight: 600;
    color: #92400e;
    padding: 4px 8px;
    border-bottom: 1px solid #fbbf24;
}

.vacancy-required-roles-table td {
    padding: 6px 8px;
    color: #78350f;
}

.vacancy-required-roles-table .role-covered {
    color: #16a34a;
    font-weight: 500;
}

.vacancy-required-roles-table .role-pending {
    color: #dc2626;
    font-weight: 500;
}

.vacancy-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition);
}
.vacancy-card:hover {
    box-shadow: var(--shadow-sm);
}

.vacancy-card.vacancy-active {
    border-left: 4px solid #10b981;
}
.vacancy-card.vacancy-inactive {
    border-left: 4px solid var(--color-border);
}

.vacancy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px 8px;
}

.vacancy-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vacancy-role-badge {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
}

.vacancy-card-actions {
    display: flex;
    gap: 4px;
}

.vacancy-card-body {
    padding: 8px 18px 16px;
}

.vacancy-people {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
}

.vacancy-person {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vacancy-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.vacancy-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.vacancy-name-link {
    color: var(--color-primary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}
.vacancy-name-link:hover {
    color: var(--color-primary-dark, #1D4ED8);
    text-decoration: underline;
}

.vacancy-arrow {
    font-size: 20px;
    color: var(--color-text-muted);
    margin-top: 14px;
}

.vacancy-dates {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.vacancy-reason {
    font-size: 12px;
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: 6px;
}

/* ===== USER VACANCY CARDS (my interims) ===== */
.my-vacancy-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vacancy-card.vacancy-upcoming {
    border-left: 4px solid var(--color-warning, #f59e0b);
}

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

/* ===== ROLES LIST ===== */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.role-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition);
    position: relative;
    cursor: default;
}

.role-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
}

/* Tooltip on hover — shows full description */
.role-card[title] {
    cursor: help;
}

.role-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.role-code-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 32px;
    padding: 0 8px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.role-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.role-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
}

.role-description {
    font-size: 12px;
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.role-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity .15s;
}

.role-card:hover .role-actions {
    opacity: 1;
}

/* Custom tooltip for role cards */
.role-card[data-tooltip] {
    position: relative;
}
.role-card[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: var(--color-text);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    white-space: normal;
    max-width: 320px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 100;
}
.role-card[data-tooltip]::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 100;
}
.role-card[data-tooltip]:hover::after,
.role-card[data-tooltip]:hover::before {
    opacity: 1;
}

/* ===== WORKFLOW CARDS ===== */
.workflow-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.workflow-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.workflow-card:hover {
    box-shadow: var(--shadow-sm);
}

.workflow-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.workflow-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.workflow-card-title h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.workflow-card-title span {
    font-size: 12px;
    color: var(--color-text-muted);
}

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

.workflow-card-body {
    padding: 16px 20px;
}

.workflow-steps-chain {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.wf-chain-step {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
}

.wf-chain-step .step-num {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.wf-chain-arrow {
    color: var(--color-text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

/* ===== WORKFLOW CREATE FORM ===== */
.wf-steps-section {
    margin-top: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}

.wf-steps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.wf-steps-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.wf-steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wf-step-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.wf-step-num {
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.wf-step-move-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.btn-move {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 16px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 3px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    transition: all .15s;
}

.btn-move:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: var(--color-primary);
}
    flex-shrink: 0;
}

.wf-step-row select,
.wf-step-row input {
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--color-text);
    background: var(--color-surface);
}

.wf-step-row select {
    min-width: 160px;
}

.wf-step-row input {
    flex: 1;
    min-width: 120px;
}

.wf-step-row select:focus,
.wf-step-row input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ===== FORMS ===== */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.form-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-muted);
}

.form-actions-inline {
    flex: 0;
    flex-direction: row !important;
    gap: 8px !important;
}

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

/* ===== UPLOAD ===== */
.upload-container {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}

.upload-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.upload-card.upload-busy {
    cursor: progress;
}

.upload-card-header {
    margin-bottom: 24px;
}

.upload-card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.upload-card-header p {
    font-size: 13px;
    color: var(--color-text-muted);
}

.upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 16px;
    background: var(--color-bg);
}

.upload-area:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.upload-area.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    transform: scale(1.01);
}

.upload-icon-wrapper {
    margin-bottom: 16px;
    color: var(--color-text-muted);
}

.upload-area:hover .upload-icon-wrapper,
.upload-area.dragover .upload-icon-wrapper {
    color: var(--color-primary);
}

.upload-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.upload-or {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 8px 0;
}

.file-selected {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.file-selected-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
    font-weight: 500;
    font-size: 13px;
    min-width: 0;
}

.file-selected-info svg {
    flex-shrink: 0;
    color: var(--color-primary);
}

.file-selected-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.file-selected-header > span {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.file-selected-actions {
    display: flex;
    gap: 8px;
}

.selected-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 260px;
    overflow-y: auto;
}

.selected-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    padding: 8px 10px;
}

.selected-file-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.selected-file-thumb {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    object-fit: cover;
    flex-shrink: 0;
}

.selected-file-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.selected-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.selected-file-size {
    font-size: 12px;
    color: var(--color-text-muted);
}

.progress-container {
    padding: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 3px;
}

.progress-status {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 10px;
    text-align: center;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ===== STATES ===== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    gap: 16px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    background: var(--color-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--color-text-muted);
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ===== TOAST / NOTIFICATION ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 380px;
}

.toast-success {
    border-left: 3px solid var(--color-success);
}

.toast-error {
    border-left: 3px solid var(--color-danger);
}

.toast-info {
    border-left: 3px solid var(--color-primary);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== RESPONSIVE ===== */
/* ═══════════════════════════════════════════════════════════════════
   HAMBURGER BUTTON (hidden on desktop)
   ═══════════════════════════════════════════════════════════════════ */

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: none;
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition);
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: var(--color-bg);
}

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

/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR OVERLAY (mobile)
   ═══════════════════════════════════════════════════════════════════ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .detail-body,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-meta-grid {
        grid-template-columns: 1fr 1fr;
    }

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

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* -- Sidebar: off-canvas slide-in -- */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    /* -- Show hamburger -- */
    .hamburger-btn {
        display: flex;
    }

    /* -- Main content takes full width -- */
    .main-content {
        margin-left: 0;
    }

    /* -- Topbar -- */
    .topbar {
        padding: 0 12px;
        height: 56px;
    }

    .topbar h1 {
        font-size: 15px;
    }

    .search-box {
        min-width: 0;
        flex: 1;
    }

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

    .topbar-user-label {
        display: none;
    }

    /* -- Tab content -- */
    .tab-content {
        padding: 16px 12px;
    }

    /* -- Content headers -- */
    .content-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .content-header-right {
        flex-wrap: wrap;
    }

    /* -- Grids to single column -- */
    .categories-grid {
        grid-template-columns: 1fr;
    }

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

    .form-row {
        flex-direction: column;
    }

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

    .detail-body,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-meta-grid {
        grid-template-columns: 1fr;
    }

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

    /* -- Tables: horizontal scroll -- */
    .documents-table-wrapper,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .doc-table {
        min-width: 800px;
    }

    /* -- Cards -- */
    .detail-card-body {
        padding: 14px;
        overflow-x: auto;
    }

    .detail-card-header {
        padding: 12px 14px;
        font-size: 13px;
    }

    /* -- Detail page back button area -- */
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* -- Workflow pipeline: wrap -- */
    .wf-pipeline {
        flex-wrap: wrap;
    }

    .wf-pipeline-step {
        font-size: 11px;
        padding: 4px 8px;
    }

    .wf-pipeline-arrow {
        font-size: 12px;
    }

    /* -- Modals: full-screen on mobile -- */
    .modal-overlay {
        padding: 12px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-md);
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    /* -- Validation card -- */
    .validation-actions {
        flex-direction: column;
    }

    .validation-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* -- Upload area -- */
    .upload-zone {
        padding: 24px 16px;
    }

    /* -- Vacancy cards -- */
    .vacancy-people {
        flex-direction: column;
        align-items: flex-start;
    }

    .vacancy-arrow {
        transform: rotate(90deg);
        margin-top: 0;
    }

    /* -- User detail (admin) -- */
    .ud-profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .ud-profile-info {
        align-items: center;
    }

    /* -- Inbox cards -- */
    .inbox-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .inbox-card-right {
        align-items: flex-start;
        margin-left: 0;
    }

    /* -- User profile (user portal) -- */
    .user-profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px 16px;
    }

    .user-profile-info {
        align-items: center;
    }

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

    .user-profile-details {
        grid-template-columns: 1fr;
    }

    .user-profile-meta {
        padding: 12px 16px;
    }

    .profile-detail-item:nth-child(odd) {
        border-right: none;
    }

    .profile-detail-item {
        border-bottom: 1px solid var(--color-border);
    }

    .profile-detail-item:last-child {
        border-bottom: none;
    }

    /* -- Sidebar footer -- */
    .sidebar-footer {
        padding: 12px 16px;
    }

    /* -- Nav badge (inbox count) -- */
    .nav-badge {
        font-size: 10px;
    }

    /* -- Workflow comments -- */
    .wf-comments-section {
        margin-top: 12px;
    }

    /* -- My interims -- */
    .my-vacancy-cards {
        grid-template-columns: 1fr;
    }

    /* -- Workflow cards -- */
    .workflow-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
    }

    .workflow-card-title h4 {
        font-size: 13px;
        line-height: 1.3;
    }

    .workflow-card-title span {
        font-size: 11px;
    }

    .workflow-card-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 6px;
    }

    .workflow-card-body {
        padding: 12px 14px;
    }

    .workflow-steps-chain {
        gap: 3px;
    }

    .wf-chain-step .step-num {
        font-size: 10px;
        padding: 2px 6px;
    }

    .wf-chain-step .step-action {
        font-size: 10px;
    }

    .wf-chain-arrow {
        font-size: 10px;
    }

    /* -- Vacancy cards -- */
    .vacancy-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 14px 8px;
    }

    .vacancy-card-title {
        flex-wrap: wrap;
        gap: 6px;
    }

    .vacancy-card-actions {
        align-self: flex-end;
    }

    .vacancy-card-body {
        padding: 10px 14px 14px;
    }

    .vacancy-dates {
        font-size: 11px;
    }

    /* -- Pipeline (document detail workflow) -- */
    .pipeline {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .pipeline-step {
        min-width: 0;
    }

    .pipeline-circle {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .pipeline-role {
        font-size: 10px;
    }

    .pipeline-action {
        font-size: 9px;
        max-width: 60px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .topbar h1 {
        font-size: 14px;
    }

    .tab-content {
        padding: 12px 8px;
    }

    .detail-card {
        border-radius: var(--radius-sm);
    }

    .detail-card-body {
        padding: 10px;
    }

    .btn {
        padding: 7px 12px;
        font-size: 12px;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }

    .content-header-right {
        gap: 4px;
    }

    .upload-zone {
        padding: 16px 10px;
    }

    .upload-zone h3 {
        font-size: 14px;
    }

    .user-avatar-lg {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    .user-profile-name {
        font-size: 18px;
    }

    .inbox-card {
        padding: 12px;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* -- Workflow cards extra-small -- */
    .workflow-card-header {
        padding: 10px 12px;
    }

    .workflow-card-body {
        padding: 10px 12px;
    }

    .vacancy-card-header {
        padding: 10px 12px 6px;
    }

    .vacancy-card-body {
        padding: 8px 12px 12px;
    }

    .vacancy-role-badge {
        font-size: 12px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}


/* ===== USER PORTAL — INBOX ===== */

.inbox-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.inbox-section-title:first-child {
    margin-top: 0;
}

.inbox-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition);
}

.inbox-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    transform: translateY(-1px);
}

.inbox-card-pending {
    border-left: 3px solid var(--color-warning);
}

.inbox-card-held {
    border-left: 3px solid var(--color-primary);
}

.inbox-card-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.inbox-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inbox-card-icon.pending {
    background: var(--color-warning-bg, #fff7ed);
    color: var(--color-warning);
}

.inbox-card-icon.held {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.inbox-card-info {
    min-width: 0;
}

.inbox-card-filename {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.inbox-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 16px;
}

.inbox-card-role {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* Sidebar user card */
.user-sidebar-card {
    padding: 4px 0;
}

/* Nav badge (notification count) */
.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--color-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Topbar user label */
.topbar-user-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Info action box */
.wf-action-info {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-top: 12px;
}

/* ===== USER PROFILE STACK LAYOUT ===== */
.profile-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ===== USER PROFILE CARD (user portal) ===== */

.user-profile-card {
    padding: 0;
    overflow: hidden;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px 20px;
    position: relative;
}

.user-avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 26px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 1px;
}

.user-avatar-lg.user-avatar-absent {
    background: #d97706;
}

.user-profile-info {
    display: flex;
    flex-direction: column;
}

.user-profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 2px;
    line-height: 1.2;
}

.user-profile-role {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0 0 10px;
}

.user-profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.user-profile-meta {
    border-top: 1px solid var(--color-border);
    padding: 16px 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-profile-meta-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.user-profile-meta-item .label {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.user-profile-meta-item .value {
    color: var(--color-text);
}

.user-profile-body {
    padding: 0 28px 24px;
}

.user-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.profile-stat-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.profile-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-profile-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.profile-detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
}

.profile-detail-item:nth-child(odd) {
    border-right: 1px solid var(--color-border);
}

.profile-detail-item:nth-last-child(-n+2) {
    border-bottom: none;
}

.profile-detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.profile-detail-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.user-absence-banner {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
    margin: 0 28px 20px;
}

.user-absence-banner svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.user-absence-banner p {
    margin: 0;
}

/* ===== PAGINATION ===== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0 4px;
}

.pagination-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.pagination-btn:hover:not(:disabled):not(.active) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.pagination-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-left: 12px;
}

/* (User profile responsive rules merged into main @media block) */


/* ═══════════════════════════════════════════════════════════════════
   DOCUMENT STATUS BADGES
   ═══════════════════════════════════════════════════════════════════ */

.badge-status-brouillon {
    background-color: #FEF3CD;
    color: #856404;
    border: 1px solid #FFEAA7;
}

.badge-status-valide {
    background-color: #D4EDDA;
    color: #155724;
    border: 1px solid #C3E6CB;
}

.badge-status-en_attente {
    background-color: #FEF3CD;
    color: #856404;
}
.badge-status-en_cours {
    background-color: #CCE5FF;
    color: #004085;
}
.badge-status-termine {
    background-color: #D4EDDA;
    color: #155724;
}
.badge-status-annule {
    background-color: #F8D7DA;
    color: #721C24;
}

.doc-row-draft {
    background-color: rgba(254, 243, 205, 0.15);
}

/* ═══════════════════════════════════════════════════════════════════
   DOCUMENT VALIDATION CARD
   ═══════════════════════════════════════════════════════════════════ */

.validation-card {
    grid-column: 1 / -1;
    border: 2px solid #FFEAA7;
    background: linear-gradient(135deg, rgba(254, 243, 205, 0.1), rgba(255, 255, 255, 1));
}

.validation-card-header {
    background-color: rgba(254, 243, 205, 0.3) !important;
    color: #856404 !important;
}

.validation-hint {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0 0 16px;
    line-height: 1.5;
}

.validation-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.validation-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.validation-field .form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-background);
    color: var(--color-text);
    transition: border-color 0.2s;
}

.validation-field .form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.validation-field select.form-input {
    cursor: pointer;
}

.validation-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.validation-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.validation-actions .btn-secondary {
    background: var(--color-background);
    color: var(--color-text);
    border-color: var(--color-border);
}

.validation-actions .btn-secondary:hover {
    background: var(--color-background-hover);
}

.validation-actions .btn-primary {
    background: #28A745;
    color: white;
    border-color: #28A745;
}

.validation-actions .btn-primary:hover {
    background: #218838;
    border-color: #1E7E34;
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-title-row .badge {
    flex-shrink: 0;
}
