:root {
    --bg: #f4f7fc;
    --white: #ffffff;
    --text: #07152f;
    --muted: #64748b;
    --blue: #0d5cff;
    --blue-hover: #004be0;
    --border: #e2e8f0;
    --border-soft: #edf2f7;
    --shadow: 0 10px 30px rgba(15, 23, 42, .06);
    --shadow-hover: 0 18px 45px rgba(13, 92, 255, .16);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, system-ui, sans-serif;
}

a {
    text-decoration: none;
    color: inherit;
}

/* LAYOUT */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

/* SIDEBAR */

.sidebar {
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 34px;
}

.brand-logo {
    width: 72px;
    max-height: 48px;
    object-fit: contain;
}

.brand-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--text);
}

.brand-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--blue);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    height: 48px;
    padding: 0 16px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    gap: 13px;
    color: #475569;
    font-weight: 800;
    font-size: 15px;
    transition: .22s ease;
}

.nav-link i {
    font-size: 18px;
}

.nav-link:hover,
.nav-link.active {
    background: var(--blue);
    color: white;
    box-shadow: 0 10px 24px rgba(13, 92, 255, .22);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.user-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-icon {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--blue);
    color: white;
    display: grid;
    place-items: center;
    font-size: 20px;
}

.user-name {
    font-size: 14px;
    font-weight: 900;
    color: var(--text);
}

.user-role {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
}

.logout-btn {
    height: 46px;
    border-radius: 9px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #ef4444;
    font-weight: 900;
    transition: .22s ease;
}

.logout-btn:hover {
    background: #fff1f2;
    border-color: #fecdd3;
}

/* MAIN */

.main-content {
    padding: 44px 54px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 34px;
}

.page-label {
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 5px;
    margin-bottom: 10px;
}

.page-header h1 {
    font-size: 42px;
    line-height: 1;
    font-weight: 950;
    letter-spacing: -1px;
    color: var(--text);
}

/* MODULES */

.modules-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 18px;
}

.module-card {
    min-height: 210px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    position: relative;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
    transition:
        transform .22s ease,
        border-color .22s ease,
        box-shadow .22s ease;
}

.module-card:hover {
    transform: translateY(-4px);
    border-color: var(--blue);
    box-shadow:
        0 0 0 4px rgba(13, 92, 255, .11),
        var(--shadow-hover);
}

.module-icon {
    width: 48px;
    height: 48px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    font-size: 24px;
}

.module-icon.blue {
    background: #e0f2fe;
    color: var(--blue);
}

.module-card:hover .module-icon {
    background: var(--blue);
    color: white;
}

.module-card h2 {
    font-size: 19px;
    font-weight: 950;
    color: var(--text);
    margin-bottom: 12px;
}

.module-card p {
    max-width: 220px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted);
}

.module-arrow {
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: var(--blue);
    background: white;
    transition: .22s ease;
}

.module-card:hover .module-arrow {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}

/* RESPONSIVE */

@media (max-width: 1200px) {
    .modules-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 850px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 28px 18px;
    }

    .page-header h1 {
        font-size: 34px;
    }

    .modules-grid {
        grid-template-columns: 1fr;
    }
}

/* RELIQUAT PAGE */

.reliquat-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-box {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.stat-box strong {
    display: block;
    margin-top: 12px;
    font-size: 28px;
    font-weight: 950;
    color: var(--text);
}

.stat-box span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.panel-card,
.table-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
    margin-bottom: 18px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.form-control-box {
    display: grid;
    gap: 7px;
}

.form-control-box label {
    font-size: 12px;
    font-weight: 900;
    color: var(--text);
}

.form-control-box input {
    height: 44px;
    border-radius: 9px;
    border: 2px solid var(--border);
    padding: 0 12px;
    outline: none;
    font-weight: 700;
    color: var(--text);
}

.form-control-box input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(13, 92, 255, .11);
}

.filter-actions,
.actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.actions-bar {
    margin-bottom: 18px;
}

.btn-main,
.btn-soft,
.btn-danger-custom {
    height: 44px;
    padding: 0 16px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 900;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: .22s ease;
    text-decoration: none;
}

.btn-main {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

.btn-main:hover {
    background: var(--blue-hover);
}

.btn-soft {
    background: white;
    color: var(--text);
}

.btn-soft:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.btn-danger-custom {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-scroll {
    overflow: auto;
    max-height: 650px;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1300px;
}

.modern-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fafc;
    color: var(--text);
    font-size: 12px;
    text-align: left;
    padding: 14px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.modern-table th a {
    color: var(--text);
    text-decoration: none;
}

.modern-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    vertical-align: top;
}

.modern-table tbody tr:hover {
    background: #f8fbff;
}

.chip,
.zone-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e0f2fe;
    color: var(--blue);
    font-weight: 900;
}

.table-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.table-actions a {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--blue);
    background: white;
    transition: .2s ease;
}

.table-actions a:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

.empty-table {
    text-align: center;
    color: var(--muted);
    padding: 30px !important;
}

.gp-pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, .70);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.gp-pdf-modal[hidden] {
    display: none;
}

.gp-pdf-panel {
    width: min(1200px, 96vw);
    height: min(88vh, 1000px);
    background: white;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gp-pdf-toolbar {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gp-pdf-panel iframe {
    flex: 1;
    border: 0;
}

@media (max-width: 1200px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-actions {
        grid-column: 1 / -1;
    }

    .reliquat-stats {
        grid-template-columns: 1fr;
    }
}

/* Une ligne sur deux légèrement grise */
.modern-table tbody tr:nth-child(odd) {
    background: #f8fafc;
}

.modern-table tbody tr:nth-child(even) {
    background: #eef2f7;
}

/* Hover plus propre */
.modern-table tbody tr:hover {
    background: #dbeafe !important;
}

/* STATS RELIQUATS */

.stats-filter-grid {
    grid-template-columns: 220px 220px auto 1fr;
}

.stats-period {
    font-size: 13px;
    color: var(--muted);
    font-weight: 800;
    align-self: center;
}

.stats-period strong {
    color: var(--text);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.stats-chart-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}

.stats-card-header h2 {
    font-size: 20px;
    font-weight: 950;
    color: var(--text);
    margin-bottom: 6px;
}

.stats-card-header p {
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
}

.stats-chart-full {
    margin-top: 0;
}

.gp-chart-wrap {
    width: 100%;
    min-height: 180px;
}

@media (max-width: 1200px) {
    .stats-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stats-period {
        grid-column: 1 / -1;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
/* FORMULAIRE EDIT PALETTE */

.form-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.form-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.form-card-header h2 {
    font-size: 24px;
    font-weight: 950;
    color: var(--text);
    margin-bottom: 6px;
}

.form-card-header p {
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
}

.modern-form {
    display: grid;
    gap: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 16px;
}

.form-col-2 {
    grid-column: span 2;
}

.form-col-3 {
    grid-column: span 3;
}

.form-control-box {
    display: grid;
    gap: 7px;
}

.form-control-box label {
    font-size: 13px;
    font-weight: 900;
    color: var(--text);
}

.required-star {
    color: #ef4444;
}

.form-control-box input,
.form-control-box select,
.form-control-box textarea {
    width: 100%;
    min-height: 46px;
    border-radius: 9px;
    border: 2px solid var(--border);
    padding: 0 13px;
    outline: none;
    color: var(--text);
    background: white;
    font-weight: 700;
    transition: .22s ease;
}

.form-control-box textarea {
    padding: 12px 13px;
    resize: vertical;
}

.form-control-box select[multiple] {
    min-height: 150px;
    padding: 10px;
}

.form-control-box input:focus,
.form-control-box select:focus,
.form-control-box textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(13, 92, 255, .11);
}

.form-control-box input[readonly] {
    background: #f8fafc;
    color: var(--muted);
}

.form-control-box small {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

.scan-field {
    display: flex;
    gap: 10px;
}

.scan-field input {
    flex: 1;
}

.scanner-box {
    display: none;
    width: 100%;
    max-width: 420px;
    margin-top: 10px;
    border-radius: 12px;
    overflow: hidden;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 1000px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-col-2,
    .form-col-3 {
        grid-column: span 1;
    }

    .scan-field {
        flex-direction: column;
    }
}
/* SAV / RETOUR FOURNISSEUR */

.actions-bar-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.actions-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modern-check {
    width: 17px;
    height: 17px;
    accent-color: var(--blue);
    cursor: pointer;
}

.cell-prewrap {
    white-space: pre-wrap;
}

.cell-muted {
    color: var(--muted) !important;
}

.table-actions form {
    display: inline-flex;
}

.table-actions button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--blue);
    background: white;
    transition: .2s ease;
    cursor: pointer;
}

.table-actions button:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

#btn-export:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.gp-pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, .70);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.gp-pdf-panel {
    width: min(1200px, 96vw);
    height: min(88vh, 1000px);
    background: white;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gp-pdf-toolbar {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.gp-pdf-panel iframe {
    flex: 1;
    border: 0;
}

@media (max-width: 900px) {
    .actions-bar-card {
        flex-direction: column;
    }

    .actions-left {
        flex-direction: column;
    }
}