:root {
    --green-950: #073d25;
    --green-900: #064d2c;
    --green-800: #0a6236;
    --green-100: #e9f4e7;
    --cream: #fbfaf5;
    --paper: #fffefa;
    --ink: #15251c;
    --muted: #5d6962;
    --line: #d9d7cc;
    --amber: #a45a00;
    --amber-bg: #fff2d5;
    --red: #b42318;
    --red-bg: #fee9e7;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}
html {
    font-size: 18px;
}
body {
    margin: 0;
    color: var(--ink);
    background: var(--cream);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}
a {
    color: var(--green-900);
    text-underline-offset: 3px;
}
img {
    border: 0;
    max-width: 100%;
}

#global {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    text-align: left;
}
.app-sidebar {
    grid-row: 1 / -1;
    background: var(--green-950);
    color: #fff;
    min-height: 100vh;
}
.brand {
    display: block;
    padding: 24px 28px 18px;
    background: #fff;
}
.brand img {
    display: block;
    width: 185px;
    margin: auto;
}
.app-sidebar nav {
    padding: 14px 0;
}
.nav-form {
    margin: 0;
}
.nav-link {
    min-height: 62px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    justify-content: flex-start;
    font-size: 1rem;
}
.nav-link:hover,
.nav-link:focus-visible,
.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
}
.nav-icon {
    width: 30px;
    font-size: 28px;
    text-align: center;
}
.app-header {
    grid-column: 2;
    min-height: 126px;
    padding: 28px 36px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.app-header strong {
    display: block;
    color: var(--green-950);
    font-size: clamp(1.35rem, 2.3vw, 2rem);
}
.today {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}
.logout-form {
    margin: 0;
}

#centre {
    grid-column: 2;
    padding: 34px 36px 56px;
    min-width: 0;
    overflow: auto;
}
#centre > h1:first-child,
#centre > h2:first-child {
    margin-top: 0;
}
#centre > img[src*="titre"],
#centre > h1[style*="background:url"] {
    display: none;
}
#centre > div[style*="float:left"],
#centre > div[style*="float:right"] {
    float: none !important;
    display: block !important;
    margin-bottom: 32px;
}
h1 {
    color: var(--green-950);
    font-size: 2rem;
    line-height: 1.15;
}
h2 {
    color: var(--green-950);
    font-size: 1.55rem;
}
h3 {
    color: var(--green-900);
    font-size: 1.25rem;
    margin-top: 34px;
}

button,
input,
select,
textarea {
    font: inherit;
}
input:not([type]),
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="email"],
input[type="tel"],
select,
textarea {
    min-height: 52px;
    padding: 10px 13px;
    border: 2px solid #9ba49e;
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    line-height: 1.35;
    box-shadow: none;
}
input:not([type]),
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="email"],
input[type="tel"],
select {
    height: 52px;
}
select {
    padding-right: 40px;
}
.ss-main {
    min-height: 52px;
    border: 2px solid #9ba49e;
    border-radius: var(--radius);
    color: var(--ink);
}
.ss-main:focus,
.ss-main.ss-open-below,
.ss-main.ss-open-above {
    border-color: var(--green-700);
    box-shadow: 0 0 0 3px rgba(59, 107, 68, 0.14);
}
.ss-main .ss-values {
    padding: 7px 12px;
}
.ss-main .ss-values .ss-single {
    margin: 0;
    color: var(--ink);
    line-height: 1.35;
}
.ss-main .ss-values .ss-placeholder {
    color: var(--muted);
}
.ss-main .ss-arrow {
    margin-right: 12px;
}
.ss-content {
    border: 2px solid #9ba49e;
    border-radius: var(--radius);
    box-shadow: 0 12px 28px rgba(21, 37, 28, 0.14);
}
.ss-content .ss-search input {
    min-height: 44px;
    border: 2px solid #9ba49e;
    border-radius: var(--radius);
}
.ss-content .ss-search input:focus {
    border-color: var(--green-700);
    box-shadow: 0 0 0 3px rgba(59, 107, 68, 0.14);
}
.ss-content .ss-list .ss-option {
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ink);
}
.ss-content .ss-list .ss-option:hover,
.ss-content .ss-list .ss-option.ss-highlighted {
    background: var(--green-100);
    color: var(--green-950);
}
.ss-content .ss-list .ss-optgroup .ss-optgroup-label {
    color: var(--muted);
    font-weight: 700;
}
input:disabled,
select:disabled,
textarea:disabled {
    background: #efeee8;
    color: #626b66;
    cursor: not-allowed;
}
textarea {
    width: 100%;
    min-height: 100px;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 4px solid #f2bd4b;
    outline-offset: 2px;
}
input[type="checkbox"],
input[type="radio"] {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    accent-color: var(--green-800);
}
input[type="submit"],
button,
.button {
    min-height: 52px;
    padding: 11px 22px;
    border: 2px solid var(--green-800);
    border-radius: var(--radius);
    background: var(--green-800);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}
input[type="submit"]:hover:not(:disabled),
button:hover:not(:disabled),
.button:hover {
    background: var(--green-950);
    border-color: var(--green-950);
    color: #fff;
    box-shadow: 0 4px 12px rgba(7, 61, 37, 0.18);
    transform: translateY(-1px);
}
.button-ghost {
    background: transparent;
    color: var(--green-900);
}
.button-ghost:hover {
    color: #fff;
}
.button-danger {
    border-color: var(--red);
    background: transparent;
    color: var(--red);
}
.button-danger:hover {
    background: var(--red);
    color: #fff;
}
button:disabled,
input[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

form {
    margin: 0 0 24px;
}
table {
    border-collapse: collapse;
    width: 100%;
    background: var(--paper);
}
table.list {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
table.list th,
table.list td,
table.list tr td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.list tr:first-child,
table.list thead tr,
.impaire {
    background: #f3f1e9;
    font-weight: 700;
}
table.list tr:hover:not(:first-child) {
    background: #f8fbf6;
}
.bgrouge {
    background: var(--red-bg) !important;
}
.bgorange {
    background: var(--amber-bg) !important;
}
.bggris {
    background: #f0efe8;
}
.bggrisf {
    background: #deddd5;
}
.borderhb {
    border: none;
}
.listlabel {
    display: inline-block;
    width: min(100%, 330px);
    padding: 8px;
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}
.page-toolbar h1 {
    margin: 0;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(330px, 1fr);
    gap: 24px;
    align-items: start;
}
.dashboard-grid > section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--paper);
}
.dashboard-grid > section > h2 {
    margin: 0;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}
.dashboard-grid > section > table {
    border: 0;
}
.dashboard-grid > section > p {
    padding: 0 18px 18px;
}
.status {
    display: inline-block;
    border-radius: 6px;
    padding: 5px 10px;
    font-weight: 700;
}
.status-ok {
    color: var(--green-950);
    background: var(--green-100);
}
.status-warning {
    color: var(--amber);
    background: var(--amber-bg);
}
.status-danger {
    color: var(--red);
    background: var(--red-bg);
}
.feedback_ko {
    color: #fff;
    background: var(--red);
    padding: 15px;
    margin-bottom: 24px;
    border-radius: var(--radius);
}
.feedback_ok {
    color: var(--green-950);
    background: var(--green-100);
    padding: 15px;
    margin-bottom: 24px;
    border-radius: var(--radius);
}
.back-link {
    display: inline-block;
    margin-bottom: 10px;
    font-weight: 700;
}
.client-title h1 {
    margin: 0 0 6px;
    max-width: 900px;
}
.client-title p {
    margin: 0;
    color: var(--muted);
}
.client-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    align-items: start;
}
.content-section {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
.section-heading {
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.section-heading h2 {
    margin: 0 0 5px;
}
.section-heading p {
    margin: 0;
    color: var(--muted);
}
.form-grid {
    display: grid;
    gap: 18px;
}
.form-grid label,
.history-filters label,
.favorite-add label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}
.form-grid input {
    width: 100%;
}
.form-actions {
    padding-top: 4px;
}
.history-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: end;
}
.history-filters button {
    grid-column: 1 / -1;
    justify-self: start;
}
.empty-state {
    padding: 22px;
    border: 1px dashed #9ba49e;
    border-radius: var(--radius);
    color: var(--muted);
    background: #faf9f4;
}
.favorite-add {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(360px, 2fr) auto;
    gap: 14px;
    align-items: end;
}
.favorite-add > label:first-child {
    grid-column: 1 / -1;
}
.favorite-add select {
    grid-column: 1 / 3;
    width: 100%;
}
.favorite-add .ss-main {
    grid-column: 1 / 3;
}
.favorites-section table form {
    margin: 0;
}
.delivery-steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin: 0 0 30px;
    padding: 0;
    border-bottom: 1px solid var(--line);
}
.delivery-steps.workflow-four {
    grid-template-columns: repeat(4, 1fr);
}
.delivery-steps li {
    padding: 16px 20px;
    border-bottom: 4px solid transparent;
    display: grid;
    gap: 3px;
    color: var(--muted);
}
.delivery-steps li.active {
    color: var(--green-950);
    border-bottom-color: var(--green-800);
}
.delivery-steps li.done {
    color: var(--green-900);
    border-bottom-color: #8bb89b;
}
.delivery-steps span {
    font-size: 0.88rem;
}
.delivery-form {
    margin: 0;
}
.delivery-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: end;
}
.delivery-info-grid > * {
    min-width: 0;
}
.delivery-info-grid > label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}
.delivery-info-grid select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
.delivery-info-grid fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}
.delivery-info-grid legend {
    font-weight: 700;
    margin-bottom: 7px;
}
.period-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.period-options label {
    position: relative;
}
.period-options input {
    position: absolute;
    opacity: 0;
}
.period-options span {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #9ba49e;
    background: #fff;
    font-weight: 700;
    white-space: nowrap;
}
.period-options label:first-child span {
    border-radius: var(--radius) 0 0 var(--radius);
}
.period-options label:last-child span {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: 0;
}
.period-options input:checked + span {
    background: var(--green-800);
    border-color: var(--green-800);
    color: #fff;
}
.period-options input:focus-visible + span {
    outline: 4px solid #f2bd4b;
    outline-offset: 2px;
}
.client-picker-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
}
.client-search {
    display: grid;
    gap: 7px;
    font-weight: 700;
    max-width: 620px;
    margin-bottom: 16px;
}
.client-checklist {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.client-choice {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.client-choice:nth-child(odd) {
    border-right: 1px solid var(--line);
}
.client-choice:hover {
    background: #f3f8f1;
}
.client-choice:has(input:checked) {
    background: var(--green-100);
    font-weight: 700;
}
.client-choice[hidden] {
    display: none;
}
.delivery-actions {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 16px 0;
    background: var(--cream);
    border-top: 1px solid var(--line);
}
.delivery-actions > span {
    text-align: center;
    color: var(--muted);
}
.delivery-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    margin-bottom: 24px;
}
.delivery-summary > span {
    padding: 16px 20px;
    border-right: 1px solid var(--line);
}
.delivery-summary > span:last-child {
    border-right: 0;
}
.delivery-summary .summary-action {
    margin-left: auto;
}
.delivery-client .section-heading {
    margin-bottom: 0;
}
.quantity-table {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}
.quantity-input {
    width: 150px;
    text-align: center;
    font-weight: 700;
}
.add-product-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin: 20px 0;
}
.add-product-row label,
.client-comment {
    display: grid;
    gap: 7px;
    font-weight: 700;
}
.add-product-row select {
    width: 100%;
}
.save-state {
    min-height: 24px;
    color: var(--green-800);
    font-weight: 400;
}
.order-alert {
    box-shadow: inset 5px 0 0 var(--red);
    background: var(--red-bg);
}
.lot-row {
    display: grid;
    grid-template-columns: 0.7fr 1.2fr 1fr auto;
    gap: 14px;
    align-items: end;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.lot-row label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    min-width: 0;
}
.lot-row input {
    width: 100%;
    min-width: 0;
}
.lots + .add-lot {
    margin-top: 14px;
}
.document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.checkbox-setting {
    grid-column: 1 / -1;
    display: flex !important;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}
.verification-client {
    padding: 0;
    overflow: hidden;
}
.verification-client .section-heading {
    padding: 20px 24px 16px;
    margin: 0;
}
.verification-client table {
    border: 0;
    border-radius: 0;
}
.delivery-comment {
    padding: 16px 24px;
    background: #f7f5ed;
    border-top: 1px solid var(--line);
}
.validation-panel {
    display: grid;
    gap: 4px;
    padding: 20px 24px;
    border: 1px solid;
    border-radius: var(--radius);
    margin-bottom: 14px;
}
.validation-panel.ready {
    color: var(--green-950);
    background: var(--green-100);
    border-color: #8bb89b;
}
.validation-panel.not-ready {
    color: var(--amber);
    background: var(--amber-bg);
    border-color: #e1ad55;
}
.delivery-actions form {
    margin: 0;
}
.product-list .button-ghost {
    min-width: 142px;
}
.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.history-search-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 16px;
    align-items: end;
}
.history-search-grid label {
    display: grid;
    gap: 7px;
    min-width: 0;
    font-weight: 700;
}
.history-search-grid input,
.history-search-grid select {
    width: 100%;
    min-width: 0;
}
.history-search-form table,
.history-search-form tbody {
    display: block;
    width: 100%;
}
.history-search-form tr {
    display: grid;
    grid-template-columns: auto minmax(150px, 1fr) auto minmax(150px, 1fr) auto;
    gap: 12px;
    align-items: center;
}
.history-search-form td {
    min-width: 0;
    padding: 6px !important;
}
.history-search-form input,
.history-search-form select {
    width: 100%;
    min-width: 0;
}
.list td > form[style*="display:inline"] {
    display: inline-block !important;
    margin: 4px 0;
}
.product-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.product-form-grid label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}
.product-form-grid input,
.product-form-grid select {
    width: 100%;
}
.product-comment,
.product-form-grid .form-actions {
    grid-column: 1 / -1;
}

/* Même langage de blocs sur les écrans historiques. */
#centre > form:not(.logout-form):not(.nav-form):not(.delivery-form),
#centre > table.list,
#centre > div[style*="float:left"],
#centre > div[style*="float:right"] {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
#centre > form > table {
    border: 0;
}
#centre > form > table td {
    padding: 9px;
}
#centre > table.list {
    overflow: hidden;
}
#centre > table.list + h2,
#centre > table.list + h3 {
    margin-top: 34px;
}
.page-toolbar + form {
    margin-top: 8px;
}

#login {
    background: var(--cream);
}
#login #global {
    display: block;
    width: min(100% - 32px, 620px);
    margin: auto;
}
#login #centre {
    min-height: 100vh;
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#login #centre img {
    width: 250px;
    margin-bottom: 24px;
}
#login h1 {
    text-align: center;
    margin: 0 0 28px;
}
#login form {
    width: min(100%, 420px);
}
#login label {
    display: block;
    font-weight: 700;
    margin: 14px 0 6px;
}
#login input {
    width: 100%;
    margin: 0 0 12px;
}
#login .bts {
    margin-top: 16px;
}

@media (max-width: 900px) {
    #global {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    .app-sidebar {
        grid-row: 1;
        min-height: auto;
    }
    .brand {
        padding: 12px;
    }
    .brand img {
        width: 130px;
    }
    .app-sidebar nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }
    .nav-link {
        min-width: max-content;
        min-height: 58px;
        padding: 8px 14px;
    }
    .nav-icon {
        display: none;
    }
    .app-header,
    #centre {
        grid-column: 1;
    }
    .app-header {
        min-height: auto;
        padding: 18px;
    }
    .app-header strong {
        font-size: 1.25rem;
    }
    #centre {
        padding: 24px 18px 42px;
    }
    table.list {
        min-width: 720px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .client-layout {
        grid-template-columns: 1fr;
    }
    .history-filters,
    .favorite-add {
        grid-template-columns: 1fr;
    }
    .product-form-grid {
        grid-template-columns: 1fr;
    }
    .product-comment,
    .product-form-grid .form-actions {
        grid-column: auto;
    }
    .favorite-add > label:first-child,
    .favorite-add select,
    .favorite-add .ss-main {
        grid-column: auto;
    }
    .delivery-steps {
        grid-template-columns: 1fr;
    }
    .delivery-steps.workflow-four {
        grid-template-columns: 1fr 1fr;
    }
    .delivery-info-grid,
    .client-checklist,
    .delivery-actions {
        grid-template-columns: 1fr;
    }
    .add-product-row {
        grid-template-columns: 1fr;
    }
    .client-choice:nth-child(odd) {
        border-right: 0;
    }
    .delivery-actions > span {
        text-align: left;
    }
}
@media (max-width: 1250px) {
    .delivery-info-grid {
        grid-template-columns: 1fr 1fr;
    }
    .delivery-info-grid > label:last-child {
        grid-column: 1 / -1;
    }
    .history-search-grid {
        grid-template-columns: 1fr 1fr;
    }
    .history-search-grid button {
        justify-self: start;
    }
}
@media (max-width: 650px) {
    .delivery-info-grid,
    .history-search-grid {
        grid-template-columns: 1fr;
    }
    .delivery-info-grid > label:last-child {
        grid-column: auto;
    }
    .content-section {
        padding: 18px;
    }
    .page-toolbar > input,
    .page-toolbar > select,
    .page-toolbar > button {
        width: 100%;
    }
    .history-search-form tr {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .lot-row {
        grid-template-columns: 1fr;
    }
}
.loading-sheet {
    display: none;
}
