/* ================================================================
   SGRI - Styles Azure-inspired
   Référence: Microsoft Azure Portal UI
   ================================================================ */

:root {
    --azure-blue: #0078d4;
    --azure-blue-dark: #005a9e;
    --azure-blue-light: #deecf9;
    --azure-blue-hover: #106ebe;
    --text-primary: #323130;
    --text-secondary: #605e5c;
    --text-disabled: #a19f9d;
    --bg-body: #f3f2f1;
    --bg-white: #ffffff;
    --bg-gray-50: #faf9f8;
    --border-color: #edebe9;
    --border-focus: #0078d4;
    --danger: #a4262c;
    --danger-light: #fde7e9;
    --warning: #7a5c00;
    --warning-light: #fff4ce;
    --success: #107c10;
    --success-light: #dff6dd;
    --nav-height: 48px;
    --sidebar-width: 220px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.10);
    --shadow-md: 0 2px 8px rgba(0,0,0,.12);
    --radius: 2px;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: .875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.25rem;
}

h3 {
    font-size: 1.1rem;
}

a {
    color: var(--azure-blue);
    text-decoration: none;
}

    a:hover {
        color: var(--azure-blue-dark);
        text-decoration: underline;
    }

/* ── Top Navigation ───────────────────────────────────────────── */
.top-nav {
    height: var(--nav-height);
    background: var(--azure-blue);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: .5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

/* Hamburger button (caché par défaut, visible ≤ 1024px) */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 5px 6px;
    flex-shrink: 0;
}

    .nav-hamburger span {
        display: block;
        height: 2px;
        background: #fff;
        border-radius: 1px;
        transition: transform .2s, opacity .2s;
    }

@media (max-width: 1024px) {
    .nav-hamburger {
        display: flex;
    }
}

.top-nav .nav-brand {
    color: #fff;
    font-size: .9375rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

    .top-nav .nav-brand:hover {
        color: #fff;
        text-decoration: none;
    }

    .top-nav .nav-brand .brand-icon {
        width: 28px;
        height: 28px;
        background: rgba(255,255,255,.25);
        border-radius: var(--radius);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: .65rem;
        font-weight: 700;
        color: #fff;
        flex-shrink: 0;
    }

/* Cacher le texte long de la marque sur mobile */
.nav-brand-text {
}

@media (max-width: 480px) {
    .nav-brand-text {
        display: none;
    }
}

.top-nav .nav-spacer {
    flex: 1;
}

.top-nav .nav-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: rgba(255,255,255,.9);
    font-size: .8125rem;
}

/* Nom utilisateur — caché sur mobile étroit */
.nav-user-name {
    color: #fff;
}

@media (max-width: 600px) {
    .nav-user-name {
        display: none;
    }
}

.top-nav .nav-user .btn-logout {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    padding: .25rem .75rem;
    border-radius: var(--radius);
    font-size: .8125rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

    .top-nav .nav-user .btn-logout:hover {
        background: rgba(255,255,255,.25);
    }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 900;
}

.sidebar-section-title {
    padding: .75rem 1rem .25rem;
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-secondary);
}

.sidebar-nav a {
    display: block;
    padding: .5rem 1rem;
    color: var(--text-primary);
    font-size: .8125rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .1s, border-color .1s;
}

    .sidebar-nav a:hover {
        background: var(--azure-blue-light);
        color: var(--azure-blue-dark);
        text-decoration: none;
    }

    .sidebar-nav a.active {
        background: var(--azure-blue-light);
        border-left-color: var(--azure-blue);
        color: var(--azure-blue-dark);
        font-weight: 600;
    }

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: .5rem 0;
}

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--nav-height);
    padding: 1.5rem;
    min-height: calc(100vh - var(--nav-height));
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-breadcrumb {
    font-size: .8125rem;
    color: var(--text-secondary);
    margin-bottom: .25rem;
}

    .page-breadcrumb a {
        color: var(--azure-blue);
    }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.card-header {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-gray-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .card-header .card-title {
        font-size: .9375rem;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0;
    }

.card-body {
    padding: 1.25rem;
}

/* ── Form Styles ──────────────────────────────────────────────── */

/* Section container — bordure grise neutre, fond blanc */
.form-section {
    border: 1px solid #e1dfdd;
    border-radius: 3px;
    margin-bottom: 1.125rem;
    background: var(--bg-white);
    overflow: hidden;
}

/* Titre de section : numéro + texte gras noir, fond très léger */
.form-section-title {
    font-size: .8125rem;
    font-weight: 700;
    color: #201f1e;
    background: #f9f8f7;
    border-bottom: 1px solid #e1dfdd;
    padding: .5rem 1.125rem;
    letter-spacing: 0;
}

/* Corps de section */
.form-section-body {
    padding: .875rem 1.125rem .125rem;
}

/* Grille 2 colonnes égales — chaque enfant direct = 1 cellule */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.25rem;
    row-gap: 0;
}

/* Colonne enveloppante (trigger + conditional empilés dans 1 cellule) */
.form-col {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: .875rem;
}

label.form-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: #484644;
    margin-bottom: .3rem;
}

    label.form-label .required-mark {
        color: var(--danger);
        margin-left: 2px;
    }

.form-control, .form-select {
    width: 100%;
    padding: .375rem .625rem;
    font-size: .875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
    border: 1px solid #8a8886;
    border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}

    .form-control:focus, .form-select:focus {
        outline: none;
        border-color: var(--azure-blue);
        box-shadow: 0 0 0 1px var(--azure-blue);
    }

    .form-control:disabled, .form-select:disabled {
        background: var(--bg-gray-50);
        color: var(--text-disabled);
        cursor: not-allowed;
    }

textarea.form-control {
    resize: vertical;
    min-height: 72px;
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger);
}

    .form-control.is-invalid:focus {
        box-shadow: 0 0 0 1px var(--danger);
    }

.field-validation-error {
    display: block;
    font-size: .75rem;
    color: var(--danger);
    margin-top: .2rem;
}

/* ── Checkbox group — 2 par ligne, flux gauche→droite ─────────── */
.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: row;
    gap: .125rem .5rem;
    padding: .5rem .625rem;
    border: 1px solid #e1dfdd;
    border-radius: var(--radius);
    background: #faf9f8;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: .375rem;
    padding: .3rem .375rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .1s;
}

    .checkbox-item:hover {
        background: #deecf9;
    }

    .checkbox-item input[type="checkbox"],
    .checkbox-item input[type="radio"] {
        margin-top: 2px;
        flex-shrink: 0;
        accent-color: var(--azure-blue);
        width: 14px;
        height: 14px;
        cursor: pointer;
    }

    .checkbox-item span {
        font-size: .8125rem;
        color: var(--text-primary);
        line-height: 1.4;
    }

/* ── Radio oui/non inline ─────────────────────────────────────── */
.radio-inline {
    display: flex;
    gap: 1.25rem;
    padding: .375rem 0;
}

    .radio-inline label {
        display: flex;
        align-items: center;
        gap: .375rem;
        font-size: .875rem;
        font-weight: 400;
        color: var(--text-primary);
        cursor: pointer;
        margin: 0;
    }

    .radio-inline input[type="radio"] {
        accent-color: var(--azure-blue);
        width: 14px;
        height: 14px;
        cursor: pointer;
        flex-shrink: 0;
    }

/* ── Champ conditionnel — même colonne que trigger ────────────── */
.cond-field {
    display: none;
    margin-top: -.25rem; /* colle visuellement sous le trigger */
    padding-top: .5rem;
    padding-left: .75rem;
    border-left: 2px solid #e1dfdd;
    margin-left: .125rem;
}

    .cond-field.show {
        display: block;
    }

    .cond-field .form-label {
        color: var(--text-secondary);
        font-style: italic;
    }

/* Hint */
.form-hint {
    font-size: .75rem;
    color: var(--text-secondary);
    margin-top: .2rem;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .375rem .875rem;
    font-size: .875rem;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}

    .btn:hover {
        text-decoration: none;
    }

    .btn:focus {
        outline: none;
        box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--azure-blue);
    }

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

    .btn-primary:hover {
        background: var(--azure-blue-hover);
        border-color: var(--azure-blue-hover);
        color: #fff;
    }

.btn-secondary {
    background: var(--bg-white);
    border-color: #8a8886;
    color: var(--text-primary);
}

    .btn-secondary:hover {
        background: var(--bg-gray-50);
        color: var(--text-primary);
    }

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

    .btn-danger:hover {
        background: var(--danger-light);
    }

.btn-sm {
    padding: .2rem .6rem;
    font-size: .8125rem;
}

.btn-toolbar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-white);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8125rem;
}

    .data-table thead tr {
        background: var(--bg-gray-50);
        border-bottom: 2px solid var(--border-color);
    }

    .data-table thead th {
        padding: .625rem .875rem;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        white-space: nowrap;
        font-size: .8125rem;
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .data-table tbody tr {
        border-bottom: 1px solid var(--border-color);
        transition: background .1s;
    }

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

        .data-table tbody tr:hover {
            background: var(--bg-gray-50);
        }

    .data-table tbody td {
        padding: .625rem .875rem;
        color: var(--text-primary);
        vertical-align: middle;
    }

.table-actions {
    display: flex;
    gap: .375rem;
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: #054b05;
}

.alert-danger {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    border-color: #c8a600;
    color: var(--warning);
}

.alert-info {
    background: var(--azure-blue-light);
    border-color: var(--azure-blue);
    color: var(--azure-blue-dark);
}

/* ── Badge ────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15em .5em;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 10px;
    line-height: 1.4;
}

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

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

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

.badge-info {
    background: var(--azure-blue-light);
    color: var(--azure-blue-dark);
}

.badge-gray {
    background: var(--border-color);
    color: var(--text-secondary);
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

    .modal-overlay.show {
        display: flex;
    }

.modal-box {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

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

    .modal-header .modal-title {
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0;
    }

    .modal-header .btn-close {
        background: none;
        border: none;
        font-size: 1.25rem;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0 .25rem;
        line-height: 1;
    }

        .modal-header .btn-close:hover {
            color: var(--text-primary);
        }

.modal-body {
    padding: 1.25rem;
    font-size: .875rem;
    color: var(--text-primary);
}

.modal-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    background: var(--bg-gray-50);
}

/* ── Login Page ───────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background: var(--azure-blue);
    padding: 1.5rem 2rem;
    text-align: center;
}

    .login-header .login-logo {
        font-size: 1.1rem;
        font-weight: 700;
        color: #fff;
        line-height: 1.3;
    }

    .login-header .login-subtitle {
        font-size: .75rem;
        color: rgba(255,255,255,.8);
        margin-top: .25rem;
    }

.login-body {
    padding: 2rem;
}

/* ── Stats Cards ──────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--azure-blue);
}

    .stat-card .stat-value {
        font-size: 2rem;
        font-weight: 700;
        color: var(--azure-blue-dark);
        line-height: 1;
    }

    .stat-card .stat-label {
        font-size: .8125rem;
        color: var(--text-secondary);
        margin-top: .25rem;
    }

/* ── Utilities ────────────────────────────────────────────────── */
.text-muted {
    color: var(--text-secondary) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-success {
    color: var(--success) !important;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.gap-2 {
    gap: .5rem;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: .25rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: .25rem;
}

.mt-3 {
    margin-top: 1rem;
}

.w-100 {
    width: 100%;
}

.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.col-12 {
    grid-column: span 12;
}

.col-6 {
    grid-column: span 6;
}

.col-4 {
    grid-column: span 4;
}

.col-3 {
    grid-column: span 3;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   Breakpoints: 480px · 768px · 1024px
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablette large → desktop (≥ 1025px) : déjà géré par défaut ─ */

/* ── Tablette (≤ 1024px) ────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--nav-height);
        height: calc(100vh - var(--nav-height));
        z-index: 900;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,.15);
    }

        .sidebar.open {
            transform: translateX(0);
        }

    .main-content {
        margin-left: 0 !important;
    }

    /* Overlay quand sidebar ouverte */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 899;
    }

        .sidebar-overlay.show {
            display: block;
        }
}

/* ── Mobile paysage / tablette portrait (≤ 768px) ────────────── */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    /* Navigation */
    .nav-logo span {
        display: none;
    }

    .nav-user-name {
        display: none;
    }

    .nav-title {
        font-size: .9rem;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .625rem;
    }

        .page-header .btn {
            align-self: flex-start;
        }

    /* Formulaire : 2 col → 1 col */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-col {
        display: contents;
    }
    /* chaque enfant flow naturellement */

    /* Supprime le span-2 inline car on est déjà 1 col */
    .form-grid [style*="grid-column"] {
        grid-column: 1 / -1;
    }

    /* Checkbox group : 1 col sur petits écrans */
    .checkbox-group {
        grid-template-columns: 1fr;
    }

    /* Form actions : boutons en colonne */
    .form-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }

        .form-actions .btn {
            flex: 1 1 auto;
            justify-content: center;
            min-width: 120px;
        }

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

    .data-table {
        min-width: 600px;
    }

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

    /* Détail : label + valeur en colonne */
    .detail-row {
        grid-template-columns: 1fr;
        gap: .125rem;
    }

    .detail-label {
        padding-bottom: 0;
    }

    /* Utils */
    .col-6, .col-4, .col-3 {
        grid-column: span 12;
    }
}

/* ── Mobile portrait (≤ 480px) ───────────────────────────────── */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    /* Contenu principal */
    .main-content {
        padding: .875rem .75rem;
    }

    /* Sections de formulaire */
    .form-section-body {
        padding: .75rem .75rem .125rem;
    }

    .form-section-title {
        padding: .5rem .75rem;
    }

    /* Champs radio inline → wrap sur très petits écrans */
    .radio-inline {
        flex-wrap: wrap;
        gap: .375rem;
    }

    /* Checkbox : 1 seule colonne */
    .checkbox-group {
        grid-template-columns: 1fr;
        padding: .375rem .5rem;
    }

    /* Boutons de navigation */
    .nav-action {
        display: none;
    }

    .nav-menu-btn {
        display: flex;
    }

    /* Stats : 1 col */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Page header */
    .page-title {
        font-size: 1.1rem;
    }

    .page-breadcrumb {
        font-size: .75rem;
    }

    /* Tableau : scroll avec indicateur */
    .table-wrapper::after {
        content: '← scroll →';
        display: block;
        text-align: center;
        font-size: .7rem;
        color: var(--text-secondary);
        padding: .25rem 0;
    }
}

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: .25rem;
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

    .pagination li a, .pagination li span {
        display: inline-block;
        padding: .375rem .625rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        font-size: .8125rem;
        color: var(--azure-blue);
        background: var(--bg-white);
        text-decoration: none;
    }

    .pagination li.active span {
        background: var(--azure-blue);
        border-color: var(--azure-blue);
        color: #fff;
    }

    .pagination li.disabled span {
        color: var(--text-disabled);
        cursor: default;
    }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

    .empty-state p {
        font-size: .9375rem;
        margin-bottom: .5rem;
    }

/* ── File Input ───────────────────────────────────────────────── */
.form-control[type="file"] {
    padding: .25rem .5rem;
    cursor: pointer;
}

/* ── Scroll to top ────────────────────────────────────────────── */
.form-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: .875rem 1.25rem;
    margin: 0 -1.25rem -1.25rem;
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    z-index: 10;
}

/* ── Detail view rows ─────────────────────────────────────────── */
.detail-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: .375rem 1rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border-color);
    align-items: start;
}

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

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: .8125rem;
    padding-top: .125rem;
}

.detail-value {
    color: var(--text-primary);
    font-size: .875rem;
    word-break: break-word;
}

/* ─── Details page ──────────────────────────────────────────────── */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.detail-row {
    display: flex;
    flex-direction: column;
    padding: .625rem 1rem;
    border-bottom: 1px solid #f3f2f1;
}

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

.detail-label {
    font-size: .75rem;
    font-weight: 600;
    color: #605e5c;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .25rem;
}

.detail-value {
    color: #201f1e;
    font-size: .875rem;
    line-height: 1.5;
}

.detail-text {
    white-space: pre-wrap;
}

/* ─── Attachment cards ───────────────────────────────────────────── */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    padding: .5rem;
}

.attachment-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 1.25rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: #201f1e;
    background: #faf9f8;
    transition: background .15s, border-color .15s;
    text-align: center;
}

    .attachment-card:hover {
        background: #f0f6ff;
        border-color: var(--primary);
    }

.attachment-icon {
    font-size: 2rem;
    line-height: 1;
}

.attachment-label {
    font-size: .8125rem;
    font-weight: 500;
}

/* ─── Audit footer ───────────────────────────────────────────────── */
.audit-footer {
    text-align: right;
    font-size: .75rem;
    color: #a19f9d;
    margin-top: .75rem;
    padding: .5rem 0;
}

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge-success {
    background: #dff6dd;
    color: #107c10;
}

.badge-warning {
    background: #fff4ce;
    color: #835c00;
}

.badge-neutral {
    background: #edebe9;
    color: #323130;
}

/* ─── Table actions ─────────────────────────────────────────────── */
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    align-items: center;
}

/* ─── Form hint ─────────────────────────────────────────────────── */
.form-hint {
    font-size: .75rem;
    color: #605e5c;
    margin-top: .25rem;
    display: block;
}

/* ─── Responsive details ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }

    .detail-row[style*="grid-column"] {
        grid-column: unset !important;
    }

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

    .table-actions {
        flex-wrap: wrap;
    }
}

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

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: #f9f8f7;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #605e5c;
    padding: .25rem .5rem;
    border-radius: 3px;
    line-height: 1;
}

    .modal-close:hover {
        background: #edebe9;
    }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .modal-box {
        width: 98% !important;
        max-height: 95vh;
    }

    .modal-body {
        padding: .75rem;
    }
}
