:root {
    --vert: #1E5638;
    --vert-clair: #2E7D52;
    --sable: #F1EADB;
    --bone: #FBF8F1;
    --ocre: #C46126;
    --ambre: #E0A23B;
    --beton: #6E6B61;
    --ligne: #DBD2BF;
    --charbon: #211E18;
    --rouge: #C0492F;
    --shadow: 0 16px 36px -16px rgba(33, 30, 24, 0.25);
    --shadow-sm: 0 6px 16px -8px rgba(33, 30, 24, 0.20);
    --r: 16px;
    --font: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background: var(--sable);
    color: var(--charbon);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.wrap {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
}

/* Header & Navigation */
.topbar {
    background: rgba(241, 234, 219, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ligne);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.brand .mark {
    display: grid;
    place-items: center;
}

.brand b {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 18px;
    font-weight: 800;
    display: block;
    line-height: 1.1;
}

.brand small {
    font-size: 11px;
    color: var(--beton);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge-sync {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid transparent;
}

.sync-ok {
    background: #dcefe2;
    color: var(--vert);
    border-color: #bfe6cf;
}

.sync-pending {
    background: #f7ecd5;
    color: #a9761f;
    border-color: var(--ligne);
}

.user-profile {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--vert);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    font-family: 'Bricolage Grotesque', sans-serif;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 42px;
    background: #fff;
    min-width: 140px;
    box-shadow: var(--shadow);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--ligne);
}

.dropdown-content a {
    color: var(--charbon);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    font-weight: 500;
}

.dropdown-content a:hover {
    background: var(--bone);
}

.dropdown-content.show {
    display: block;
}

/* Hero Section */
.hero {
    padding: 60px 0;
    background: linear-gradient(180deg, rgba(241,234,219,0.5) 0%, rgba(251,248,241,0.8) 100%);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 40px;
    align-items: center;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ocre);
    margin-bottom: 16px;
}

.eyebrow .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ocre);
}

h1, h2, h3 {
    font-family: 'Bricolage Grotesque', sans-serif;
    color: var(--charbon);
    font-weight: 800;
    line-height: 1.05;
}

h1 {
    font-size: clamp(34px, 5vw, 56px);
}

.text-green {
    color: var(--vert);
}

p.lead {
    font-size: 17px;
    color: #555048;
    margin: 20px 0 32px;
    max-width: 32em;
    line-height: 1.6;
}

.cta-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14.5px;
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--vert);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--vert-clair);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-ghost {
    background: transparent;
    border-color: var(--ligne);
    color: var(--charbon);
}

.btn-ghost:hover {
    background: var(--bone);
    transform: translateY(-2px);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.hero-photo {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

.hero-image .image-placeholder {
    width: 100%;
    height: 320px;
    background: linear-gradient(135deg, var(--vert), #133924);
    border-radius: var(--r);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--sable);
    position: relative;
    box-shadow: var(--shadow);
}

.img-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 10px;
}

/* Catalogue & Cartes */
.catalog-section {
    padding: 60px 0;
}

.section-title {
    font-size: 28px;
    margin-bottom: 32px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 40px;
    height: 3px;
    background: var(--ocre);
    border-radius: 2px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.card {
    background: var(--bone);
    border: 1px solid var(--ligne);
    border-radius: var(--r);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.catalog-card {
    display: flex;
    flex-direction: column;
}

.catalog-card h3 {
    font-size: 20px;
    margin-bottom: 4px;
}

.catalog-card .format {
    font-size: 13px;
    color: var(--beton);
    margin-bottom: 16px;
}

.catalog-card .price {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 22px;
    color: var(--vert);
    margin-top: auto;
}

/* Devis Section */
.devis-section {
    padding: 20px 0 60px;
}

.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 24px;
}

.form-grid .form-group:last-child {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.form-control, input[type="text"], input[type="tel"], input[type="number"], input[type="date"], select {
    padding: 10px 14px;
    border: 1px solid var(--ligne);
    border-radius: 8px;
    background: #fff;
    color: var(--charbon);
    font-family: var(--font);
    font-size: 14.5px;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-control:focus, input:focus, select:focus {
    border-color: var(--vert);
}

.devis-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.product-row-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px dashed var(--ligne);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--ligne);
    background: #fff;
    color: var(--vert);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.stepper span {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    width: 40px;
    text-align: center;
}

.form-submit {
    margin-top: 32px;
    text-align: center;
}

/* Login View */
#view-login.active {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 140px);
}

.login-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.login-card p {
    margin-bottom: 24px;
    color: var(--beton);
}

.login-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Admin Tabs Navigation */
.admin-nav {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--ligne);
    padding-bottom: 12px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.nav-tab {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    color: var(--beton);
    transition: all 0.15s ease;
}

.nav-tab:hover {
    background: var(--bone);
    color: var(--charbon);
}

.nav-tab.active {
    background: var(--vert);
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bone);
    border: 1px solid var(--ligne);
    border-radius: var(--r);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.kpi-card.lead-card {
    background: var(--vert);
    border-color: var(--vert);
    color: #fff;
}

.kpi-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--beton);
}

.kpi-card.lead-card .label {
    color: rgba(255,255,255,0.7);
}

.kpi-card .val {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 24px;
    font-weight: 800;
}

.kpi-card .val.mono {
    font-family: 'JetBrains Mono', monospace;
}

.kpi-card .trend {
    font-size: 11px;
    font-weight: 600;
}

.kpi-card .sub {
    font-size: 11px;
    color: var(--beton);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 24px;
}

/* Tables style */
.table-compact {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.table-compact th, .table-compact td {
    padding: 10px 12px;
    text-align: left;
    font-size: 13.5px;
    border-bottom: 1px solid var(--ligne);
}

.table-compact th {
    background: var(--sable);
    font-weight: 700;
    color: var(--charbon);
}

.table-compact tbody tr:hover {
    background: rgba(251, 248, 241, 0.5);
}

.badge-state {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
}

.state-demande { background: #eee; color: #555; }
.state-proforma { background: #e0f2fe; color: #0369a1; }
.state-bc { background: #fef3c7; color: #d97706; }
.state-production { background: #fae8ff; color: #c026d3; }
.state-prete { background: #ecfdf5; color: #059669; }
.state-livree { background: #dcfce7; color: #15803d; }
.state-payee { background: #dcfce7; color: #166534; border: 1px solid #166534; }

/* Alerts list */
.stock-alerts-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.stock-alerts-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--ligne);
}

.stock-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(33, 30, 24, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--r);
    padding: 32px;
    max-width: 600px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow);
    border: 1px solid var(--ligne);
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: 700;
    cursor: pointer;
    color: var(--beton);
}

.order-items-selection {
    max-height: 240px;
    overflow-y: auto;
    margin: 16px 0;
    border: 1px solid var(--ligne);
    border-radius: 8px;
    padding: 8px;
}

.total-summary {
    background: var(--bone);
    border: 1px solid var(--ligne);
    border-radius: 8px;
    padding: 14px;
    margin-top: 14px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 700;
}

/* Canvas pour Signature */
.canvas-container {
    border: 2px dashed var(--ligne);
    background: #fdfdfd;
    border-radius: 8px;
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

#signature-canvas {
    background: transparent;
    cursor: crosshair;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Gating Rôles */
.check-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Tournées List card */
.tournee-card {
    border: 1px solid var(--ligne);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
    margin-bottom: 12px;
}

.tournee-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ligne);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.hidden {
    display: none !important;
}

/* =======================================
   IMPRESSION ET PDF STYLING (@media print)
   ======================================= */
@media print {
    .no-print {
        display: none !important;
    }
    
    html, body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
    }
    
    .print-only {
        display: block !important;
    }
    
    .print-card {
        padding: 20mm;
        border: none;
        width: 100%;
    }
    
    .print-header {
        display: flex;
        justify-content: space-between;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }
    
    .print-title {
        font-family: 'Bricolage Grotesque', sans-serif;
        font-size: 26pt;
        font-weight: 800;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin: 20px 0;
    }
    
    .print-table th, .print-table td {
        border: 1px solid #ddd;
        padding: 8px 12px;
        text-align: left;
    }
    
    .print-table th {
        background: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
    }
    
    .print-footer {
        margin-top: 40px;
        display: flex;
        justify-content: space-between;
        font-size: 10pt;
        color: #555;
    }
    
    .signature-area {
        margin-top: 30px;
        text-align: right;
    }
    
    .signature-box {
        border: 1px solid #000;
        width: 150px;
        height: 80px;
        display: inline-block;
    }
}

.print-only {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .cta-row {
        justify-content: center;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .admin-nav {
        flex-wrap: nowrap;
    }
}
