/* ===== Tokens : clair (A) par défaut, sombre (B) ===== */
:root {
  box-sizing: border-box;
  --bg: #f3f5f7; --surface: #ffffff; --surface-2: #e6ecef;
  --topbar: #0b3c49; --topbar-ink: #ffffff;
  --ink: #14212b; --ink-soft: #566573; --line: #dde3e8;
  --field-border: #b9c4cc; --field-bg: #ffffff;
  --accent: #0b3c49; --accent-ink: #ffffff;
  --warn-bg: #fff4e0; --warn-line: #f0c674; --warn-ink: #6b4600;
  --err-bg: #fdecea; --err-line: #e5a39b; --err-ink: #7a1c12;
  --ok-bg: #e8f5ec; --ok-line: #9ccfae; --ok-ink: #1d5a33;
}
:root[data-theme="dark"] {
  --bg: #0f151a; --surface: #151d24; --surface-2: #0f151a;
  --topbar: #151d24; --topbar-ink: #e8edf1;
  --ink: #e8edf1; --ink-soft: #9fb0bd; --line: #27323c;
  --field-border: #34424e; --field-bg: #0f151a;
  --accent: #e5b84b; --accent-ink: #1a1300;
  --warn-bg: #2b2210; --warn-line: #6b5217; --warn-ink: #f1d58a;
  --err-bg: #2d1512; --err-line: #7a3128; --err-ink: #f3b4aa;
  --ok-bg: #12261a; --ok-line: #2f6b45; --ok-ink: #a8dcba;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151a; --surface: #151d24; --surface-2: #0f151a;
    --topbar: #151d24; --topbar-ink: #e8edf1;
    --ink: #e8edf1; --ink-soft: #9fb0bd; --line: #27323c;
    --field-border: #34424e; --field-bg: #0f151a;
    --accent: #e5b84b; --accent-ink: #1a1300;
    --warn-bg: #2b2210; --warn-line: #6b5217; --warn-ink: #f1d58a;
    --err-bg: #2d1512; --err-line: #7a3128; --err-ink: #f3b4aa;
    --ok-bg: #12261a; --ok-line: #2f6b45; --ok-ink: #a8dcba;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: inherit; margin: 0; }
body { font-family: "IBM Plex Sans", system-ui, sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }
.text-muted { color: var(--ink-soft); font-size: .85em; }

/* ===== Structure Client-First ===== */
.page-wrapper { min-height: 100vh; }
.main-wrapper { padding: 1rem 0 2rem; }
.padding-global { padding: 0 1rem; }
.container-large { max-width: 1320px; margin: 0 auto; display: grid; gap: 1rem; }
.page_title { font-size: 1.4rem; font-weight: 600; }

/* ===== Barre du haut ===== */
.topbar_component { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .8rem 1.25rem; background: var(--topbar); color: var(--topbar-ink); border-bottom: 1px solid var(--line); }
.topbar_brand { margin-right: auto; }
.topbar_title { font-weight: 700; }
.topbar_meta { font-size: .8rem; opacity: .8; }
.topbar_nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar_link { text-decoration: none; padding: .45rem .8rem; border-radius: 6px; font-size: .9rem; }
.topbar_link:hover, .topbar_link.is-active { background: #ffffff22; }
.theme_button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 6px; padding: .4rem .7rem; cursor: pointer; font-size: .85rem; }

/* ===== Composants ===== */
.card_component { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; display: grid; gap: .9rem; }
.login_component { max-width: 380px; margin: 3rem auto 0; }
.alert_component { padding: .8rem 1rem; border-radius: 8px; font-size: .9rem; border: 1px solid; }
.alert_component.is-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.alert_component.is-error   { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-ink); }
.alert_component.is-success { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-ink); }

.form_field { display: flex; flex-direction: column; gap: .3rem; }
.form_label { font-size: .8rem; font-weight: 500; color: var(--ink-soft); }
.form_input { padding: .6rem .75rem; border-radius: 6px; width: 100%; border: 1px solid var(--field-border); background: var(--field-bg); font-variant-numeric: tabular-nums; }
.form_input.is-compact { padding: .4rem .5rem; text-align: right; min-width: 7.5rem; }

.button { border: 0; border-radius: 6px; padding: .75rem 1.2rem; font-weight: 600; cursor: pointer; }
.button.is-primary { background: var(--accent); color: var(--accent-ink); }
.button-row { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

/* Pas d'ascenseur sur grand écran ; défilement horizontal seulement si l'écran est trop étroit */
.table_scroll { overflow: visible; }
@media (max-width: 1100px) { .table_scroll { overflow-x: auto; } }
.data_table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.data_table th { text-align: left; font-weight: 500; color: var(--ink-soft); padding: .45rem .5rem; white-space: nowrap; }
.data_table td { padding: .45rem .5rem; border-top: 1px solid var(--line); white-space: nowrap; }
.data_table .is-num { text-align: right; }

.form_grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; align-items: end; }
.form_actions { justify-content: flex-end; }

.gauge_track { height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.gauge_fill { height: 100%; background: var(--accent); }
.gauge_fill.is-warning { background: #e39a12; }
.gauge_fill.is-error { background: #c0392b; }
.kv_row { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.is-struck { text-decoration: line-through; opacity: .55; }
.data_table tfoot td { border-top: 2px solid var(--line); font-weight: 600; }
.button.is-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.button.is-small { padding: .3rem .6rem; font-size: .8rem; }
.card_title { font-size: 1.05rem; font-weight: 600; }
.form_input.is-invalid { border-color: var(--err-line); background: var(--err-bg); color: var(--err-ink); }

/* Tableau compact */
.data_table.is-dense th, .data_table.is-dense td { padding: .35rem .4rem; }
.data_table.is-dense .form_input.is-compact { min-width: 0; width: 6.5rem; padding: .35rem .45rem; }

/* Zone de dépôt (glisser-déposer) */
.dropzone_component { position: relative; display: grid; gap: .35rem; justify-items: center; text-align: center; padding: 2rem 1rem; border: 2px dashed var(--field-border); border-radius: 8px; background: var(--field-bg); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone_component:hover, .dropzone_component.is-over { border-color: var(--accent); background: var(--surface-2); }
.dropzone_component.is-filled { border-style: solid; border-color: var(--ok-line); background: var(--ok-bg); }
.dropzone_input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone_title { font-weight: 600; }
.dropzone_text { font-size: .85rem; color: var(--ink-soft); }
.dropzone_file { font-size: .9rem; font-weight: 500; }
.dropzone_grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: .9rem; }

/* Logo Bank of Africa en haut à droite de la page */
.page_head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page_logo { height: 32px; width: auto; }
.data_table td.is-over-limit { background: #c62828; color: #ffffff; font-weight: 600; }
.flag_icon { width: 20px; height: 15px; vertical-align: -2px; border-radius: 2px; box-shadow: 0 0 0 1px #00000020; }
/* Boutons ACHAT / VENTE du guichet : bouton sélectionné en vert */
.button.is-selected { background: #2e7d32; color: #ffffff; border-color: #2e7d32; position: relative; z-index: 1; }
/* Pied de tableau collé en bas de l'écran (page Opérations) */
.data_table tfoot.is-sticky td { position: sticky; bottom: 0; background: var(--surface); box-shadow: 0 -1px 0 var(--line); }
/* Menu déroulant des devises du guichet (drapeau, code, intitulé, stock) */
.devise_trigger { display: flex; align-items: center; gap: .45rem; width: 100%; min-width: 13rem; padding: .4rem .6rem; border-radius: 6px; border: 1px solid var(--field-border); background: var(--field-bg); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.devise_trigger.is-placeholder { color: var(--ink-soft); }
.devise_chevron { margin-left: auto; font-size: .8em; color: var(--ink-soft); }
.devise_menu { position: fixed; z-index: 50; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #00000033; padding: .25rem; }
.devise_item { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .45rem .6rem; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.devise_item:hover, .devise_item.is-active { background: var(--surface-2); }
.devise_item:disabled { opacity: .4; cursor: not-allowed; }
.devise_item_stock { margin-left: auto; padding-left: 1rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: .85em; }
/* Groupes de boutons collés du guichet (Opération, Type de client, Groupe) */
.groupes_row { display: flex; flex-wrap: wrap; gap: .9rem 1.5rem; align-items: flex-end; }
.btn_group { display: flex; }
.btn_group .button { flex: 1 1 auto; white-space: nowrap; border-radius: 0; }
.btn_group .button + .button { margin-left: -1px; }
.btn_group .button:first-child { border-radius: 6px 0 0 6px; }
.btn_group .button:last-child { border-radius: 0 6px 6px 0; }
