:root {
    --brand: #0EA5E9;
    --brand-dark: #0369A1;
    --brand-soft: #E0F2FE;
    --brand-softer: #F0F9FF;
    --text: #0F172A;
    --text-secondary: #334155;
    --muted: #64748B;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --success: #047857;
    --success-soft: #ECFDF5;
    --warning: #B45309;
    --warning-soft: #FFFBEB;
    --danger: #B91C1C;
    --danger-soft: #FEF2F2;
    --info: #1D4ED8;
    --info-soft: #EFF6FF;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAVBAR ─────────────────────────────────────── */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img {
    height: 40px;
    width: auto;
    display: block;
}
.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}
.topbar-section {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--muted);
}
.topbar-user a {
    color: var(--text-secondary);
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    transition: all .15s ease;
}
.topbar-user a:hover {
    background: var(--bg);
    border-color: var(--border-strong);
    text-decoration: none;
}

/* ── LAYOUT ─────────────────────────────────────── */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 4px;
    letter-spacing: -.01em;
}
.page-header p {
    color: var(--muted);
    margin: 0;
}

/* ── CARDS ──────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
}
.card-body {
    padding: 24px;
}

/* ── FORMS ──────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.input, .select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--white);
    color: var(--text);
    font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .15);
}
.field-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

/* ── BUTTONS ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn-brand {
    background: var(--brand);
    color: var(--white);
    border-color: var(--brand);
}
.btn-brand:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: var(--white);
    text-decoration: none;
}
.btn-outline {
    background: var(--white);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}
.btn-outline:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}
.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}
.btn-ghost:hover {
    color: var(--text);
    background: var(--bg);
    text-decoration: none;
}
.btn-danger {
    background: var(--white);
    color: var(--danger);
    border-color: #FCA5A5;
}
.btn-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
    text-decoration: none;
}
.btn-success {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
}
.btn-success:hover {
    background: #065F46;
    border-color: #065F46;
    color: var(--white);
    text-decoration: none;
}
.btn-block { width: 100%; }
.btn-lg { padding: 11px 18px; font-size: 14px; }

/* ── TABLE ──────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}
table.dossiers {
    width: 100%;
    border-collapse: collapse;
}
table.dossiers thead th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.dossiers tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.dossiers tbody tr:last-child td { border-bottom: none; }
table.dossiers tbody tr:hover { background: var(--brand-softer); }
.cell-id {
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    color: var(--muted);
    font-size: 12px;
}
.cell-name {
    font-weight: 500;
    color: var(--text);
}
.cell-meta {
    color: var(--muted);
    font-size: 13px;
}
.cell-actions {
    text-align: right;
    white-space: nowrap;
}

/* ── BADGES ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: .01em;
}
.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-neutral { background: #F1F5F9; color: #475569; }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-dark); }

.badge-pulse .badge-dot {
    animation: pulse 1.4s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

/* ── ACTIVITY CHIP ──────────────────────────────── */
.activity-chip {
    display: inline-block;
    background: var(--brand-soft);
    color: var(--brand-dark);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    max-width: 240px;
    white-space: normal;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
    cursor: pointer;
}
a.activity-chip:hover {
    background: var(--brand);
    color: var(--white);
    text-decoration: none;
}
.activity-empty {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

/* ── ALERTS ─────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    position: relative;
}
.alert-success { background: var(--success-soft); color: var(--success); border-color: #A7F3D0; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #FCD34D; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: #FCA5A5; }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: #93C5FD; }
.alert-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: inherit;
    opacity: .6;
    cursor: pointer;
    font-size: 16px;
}
.alert-close:hover { opacity: 1; }

/* ── AUTH (login/register/otp) ──────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    padding: 40px 32px;
}
.auth-logo {
    display: block;
    margin: 0 auto 20px;
    height: 44px;
}
.auth-title {
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -.01em;
}
.auth-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 28px;
}
.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--muted);
}

/* ── OTP INPUT ──────────────────────────────────── */
.otp-input {
    text-align: center;
    letter-spacing: 8px;
    font-weight: 600;
    font-size: 22px;
    padding: 14px;
}

/* ── ERROR MESSAGE (dossier en erreur) ───────────── */
.error-message {
    font-size: 11px;
    color: var(--danger);
    font-style: italic;
    margin-top: 6px;
    max-width: 280px;
    text-align: right;
    word-wrap: break-word;
    line-height: 1.3;
    margin-left: auto;
}

/* ── ADMIN — Formulaire d'ajout utilisateur ─────── */
.admin-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: 10px;
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.admin-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.admin-card-icon {
    flex-shrink: 0;
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-radius: 8px;
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
}
.admin-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.admin-card-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0 0;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.4fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}
@media (max-width: 760px) {
    .admin-form-grid { grid-template-columns: 1fr; }
}
.admin-form-grid .field { margin: 0; }
.admin-form-grid label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.admin-role-select {
    padding-right: 36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2364748B' d='M6 8.5L1.5 4h9z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.admin-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    flex-wrap: wrap;
}
.admin-warning {
    margin: 0;
    font-size: 12px;
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid #FCD34D;
    border-radius: 6px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 240px;
}
.admin-warning-icon {
    font-size: 13px;
    font-weight: bold;
}

/* ── BARRE DE FILTRES (recherche + statut) ─────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-search { flex: 1 1 220px; min-width: 200px; max-width: 360px; }
.filter-statut {
    flex: 0 0 auto;
    width: auto;
    min-width: 200px;
    padding-right: 36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2364748B' d='M6 8.5L1.5 4h9z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
.filter-reset { flex: 0 0 auto; }

/* ── DROPDOWN STATUT JURISTE ───────────────────── */
.statut-form {
    display: inline-block;
    margin: 0;
}
.statut-select {
    padding: 7px 28px 7px 12px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background-color: var(--white);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2364748B' d='M6 8.5L1.5 4h9z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    max-width: 320px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.statut-select:hover { border-color: var(--brand); }
.statut-select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.statut-select[data-current="DRAFT_GENERATED"] {
    background-color: var(--warning-soft);
    color: var(--warning);
    border-color: #FCD34D;
}
.statut-select[data-current="AWAITING_PAYMENT"] {
    background-color: var(--info-soft);
    color: var(--info);
    border-color: #93C5FD;
}
.statut-select[data-current="PAID"] {
    background-color: var(--success-soft);
    color: var(--success);
    border-color: #6EE7B7;
}

/* ── PAGINATION ────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding: 12px 4px;
    flex-wrap: wrap;
}
.pagination-info {
    font-size: 13px;
    color: var(--muted);
}
.pagination-controls {
    display: flex;
    gap: 8px;
}

/* ── EMPTY STATE ───────────────────────────────── */
.empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--muted);
}
.empty-title {
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 4px;
}
.empty-subtitle {
    font-size: 13px;
    margin: 0;
}

/* ── UTILS ─────────────────────────────────────── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
