:root {
    --navy: #0f172a;
    --navy-mid: #1e293b;
    --blue: #1e3a8a;
    --blue-bright: #1d4ed8;
    --bordeaux: #7f1d1d;
    --bordeaux-hover: #991b1b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --text: #0f172a;
    --text-muted: #475569;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

/* =========================================================
   SHELL APPLICATIF (IDENTIQUE À OPESD)
   ========================================================= */
.app-shell-body {
    min-height: 100vh;
    background: var(--bg);
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--navy);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid #1e293b;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.95);
}

.sidebar-brand .brand {
    text-decoration: none;
    color: #ffffff;
}

.brand-emblem {
    display: flex;
    width: 24px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.emblem-bar {
    flex: 1;
    height: 100%;
}
.emblem-bar.blue { background: #1d4ed8; }
.emblem-bar.white { background: #ffffff; }
.emblem-bar.red { background: #dc2626; }

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-acronym {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
    color: #ffffff;
}

.brand-sub {
    font-size: 0.74rem;
    color: #94a3b8;
    margin-top: 0.12rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #64748b;
    padding: 0.85rem 0.65rem 0.3rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.56rem 0.75rem;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--blue-bright);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(29, 78, 216, 0.35);
}

.nav-icon {
    width: 1.25rem;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.95rem 1rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.6);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.65rem;
    font-size: 0.84rem;
}

.sidebar-user strong {
    color: #f8fafc;
    font-weight: 600;
}

.sidebar-user span {
    color: #94a3b8;
    font-size: 0.76rem;
    margin-top: 0.1rem;
}

.sidebar-footer .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
    color: #f8fafc;
}

.sidebar-footer .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.app-main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.shell-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.shell-topbar-left,
.shell-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.sidebar-toggle {
    display: none;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.35rem 0.65rem;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
}

.jurisdiction-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.32rem 0.75rem;
    border-radius: 999px;
}

.jurisdiction-pill.is-pr {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.shell-content {
    flex: 1;
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* =========================================================
   TITRES, CARTES & KPI
   ========================================================= */
.page-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-title-row h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.25;
}

.page-title-row .subtitle {
    margin: 0.3rem 0 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.card-top h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.95rem;
    margin-bottom: 1.35rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--blue-bright);
    border-radius: var(--radius);
    padding: 0.95rem 1.1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.15;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.15rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* =========================================================
   BOUTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.52rem 0.95rem;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.25;
    transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

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

.btn-primary {
    background: var(--bordeaux);
    border-color: var(--bordeaux);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--bordeaux-hover);
    border-color: var(--bordeaux-hover);
    color: #ffffff;
}

.btn-navy {
    background: var(--blue);
    border-color: var(--blue);
    color: #ffffff;
}

.btn-navy:hover {
    background: var(--blue-bright);
    border-color: var(--blue-bright);
    color: #ffffff;
}

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

.btn-secondary:hover {
    background: var(--surface-alt);
    border-color: #94a3b8;
    color: var(--navy);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.36rem 0.72rem;
    border-radius: 6px;
}

.btn-block {
    width: 100%;
    display: flex;
}

/* =========================================================
   FORMULAIRES
   ========================================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    margin-bottom: 0.9rem;
}

.form-group label,
label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy-mid);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.5rem 0.72rem;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue-bright);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

input[type="file"] {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* =========================================================
   TABLEAUX & BADGES
   ========================================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.data-table thead th {
    text-align: left;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-bottom: 2px solid var(--border-light);
    padding: 0.7rem 0.75rem;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.22rem 0.58rem;
    border-radius: 999px;
    line-height: 1.25;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-amber {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.badge-red,
.badge-bordeaux {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.badge-gray {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

/* =========================================================
   ALERTES & UTILITAIRES
   ========================================================= */
.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.15rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.small-muted {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    background: var(--surface-alt);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 0.92rem;
}

/* =========================================================
   RESPONSIVE MOBILE
   ========================================================= */
@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

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

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .shell-topbar {
        padding: 0.65rem 1rem;
    }

    .shell-content {
        padding: 1rem;
    }
}