/* ─── Theme ───────────────────────────────────────────── */
:root {
  --brand:        #0b5ea8;   /* Atlantic blue */
  --brand-dark:   #084a86;
  --brand-darker: #063a69;
  --brand-soft:   #e6f0fa;
  --bs-primary: #0b5ea8;
  --bs-primary-rgb: 11,94,168;
  --bs-link-color: #0b5ea8;
  --bs-link-color-rgb: 11,94,168;
  --bs-link-hover-color: #084a86;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #eef1f5; }
main.container-fluid { min-height: calc(100vh - 56px); }

.btn { border-radius: 6px; transition: all .15s ease; }
.btn-sm { border-radius: 5px; }
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-darker); --bs-btn-active-border-color: var(--brand-darker);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
}
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }

/* ─── Navbar ─────────────────────────────────────────── */
.app-navbar { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); min-height: 54px; }
.app-navbar .navbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.8rem; }
.brand-txt { font-size: 1.12rem; font-weight: 800; color: #1f2430; letter-spacing: .2px; }
.app-navbar .nav-link { color: #3a4047; font-size: .9rem; font-weight: 500; border-radius: 8px; padding: .4rem .8rem; }
.app-navbar .nav-link:hover { background: #f3f4f6; color: #111; }
.app-navbar .nav-link.active { background: var(--brand); color: #fff; }
.app-navbar .dropdown-menu { border: none; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.13); min-width: 210px; }
.app-navbar .dropdown-item { font-size: .875rem; padding: .5rem 1rem; }
.app-navbar .dropdown-item:hover { background: var(--brand-soft); }
.app-navbar .dropdown-item.active, .app-navbar .dropdown-item:active { background: var(--brand); color: #fff; }

/* ─── Cards / tables / forms ─────────────────────────── */
.card { border-radius: 10px; }
.card-header { padding: .7rem 1.1rem; border-bottom: 1px solid rgba(0,0,0,.06); font-size: .875rem; }
.card-header.bg-white { background: #fafbfd !important; }

.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; color: #495057; background: #f8f9fa; white-space: nowrap; }
.table td { font-size: .875rem; vertical-align: middle; }
.table > thead > tr > th { border-bottom: 2px solid #e9ecef; }
.table-hover tbody tr:hover { background: rgba(11,94,168,.05); }
tr.row-link { cursor: pointer; }

.form-label { font-size: .875rem; margin-bottom: .25rem; }
.form-control:focus, .form-select:focus { border-color: #7fb0dd; box-shadow: 0 0 0 .2rem rgba(11,94,168,.15); }

.kpi-card { border-left: 4px solid var(--brand) !important; color: inherit; }
.kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #6c757d; }
.kpi-value { font-size: 1.4rem; font-weight: 700; margin-top: .15rem; color: #212529; }
.kpi-sub { font-size: .78rem; color: #8a9098; font-weight: 400; }

/* ─── Account type badge (AccountType.Abbrev) ────────── */
.type-badge {
  display: inline-block; min-width: 1.45em; padding: 0 .3em; margin-right: .4em;
  font-size: .72em; font-weight: 700; line-height: 1.5; text-align: center; vertical-align: .08em;
  border-radius: 4px; background: #e9ecef; color: #495057;
}
.type-badge[data-type="1"] { background: #fde8d7; color: #9a4a0b; }  /* Fournisseur */
.type-badge[data-type="2"] { background: #dbe9f8; color: #0b5ea8; }  /* Branch */
.type-badge[data-type="3"] { background: #d9f2e3; color: #177245; }  /* Client */
.type-badge[data-type="6"] { background: #ece3f7; color: #6a3fa0; }  /* Depot */

/* ─── Lines grid ─────────────────────────────────────── */
#linesTable td, #linesTable th { padding: .35rem .4rem; }
#linesTable input, #linesTable select { font-size: .82rem; }
#linesTable tbody tr:hover { background: rgba(11,94,168,.03); }
.s2-invalid .select2-selection { border-color: var(--bs-danger) !important; }

.totals-card .totals-row { display: flex; justify-content: space-between; align-items: center; padding: .28rem 0; font-size: .9rem; }
.totals-card .totals-row.net-total { border-top: 2px solid #e9ecef; margin-top: .4rem; padding-top: .6rem; font-weight: 700; }
.totals-card .totals-row.net-total span:last-child { font-size: 1.15rem; color: var(--brand); }
.totals-card .totals-row.net-total span.text-danger { color: var(--bs-danger) !important; }

/* Sticky action bar — Save always reachable on long forms */
.app-actions {
  position: sticky; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid #e6e9ef; box-shadow: 0 -4px 14px rgba(15,23,42,.06);
  padding: .65rem .9rem; border-radius: 10px;
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
}

/* ─── Select2 ────────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-dropdown { border-color: #dbe1ea; border-radius: 10px; box-shadow: 0 8px 28px rgba(15,23,42,.14); overflow: hidden; }
.select2-container--bootstrap-5 .select2-results__option { font-size: .86rem; }
.select2-container--bootstrap-5 .select2-results__option--highlighted { background: var(--brand-soft) !important; color: #0f2d4a !important; }
.select2-container--bootstrap-5 .select2-results__option--selected { background: #cfe2f5 !important; color: var(--brand-darker) !important; }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Login ──────────────────────────────────────────── */
.login-wrap { min-height: calc(100vh - 3rem); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; border-radius: 14px; }

/* ─── Print ──────────────────────────────────────────── */
@media print {
  body { background: #fff !important; font-size: 11pt; }
  main.container-fluid { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .table { font-size: 10pt; }
  a[href]:after { content: none !important; }
  tr.src-detail[hidden], tr.cli-detail[hidden] { display: table-row !important; }   /* PO group: print every invoice's items */
  .src-lines input.form-control { border: 0; background: transparent !important; padding: 0; }
}

/* ── Excel-like line grids (assets/js/xlgrid.js) ─────────────────────────── */
.grid-wrap { max-height: 62vh; overflow: auto; }
.xl-grid { border-collapse: separate; border-spacing: 0; }
.xl-grid thead th { position: sticky; top: 0; z-index: 3; background: #eef2f7; border-bottom: 1px solid #cfd8e3; font-size: .74rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.xl-grid tfoot td { position: sticky; bottom: 0; z-index: 2; background: #eef2f7; border-top: 1px solid #cfd8e3; font-weight: 600; }
.xl-grid tbody td { border-right: 1px solid #e6ebf1; border-bottom: 1px solid #e6ebf1; padding: 0 .45rem !important; vertical-align: middle; background: #fff; font-size: .82rem; }
.xl-grid tbody td[data-xl] { padding: 0 !important; }
.xl-grid tbody td.l-no { background: #f5f7fa; color: #6b7280; font-size: .75rem; cursor: pointer; user-select: none; padding: 0 .3rem !important; text-align: center; }
.xl-grid tbody td.l-no:hover { background: #e3ecf7; }
.xl-grid tbody td input.form-control, .xl-grid tbody td select.form-select { border: 0; border-radius: 0; box-shadow: none; background-color: transparent; height: 30px; padding-top: 0; padding-bottom: 0; font-size: .82rem; }
.xl-grid tbody td input.form-control { padding-left: .45rem; padding-right: .45rem; }
.xl-grid tbody td input[readonly] { color: #6b7280; }
.xl-grid tbody td .select2-container--bootstrap-5 .select2-selection { border: 0; border-radius: 0; box-shadow: none; background: transparent; min-height: 30px; }
.xl-grid tbody td.cell-active { outline: 2px solid #1a73e8; outline-offset: -2px; position: relative; z-index: 1; }
.xl-grid tbody td.cell-active input.form-control, .xl-grid tbody td.cell-active select.form-select, .xl-grid tbody td.cell-active .select2-selection { background-color: #fff !important; }
.xl-grid tbody tr.row-active td.l-no { background: #d6e4f5; color: #0b5ea8; font-weight: 600; }
.xl-grid tbody tr.row-selected td { background: #e8f0fe; }
.xl-grid tbody tr.row-selected td.l-no { background: #1a73e8; color: #fff; }
.xl-grid tbody td.paste-miss { box-shadow: inset 0 0 0 2px #f59e0b; background: #fff8e6; }
.xl-grid tbody td.is-invalid-cell { box-shadow: inset 0 0 0 2px var(--bs-danger); }
.xl-grid tbody td:not(:hover):not(.cell-active) .select2-selection__clear { visibility: hidden; }
.xl-grid .l-del { border: 0; }
.xl-grid [data-xl-act="selall"] { cursor: pointer; }
[data-xl-tools][hidden] { display: none !important; }
