/* v7 — modèle coûts par machine */
.v7-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.v7-kpi-mkice { border-left: 4px solid #8B5CF6; }
.v7-kpi-mkice .cf-kpi-val { color: #6D28D9; }
.v7-kpi-commercial { border-left: 4px solid #F59E0B; }
.v7-kpi-commercial .cf-kpi-val { color: #B45309; }

.v7-unit-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .v7-unit-grid { grid-template-columns: 1fr; } }
.v7-unit-table td, .v7-unit-table th { white-space: nowrap; }
.v7-row-price td { background: #ECFDF5; font-weight: 700; }
.v7-row-profit td { background: #EFF6FF; border-top: 2px solid #1E3A8A; }
.v7-ben-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; color: #fff; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.v7-ben-cards { display: flex; flex-direction: column; gap: .6rem; }
.v7-ben-card { background: #fff; border: 1px solid #E2E8F0; border-left: 5px solid #64748B; border-radius: 8px; padding: .6rem .9rem; }
.v7-ben-name { font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: #475569; font-weight: 600; }
.v7-ben-val { font-size: 1.15rem; font-weight: 800; color: #0F172A; margin-top: .15rem; }
.v7-ben-pct { font-size: .75rem; color: #64748B; }

.cf-table th.v7-th-commercial { background: #B45309; color: #fff; }
.cf-table th.v7-th-mkice { background: #6D28D9; color: #fff; }
.cf-table th.v7-th-group { background: #475569; color: #fff; }
.cf-table td.v7-td-commercial { background: #FFFBEB; color: #92400E; font-weight: 600; }
.cf-table td.v7-td-mkice { background: #F5F3FF; color: #5B21B6; font-weight: 600; }

/* page config-couts */
.cu-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem 1.2rem; margin: .6rem 0 1rem; }
.cu-params label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: #334155; }
.cu-params .cs-input { width: 100%; max-width: 220px; }
.cu-table td, .cu-table th { vertical-align: middle; }
.cu-table .cs-input { width: 110px; }
.cu-table .cs-input.wide { width: 100%; min-width: 180px; }
.cu-table select.cs-input { width: auto; min-width: 100px; }
.cu-table tr.cu-profit td { background: #EFF6FF; border-top: 2px solid #1E3A8A; font-weight: 700; }
.cu-table tr.cu-price td { background: #ECFDF5; font-weight: 700; }
.cu-table td.dim { color: #94A3B8; }
.cs-btn-del { background: #fff; color: #DC2626; border: 1px solid #FCA5A5; border-radius: 5px; padding: 3px 8px; font-size: .75rem; cursor: pointer; }
.cs-btn-del:hover { background: #FEE2E2; }
.cu-structure { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 8px; padding: .8rem 1.1rem; margin-top: 1rem; }
.cu-structure ul { margin: .4rem 0 0 1.1rem; font-size: .9rem; }
.cu-structure li { margin-bottom: .3rem; }

/* flux-detail : pastilles bucket v7 */
.fd-bucket-vente { background: #059669; }
.fd-bucket-commercial { background: #F59E0B; }
.fd-bucket-mkice { background: #8B5CF6; }
.fd-bucket-group { background: #64748B; }

.v7-row-sub td { color: #475569; font-size: .85rem; background: #F8FAFC; }
.v7-anchor { display: inline-block; margin-left: .4rem; font-size: .68rem; color: #64748B; white-space: nowrap; }

.cu-sched-row td { background: #F8FAFC; }
.cu-sched { border: 1px dashed #93C5FD; border-radius: 8px; padding: .6rem .9rem; background: #EFF6FF; }
.cu-sched-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; font-size: .85rem; }
.cu-sched-table { width: auto; border-collapse: collapse; font-size: .85rem; }
.cu-sched-table th, .cu-sched-table td { padding: .25rem .6rem; text-align: left; }
.cu-sched-table th { font-size: .7rem; text-transform: uppercase; color: #fff; background: var(--navy, #1A2A4A); }
.cu-sched-warn { background: #FEF3C7 !important; border-color: #F59E0B !important; color: #92400E !important; }

.cf-table th.v7-th-fab { background: #B91C1C; color: #fff; }
.cf-table td.v7-td-fab { background: #FEF2F2; color: #991B1B; font-weight: 600; }
.fd-bucket-fabrication { background: #EF4444; }

.cu-customs { display: flex; flex-direction: column; gap: .25rem; align-items: flex-end; font-size: .78rem; }
.cu-customs label { display: flex; gap: .3rem; align-items: center; white-space: nowrap; }

.cu-table tr.cu-us td { background: #F5F3FF; }

.v7-kpi-fund { border-left: 4px solid #0D9488; }
.v7-kpi-fund .cf-kpi-val { color: #0F766E; }
.cf-table th.v7-th-fund { background: #0F766E; color: #fff; }
.cf-table td.v7-td-fund { background: #F0FDFA; color: #0F766E; font-weight: 600; }
.cf-table th.v7-th-fundbal { background: #134E4A; color: #fff; }
.cf-table td.v7-td-fundbal { background: #CCFBF1; color: #134E4A; font-weight: 700; }
.fd-bucket-fonds { background: #0D9488; }
.cu-table tr.cu-fund td { background: #F0FDFA; }

.cu-scope { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px; padding: .5rem .9rem; margin: .4rem 0 .8rem; font-size: .85rem; }
.cu-ov-tag { display: inline-block; margin-left: .35rem; padding: 1px 6px; border-radius: 8px; font-size: .65rem; background: #E2E8F0; color: #475569; vertical-align: middle; white-space: nowrap; }
.cu-ov-tag.is-ov { background: #DBEAFE; color: #1E40AF; font-weight: 600; }

.cu-sched-main td, .cu-sched-main th { vertical-align: middle; }
.cu-sched-main tr.cu-sched-line td { background: #F8FAFC; font-size: .85rem; }

.ui-mode-badge { margin: 0 .8rem; padding: .35rem .6rem; border-radius: 6px; font-size: .68rem; font-weight: 600; text-align: center; }
.ui-mode-badge.is-dev { background: rgba(16,185,129,.15); color: #6EE7B7; border: 1px solid rgba(16,185,129,.4); }
.ui-mode-badge.is-prod { background: rgba(239,68,68,.15); color: #FCA5A5; border: 1px solid rgba(239,68,68,.4); }

/* Production (BP_MODE=prod) : aucune trace de paramétrage */
body.bp-readonly .cs-input, body.bp-readonly select.cs-input, body.bp-readonly input.cs-input {
  border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important;
  pointer-events: none; -webkit-appearance: none; appearance: none; color: inherit; font: inherit; width: auto;
}
body.bp-readonly select.cs-input { background-image: none !important; }
body.bp-readonly input[type="checkbox"] { pointer-events: none; }
body.bp-readonly .cs-btn-del, body.bp-readonly .cs-btn-add, body.bp-readonly .cs-btn-reset,
body.bp-readonly .cs-save-status, body.bp-readonly .cu-ov-tag, body.bp-readonly .cs-actions { display: none !important; }
body.bp-readonly .cs-edit-table input { text-align: right; }
body.bp-readonly .cs-input:disabled, body.bp-readonly input:disabled, body.bp-readonly select:disabled { opacity: 1 !important; color: inherit; }
body.bp-readonly .cu-customs label { display: none; }
body.bp-readonly .cu-customs small { text-align: right; }

/* Bandeau flottant enregistrer / annuler */
.bp-savebar { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: .8rem;
  background: #0F172A; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(2,6,23,.35); font-size: .9rem; }
.bp-savebar-text { font-weight: 600; }
.bp-savebar button { border-radius: 8px; padding: .45rem .9rem; font-size: .85rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.bp-savebar-save { background: #10B981; color: #fff; }
.bp-savebar-save:hover { background: #059669; }
.bp-savebar-cancel { background: transparent; color: #FCA5A5; border-color: rgba(252,165,165,.5) !important; }
.bp-savebar-cancel:hover { background: rgba(239,68,68,.15); }
.bp-savebar button:disabled { opacity: .5; cursor: wait; }
@media (max-width: 700px) { .bp-savebar { left: 1rem; right: 1rem; transform: none; flex-wrap: wrap; } }

/* Bloc Développement collé au-dessus des Préférences, en bas de la colonne */
.nav-section-dev { margin-top: auto; }
.nav-section-dev + .nav-section-user { margin-top: 0; }
.nav-section-dev[style*="display: none"] + .nav-section-user { margin-top: auto; }

.cu-sched-main tr.cu-lt td { background: #FFF7ED; }

.nav-section-prefs { padding: 4px 0 10px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 6px; }
.nav-section-dev { margin-top: auto; padding: 8px 0 1rem; border-top: 1px solid rgba(255,255,255,.08); }

/* Utilisateur connecté */
.nav-section-user { padding: 8px 0 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.ui-user { margin: 0 .8rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ui-user-name { font-weight: 700; font-size: .85rem; color: #fff; }
.ui-user-name { flex: 1; }
.ui-user-logout { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #CBD5E1; border-radius: 6px; padding: 2px 8px; font-size: .68rem; cursor: pointer; }
.ui-user-logout:hover { background: rgba(255,255,255,.08); }
/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0F172A 0%, #1A4068 60%, #1E3A8A 100%); padding: 1rem; }
.login-card { background: #fff; border-radius: 14px; padding: 2rem 2.2rem; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(2,6,23,.4); }
.login-card h1 { font-size: 1.3rem; margin: 0 0 .2rem; color: #0F172A; }
.login-card .sub { color: #64748B; font-size: .85rem; margin-bottom: 1.2rem; }
.login-card label { display: block; font-size: .8rem; font-weight: 600; color: #334155; margin: .8rem 0 .3rem; }
.login-card input { width: 100%; padding: .6rem .7rem; border: 1px solid #CBD5E1; border-radius: 8px; font-size: 1rem; }
.login-card button { width: 100%; margin-top: 1.2rem; padding: .7rem; background: #1E3A8A; color: #fff; border: 0; border-radius: 8px; font-weight: 700; font-size: 1rem; cursor: pointer; }
.login-card button:hover { background: #1A2A4A; }
.login-error { margin-top: .8rem; color: #B91C1C; font-size: .85rem; }
.login-lang { display: flex; gap: .4rem; justify-content: flex-end; }
.login-lang button { width: auto; margin: 0; padding: .2rem .5rem; font-size: .7rem; background: #E2E8F0; color: #334155; }
.login-lang button.active { background: #1E3A8A; color: #fff; }
/* Journal */
.jn-filters { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; margin: .6rem 0 1rem; }
.jn-filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; font-weight: 600; color: #334155; }
.jn-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .72rem; font-weight: 600; background: #E2E8F0; color: #334155; }
.jn-pill.page { background: #DBEAFE; color: #1E40AF; }
.jn-pill.login { background: #D1FAE5; color: #065F46; }
.jn-pill.login_failed { background: #FEE2E2; color: #991B1B; }
.jn-pill.config_write { background: #FEF3C7; color: #92400E; }
.jn-pill.export_xlsx, .jn-pill.db_export, .jn-pill.db_import { background: #EDE9FE; color: #5B21B6; }

.ui-sim-select { width: 100%; background: #0B1220; color: #E2E8F0; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: .3rem .4rem; font-size: .75rem; }

.cf-table th.v7-th-logi { background: #0369A1; color: #fff; }
.cf-table td.v7-td-logi { background: #F0F9FF; color: #075985; font-weight: 600; }
.fd-bucket-logistics { background: #0EA5E9; }

.fd-bucket-client { background: #059669; }

/* Modal mois : titre de bloc toujours lisible (fond coloré, texte blanc) */
.cf-modal .cf-bucket-tag { color: #fff; background: #334155; }
.cf-modal .cf-bucket-solde .cf-bucket-tag { background: #059669; }

/* Scénario personnel C : saisies actives même en lecture seule (zones scénario uniquement) */
body.bp-readonly main.sc-own .cs-edit-table .cs-input, body.bp-readonly main.sc-own .cu-sched-main .cs-input,
body.bp-readonly main.sc-own .cu-params:not(.sc-global) .cs-input, body.bp-readonly main.sc-own .hr-table .cs-input {
  pointer-events: auto; border: 1px solid #CBD5E1 !important; background: #fff !important; padding: 4px 6px !important; width: auto; -webkit-appearance: auto; appearance: auto; opacity: 1;
}
body.bp-readonly main.sc-own .cu-scope, body.bp-readonly main.sc-own .cs-btn-del, body.bp-readonly main.sc-own .cs-btn-reset, body.bp-readonly main.sc-own .cs-save-status { display: inline-flex !important; }
body.bp-readonly main.sc-own .cu-scope { display: flex !important; }
.sc-c-scope { background: #ECFDF5; border-color: #A7F3D0; }
