:root {
    color-scheme: light;
    font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
    --green: #47a326;
    --green-dark: #1f6b15;
    --leaf: #44AA2A;
    --leaf-soft: #eaf5e4;
    --fruit: #e85d04;
    --fruit-soft: #fff1dc;
    --leclerc-blue: #0b70b5;
    --leclerc-orange: #ed8b18;
    --readonly: #eef1ec;
    --readonly-border: #d5ddd0;
    --blue: #4169E1;
    --line: #d7dfd2;
    --danger: #c0392b;
    --muted: #607066;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f4f7f2;
    color: #142014;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 28px;
    color: #fff;
    background: linear-gradient(135deg, var(--green-dark), var(--green));
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-brand img {
    width: 78px;
    height: 78px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
}

.app-header h1 {
    margin: 0;
    font-size: 28px;
}

.app-header p {
    margin: 4px 0 0;
}

.header-actions,
.dialog-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-actions {
    flex: 0 0 auto;
    align-self: center;
    justify-content: flex-start;
}

.table-actions button {
    height: 38px;
    padding: 0 14px;
    white-space: nowrap;
}

main {
    padding: 22px 24px 40px;
}

.app-footer {
    padding: 18px 24px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    background: #ffffff;
}

button,
.button,
input,
select {
    font: inherit;
}

button,
.button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    background: var(--leclerc-blue);
    cursor: pointer;
    text-decoration: none;
}

button.secondary,
.button.secondary {
    background: var(--leclerc-blue);
}

button.secondary.active-filter {
    background: var(--leclerc-orange);
}

button.primary-action {
    background: var(--leclerc-orange);
}

#filterBriiButton {
    background: var(--leclerc-blue);
}

#copySelectionButton {
    background: var(--leclerc-blue);
}

#printBriiButton {
    background: var(--leclerc-blue);
}

#addArticleButton {
    background: var(--leclerc-orange);
}

button.danger {
    background: var(--danger);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #f0c27a;
    border-radius: 8px;
    background: var(--fruit-soft);
}

#articlesTable {
    width: 100% !important;
    table-layout: fixed;
    border-collapse: collapse;
    border-spacing: 0;
    background: #fff;
    font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 14px;
    border-left: 1px solid rgba(93, 125, 79, 0.14);
    border-right: 0;
}

#articlesTable_wrapper,
#articlesTable_wrapper input,
#articlesTable_wrapper select,
#articlesTable_wrapper button {
    font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
}

#articlesTable.dataTable thead th,
#articlesTable_wrapper .dt-scroll-head table.dataTable thead th,
#articlesTable:not(.dataTable) thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 54px;
    min-height: 54px;
    padding: 5px 6px;
    border-left: 0 !important;
    border-right: 1px solid rgba(93, 125, 79, 0.14) !important;
    border-bottom: 3px solid var(--fruit) !important;
    background: var(--leaf) !important;
    color: #fff;
    font-weight: 400;
    white-space: normal;
    line-height: 1.15;
    text-align: left !important;
    vertical-align: middle;
    word-break: normal;
}

#articlesTable_wrapper .dt-scroll-body #articlesTable thead,
#articlesTable_wrapper .dt-scroll-body #articlesTable thead tr,
#articlesTable_wrapper .dt-scroll-body #articlesTable thead th {
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    line-height: 0 !important;
    overflow: hidden !important;
    visibility: collapse !important;
}

#articlesTable_wrapper table.dataTable thead th,
#articlesTable_wrapper .dt-scroll-head table.dataTable thead th,
.dt-container table.dataTable thead th {
    text-align: left !important;
}

#articlesTable thead th.dt-center,
#articlesTable thead th.dt-right,
#articlesTable thead th.dt-type-numeric,
#articlesTable thead th.dt-type-date {
    text-align: left !important;
}

#articlesTable thead th .dt-column-header,
#articlesTable thead th.dt-center .dt-column-header,
#articlesTable thead th.dt-right .dt-column-header,
#articlesTable thead th.dt-type-numeric .dt-column-header,
#articlesTable thead th.dt-type-date .dt-column-header,
#articlesTable_wrapper table.dataTable thead th .dt-column-header,
#articlesTable_wrapper .dt-scroll-head table.dataTable thead th .dt-column-header,
.dt-container table.dataTable thead th .dt-column-header {
    justify-content: flex-start !important;
    text-align: left !important;
    align-items: center !important;
    gap: 4px !important;
}

#articlesTable thead th.dt-type-numeric .dt-column-header,
#articlesTable thead th.dt-type-date .dt-column-header,
#articlesTable_wrapper table.dataTable thead th.dt-type-numeric .dt-column-header,
#articlesTable_wrapper table.dataTable thead th.dt-type-date .dt-column-header,
.dt-container table.dataTable thead th.dt-type-numeric .dt-column-header,
.dt-container table.dataTable thead th.dt-type-date .dt-column-header {
    flex-direction: row !important;
}

#articlesTable thead th .dt-column-title,
#articlesTable_wrapper table.dataTable thead th .dt-column-title,
#articlesTable_wrapper .dt-scroll-head table.dataTable thead th .dt-column-title,
.dt-container table.dataTable thead th .dt-column-title {
    flex: 1 1 auto;
    text-align: left !important;
}

#articlesTable thead th .dt-column-order,
#articlesTable_wrapper table.dataTable thead th .dt-column-order,
.dt-container table.dataTable thead th .dt-column-order {
    margin-left: auto !important;
    text-align: right !important;
}

#articlesTable tbody td {
    padding: 5px 6px;
    border-top-color: #d9e3d2;
    border-bottom-color: #d9e3d2;
    border-left: 0;
    border-right: 1px solid rgba(93, 125, 79, 0.14);
    text-align: center !important;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#articlesTable thead th:first-child,
#articlesTable tbody td:first-child {
    border-left: 1px solid rgba(93, 125, 79, 0.14) !important;
}

#articlesTable thead th:last-child,
#articlesTable tbody td:last-child {
    border-right: 1px solid rgba(93, 125, 79, 0.14) !important;
}

#articlesTable thead th:first-child {
    border-left-color: var(--leaf) !important;
}

#articlesTable thead th:last-child {
    border-right-color: var(--leaf) !important;
}

#articlesTable tbody td.col-designation,
#articlesTable tbody td.col-origine,
#articlesTable tbody td.col-variete {
    text-align: left !important;
}

#articlesTable_wrapper .dt-scroll-head table.dataTable thead th {
    border-left: 0 !important;
    border-right: 1px solid rgba(93, 125, 79, 0.14) !important;
}

#articlesTable tbody tr:nth-child(even) td {
    background-color: #eef8e9;
}

#articlesTable tbody tr:hover td {
    background-color: #dff1d8;
}

.select-cell,
.actions-cell {
    text-align: center;
}

#articlesTable .col-select {
    width: 44px !important;
}

#articlesTable .col-ean {
    width: 140px !important;
}

#articlesTable .col-plu {
    width: 64px !important;
}

#articlesTable .col-designation {
    width: 251px !important;
}

#articlesTable .col-origine {
    width: 166px !important;
}

#articlesTable .col-variete {
    width: 166px !important;
}

#articlesTable .col-calibre {
    width: 92px !important;
}

#articlesTable .col-categorie,
#articlesTable .col-money,
#articlesTable .col-percent,
#articlesTable .col-number {
    width: 72px !important;
}

#articlesTable .col-date {
    width: 76px !important;
}

#articlesTable .col-actions {
    width: 58px !important;
}

#articlesTable tbody td.actions-cell {
    text-align: center !important;
}

#articlesTable thead th.actions-cell {
    display: table-cell;
}

.small-button {
    padding: 5px 6px;
    border-radius: 6px;
    font-size: 11px;
}

.button.disabled-action {
    background: #8c9688;
    color: #eef1ec;
    cursor: not-allowed;
    opacity: 0.8;
    pointer-events: none;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.status-valid {
    background: #16823a;
}

.status-invalid {
    background: #9ca3af;
    color: #f8fafc;
    cursor: not-allowed;
}

.missing {
    background: inherit;
}

.editable-cell {
    cursor: text;
    position: relative;
}

.editable-cell:hover {
    outline: 2px solid rgba(47, 125, 50, 0.45);
    outline-offset: -2px;
}

#articlesTable tbody td.readonly-cell,
#articlesTable tbody tr:nth-child(even) td.readonly-cell,
#articlesTable tbody tr:hover td.readonly-cell {
    background: var(--readonly);
    border-left: 0;
    border-right: 1px solid var(--readonly-border);
    color: #334033;
    font-weight: 600;
}

.editable-cell.saving {
    opacity: 0.65;
}

.inline-editor {
    width: 100%;
    min-width: 0;
    height: 30px;
    border: 2px solid var(--leaf);
    border-radius: 4px;
    padding: 4px 6px;
    background: #fff;
}

.alert-value {
    color: var(--danger);
    font-weight: 700;
}

#articlesTable tbody td.economy-status-ok,
#articlesTable tbody tr:nth-child(even) td.economy-status-ok,
#articlesTable tbody tr:hover td.economy-status-ok {
    color: #16823a;
    font-weight: 700;
}

#articlesTable tbody td.economy-status-low,
#articlesTable tbody tr:nth-child(even) td.economy-status-low,
#articlesTable tbody tr:hover td.economy-status-low {
    color: #055ffc;
    font-weight: 700;
}

#articlesTable tbody td.economy-status-high,
#articlesTable tbody tr:nth-child(even) td.economy-status-high,
#articlesTable tbody tr:hover td.economy-status-high {
    color: #c0392b;
    font-weight: 700;
}

#articlesTable tbody tr.row-attention td,
#articlesTable tbody tr.row-attention:hover td,
#articlesTable tbody tr:nth-child(even).row-attention td {
    background-color: var(--fruit-soft) !important;
}

#articlesTable tbody td.cell-attention {
    outline: 3px solid var(--fruit);
    outline-offset: -3px;
    box-shadow: inset 0 0 0 2px rgba(232, 93, 4, 0.2);
}

.dt-search input,
.dt-length select {
    border-color: #9ab98f;
    height: 38px;
}

#articlesTable_wrapper > .dt-layout-row:not(.dt-layout-table),
#articlesTable_wrapper > .table-controls-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

#articlesTable_wrapper .table-controls-left {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 12px;
    margin-right: 0 !important;
    text-align: left !important;
}

#articlesTable_wrapper > .table-controls-row > .dt-layout-start {
    margin-right: 0 !important;
}

#articlesTable_wrapper > .table-controls-row > .dt-layout-end {
    margin-left: auto !important;
}

#articlesTable_wrapper > .dt-layout-row:not(.dt-layout-table) > .dt-layout-cell {
    flex: 0 0 auto;
}

#articlesTable_wrapper > .dt-layout-row:not(.dt-layout-table) > .dt-layout-end {
    margin-left: auto;
}

.dt-paging-button.current {
    border-color: var(--leaf) !important;
    background: var(--leaf-soft) !important;
    color: #102510 !important;
}

dialog {
    width: min(920px, calc(100vw - 32px));
    border: 0;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    color: #fff;
    background: var(--green-dark);
}

.dialog-header h2 {
    margin: 0;
}

.icon-button {
    padding: 4px 10px;
    border-radius: 50%;
    font-size: 24px;
    background: transparent;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 20px 22px;
}

label {
    display: grid;
    gap: 5px;
    font-weight: 700;
}

label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

label.wide {
    grid-column: span 2;
}

input,
select {
    width: 100%;
    border: 1px solid #b8c5b3;
    border-radius: 7px;
    padding: 9px 10px;
    background: #fff;
}

input:required:placeholder-shown {
    background: var(--yellow);
}

.form-errors {
    margin: 16px 22px 0;
    padding: 12px;
    border-radius: 8px;
    color: #721c12;
    background: #f8d7da;
}

.dialog-actions {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    padding: 16px 22px 22px;
    border-top: 1px solid var(--line);
}

.action-dialog {
    width: min(520px, calc(100vw - 32px));
}

.action-dialog .dialog-header {
    background: var(--fruit);
}

.action-dialog-body {
    padding: 22px 24px 8px;
    color: #1f2a1f;
    font-size: 16px;
    line-height: 1.45;
}

.action-dialog-body p {
    margin: 0;
}

.action-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 18px 24px 24px;
}

.toast-container {
    position: fixed;
    top: 22px;
    left: 50%;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(460px, calc(100vw - 32px));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    padding: 12px 14px;
    border-left: 5px solid var(--green-dark);
    border-radius: 10px;
    color: #142014;
    background: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    font-weight: 700;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
    pointer-events: auto;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-hiding {
    opacity: 0;
    transform: translateY(8px);
}

.toast-success {
    border-left-color: #16823a;
}

.toast-warning {
    border-left-color: var(--fruit);
}

.toast-error {
    border-left-color: var(--danger);
}

.print-frame {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
