:root {
    --bs-primary: #1d4ed8;
    --bs-primary-rgb: 29, 78, 216;
    --app-bg: #f4f6fb;
    --app-sidebar-w: 260px;
    --app-radius: 14px;
    --app-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

body {
    background-color: var(--app-bg);
    color: #0f172a;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
}

/* Sidebar Desktop */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--app-sidebar-w);
    background: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.9rem;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none;
    color: #fff;
}

.app-brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

.app-nav {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.94rem;
    transition: all 0.15s ease;
}

.app-nav-link i {
    font-size: 1.15rem;
}

.app-nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.app-nav-link.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.app-main {
    margin-left: var(--app-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e2e8f0;
    padding: 0.85rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    padding: 1.5rem;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* Cartes & Composants */
.card {
    border: 1px solid #e2e8f0;
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    border-top-left-radius: var(--app-radius) !important;
    border-top-right-radius: var(--app-radius) !important;
    padding: 0.95rem 1.25rem;
    font-weight: 600;
}

.kpi-card {
    border-radius: var(--app-radius);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 1.1rem 1.25rem;
    box-shadow: var(--app-shadow);
    height: 100%;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Encart didactique */
.guide-box {
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--app-radius);
    padding: 1rem 1.2rem;
}

/* Grille des 41 Box */
.box-tile {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top-width: 4px;
    border-radius: 12px;
    padding: 0.9rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.box-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.box-tile.state-free { border-top-color: #16a34a; }
.box-tile.state-occupied { border-top-color: #2563eb; }
.box-tile.state-expiring { border-top-color: #f59e0b; background: #fffdf5; }
.box-tile.state-inactive { border-top-color: #94a3b8; opacity: 0.72; }

/* Stepper Assistant Contrat */
.stepper {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stepper-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.stepper-item.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.stepper-item.done {
    border-color: #16a34a;
}

.stepper-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: #e2e8f0;
    color: #334155;
    flex-shrink: 0;
}

.stepper-item.active .stepper-num {
    background: #2563eb;
    color: #fff;
}

.stepper-item.done .stepper-num {
    background: #16a34a;
    color: #fff;
}

/* Zone glisser-déposer */
.dropzone-area {
    border: 2px dashed #93c5fd;
    background: #f8fafc;
    border-radius: var(--app-radius);
    padding: 1.8rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dropzone-area:hover,
.dropzone-area.dragover {
    border-color: #2563eb;
    background: #eff6ff;
}

/* Balises copiables */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    transition: all 0.12s ease;
}

.tag-chip:hover {
    background: #2563eb;
    color: #ffffff;
}

/* Aperçu DOCX */
.docx-preview-stage {
    background: #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    max-height: 75vh;
    overflow: auto;
}

.docx-preview-stage .docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
}

.docx-preview-stage section.docx {
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.15) !important;
    margin-bottom: 1.25rem !important;
}

/* Code OTP 6 chiffres */
.otp-input {
    font-size: 1.9rem !important;
    font-weight: 800;
    letter-spacing: 0.5rem;
    text-align: center;
    padding: 0.8rem 1rem;
    border-radius: 12px;
}

/* Navigation mobile en bas (façon appli native) */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        display: none;
    }
    .app-main {
        margin-left: 0;
        padding-bottom: 76px;
    }
    .app-content {
        padding: 1rem;
    }
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.06);
        padding: 0.35rem 0.25rem;
    }
    .mobile-bottom-nav a {
        flex: 1;
        text-align: center;
        text-decoration: none;
        color: #64748b;
        font-size: 0.72rem;
        font-weight: 600;
        padding: 0.3rem 0.1rem;
        border-radius: 10px;
    }
    .mobile-bottom-nav a i {
        display: block;
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    .mobile-bottom-nav a.active {
        color: #1d4ed8;
        background: #eff6ff;
    }
    .stepper {
        flex-direction: column;
    }
}

/* Impression PDF propre depuis l'aperçu Word */
@media print {
    body {
        background: #ffffff !important;
    }
    .no-print,
    .app-sidebar,
    .app-topbar,
    .mobile-bottom-nav {
        display: none !important;
    }
    .app-main {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .app-content {
        padding: 0 !important;
        max-width: none !important;
    }
    .docx-preview-stage {
        background: #ffffff !important;
        padding: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .docx-preview-stage section.docx {
        box-shadow: none !important;
        margin: 0 !important;
    }
}
