/* Lascof Energy ERP — palette du site lascof : bleu #0a5cd6 / marine #06172f / soleil #ffb400→#ff7a00 */
:root {
  --imperial: #0b2447;   /* marine */
  --mist: #eaf2ff;       /* bleu très clair */
  --convol: #f3f7fc;
  --sun: #ffb400; --sun-2: #ff7a00;
  --grad-sun: linear-gradient(135deg, #ffcf40 0%, #ff8a00 100%);
  --grad-dark: linear-gradient(160deg, #06172f 0%, #0b2f66 100%);
  --bg: #f3f7fc;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #0b1b33;
  --muted: #566883;
  --border: #e1e9f4;
  --primary: #0a5cd6;
  --primary-hover: #0848aa;
  --on-primary: #ffffff;
  --primary-soft: rgba(10, 92, 214, .10);
  --sidebar: #0b2447;
  --sidebar-text: #f3f7fc;
  --sidebar-muted: rgba(234, 242, 255, .62);
  --ok: #10b981; --ok-soft: rgba(16, 185, 129, .13);
  --warn: #b7791f; --warn-soft: rgba(255, 180, 0, .18);
  --danger: #dc2f2f; --danger-soft: rgba(220, 47, 47, .12);
  --info-soft: rgba(10, 92, 214, .10);
  --shadow: 0 1px 2px rgba(6, 23, 47, .06), 0 6px 20px rgba(6, 23, 47, .06);
  --radius: 12px;
  --header-h: 62px;
  --sidebar-w: 262px;
}
[data-theme="dark"] {
  --bg: #06172f;
  --surface: #0b2447;
  --surface-2: #0e2d57;
  --text: #e8f0fb;
  --muted: #93a7c4;
  --border: #1b3a6b;
  --primary: #5b9bff;
  --primary-hover: #86b6ff;
  --on-primary: #06172f;
  --primary-soft: rgba(91, 155, 255, .15);
  --sidebar: #04101f;
  --ok: #34d399; --ok-soft: rgba(52, 211, 153, .14);
  --warn: #ffcf40; --warn-soft: rgba(255, 207, 64, .15);
  --danger: #ff7a6b; --danger-soft: rgba(255, 122, 107, .14);
  --info-soft: rgba(91, 155, 255, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Plus Jakarta Sans", "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
html[dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", "Helvetica Neue", Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.icon { flex: none; vertical-align: middle; }
html[dir="rtl"] .flip { transform: scaleX(-1); }
.muted { color: var(--muted); }
.mono, .num { font-variant-numeric: tabular-nums; }
.right { text-align: end; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar); color: var(--sidebar-text);
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; display: flex; flex-direction: column;
  transition: transform .2s ease, width .2s ease; overflow-y: auto; overflow-x: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { height: 38px; width: auto; }
.brand b { display: block; font-size: 1.02rem; letter-spacing: .06em; line-height: 1.1; }
.brand small { color: var(--sidebar-muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.nav { padding: 12px 12px 24px; flex: 1; }
.nav-title { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--sidebar-muted); padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; color: var(--sidebar-text);
  font-size: .93rem; margin-bottom: 2px; opacity: .88;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; opacity: 1; }
.nav a.active { background: rgba(245,242,243,.16); opacity: 1; font-weight: 600; box-shadow: inset 3px 0 0 var(--convol); }
html[dir="rtl"] .nav a.active { box-shadow: inset -3px 0 0 var(--convol); }
.main { flex: 1; margin-inline-start: var(--sidebar-w); transition: margin .2s ease; min-width: 0; display: flex; flex-direction: column; }
.header {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 40;
}
.header .title { font-size: 1.1rem; font-weight: 650; }
.spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.burger { display: none; }
.sb-toggle { display: inline-flex; }
.lbl { white-space: nowrap; }
/* ---------- Sidebar collapse (desktop) ---------- */
html.sb-collapsed { --sidebar-w: 72px; }
html.sb-collapsed .brand { justify-content: center; padding: 18px 8px; }
html.sb-collapsed .brand-text, html.sb-collapsed .lbl { display: none; }
html.sb-collapsed .brand img { height: 34px; }
html.sb-collapsed .nav { padding: 10px 10px 24px; }
html.sb-collapsed .nav a { justify-content: center; padding: 11px 0; gap: 0; }
html.sb-collapsed .nav-title { font-size: 0; height: 1px; margin: 12px 10px; padding: 0; background: rgba(255,255,255,.14); }
html.sb-collapsed .nav a.active { box-shadow: none; }
.dropdown { position: relative; }
.dd-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 60;
}
.dropdown.open .dd-menu { display: block; }
.dd-menu a, .dd-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--text);
  background: none; border: 0; font: inherit; cursor: pointer; text-align: start;
}
.dd-menu a:hover, .dd-menu button:hover { background: var(--primary-soft); text-decoration: none; }
.dd-menu .sel { font-weight: 650; color: var(--primary); }
.dd-sep { height: 1px; background: var(--border); margin: 6px 0; }
.lang-btn { width: auto; padding: 0 10px; gap: 6px; font-weight: 600; font-size: .85rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; border: 0; cursor: pointer;
}
.user-head { padding: 10px 12px 8px; }
.user-head b { display: block; } .user-head small { color: var(--muted); }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.backdrop { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 1.45rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h2 { font-size: 1.02rem; }
.card-b { padding: 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; font-size: .92rem; line-height: 1.2;
}
.btn:hover { background: var(--primary-soft); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .84rem; border-radius: 8px; }
.btn-icon { padding: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-soft); }
.alert-err { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-soft); }
.kpi { padding: 18px 20px; display: flex; gap: 14px; align-items: center; }
.kpi .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.kpi .v { font-size: 1.35rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .84rem; }
.kpi.warn .ico { background: var(--warn-soft); color: var(--warn); }
.kpi.danger .ico { background: var(--danger-soft); color: var(--danger); }
.kpi.ok .ico { background: var(--ok-soft); color: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--primary-soft); }
.table tr:last-child td { border-bottom: 0; }
.table .right, .table th.right { text-align: end; }
.table td.actions-cell { white-space: nowrap; text-align: end; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .icon { opacity: .4; margin-bottom: 8px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 650; white-space: nowrap; }
.badge-draft, .badge-cancelled, .badge-expired { background: rgba(120,126,150,.16); color: var(--muted); }
.badge-sent, .badge-confirmed { background: var(--info-soft); color: var(--primary); }
.badge-partial, .badge-overdue { background: var(--warn-soft); color: var(--warn); }
.badge-paid, .badge-accepted, .badge-delivered, .badge-received { background: var(--ok-soft); color: var(--ok); }
.badge-rejected, .badge-late { background: var(--danger-soft); color: var(--danger); }
.badge-admin { background: var(--primary); color: var(--on-primary); } .badge-manager { background: var(--info-soft); color: var(--primary); } .badge-user { background: rgba(120,126,150,.16); color: var(--muted); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-12 { grid-column: span 12; } .col-5 { grid-column: span 5; } .col-7 { grid-column: span 7; } .col-9 { grid-column: span 9; } .col-10 { grid-column: span 10; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.field label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.field .err { color: var(--danger); font-size: .8rem; margin-top: 4px; }
/* ---- Uniform controls: one height, border, radius, font and focus ring everywhere ---- */
:root {
  --ctl-h: 42px;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666b82' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
html[data-theme="dark"] { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398a0c6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
input[type=tel], input[type=url], input[type=time], input[type=file], select, textarea {
  display: block; width: 100%; height: var(--ctl-h); padding: 0 12px; margin: 0;
  border: 1px solid var(--border); border-radius: 10px; background-color: var(--surface); color: var(--text);
  font: inherit; font-size: .93rem; line-height: 1.3; box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select {
  padding-inline-end: 36px; cursor: pointer; text-overflow: ellipsis;
  background-image: var(--chev); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
}
html[dir="rtl"] select { background-position: left 12px center; }
input[type=date], input[type=time] { display: flex; align-items: center; min-width: 0; }
input[type=date]::-webkit-date-and-time-value { text-align: start; margin: 0; min-height: 1.3em; }
input[type=date]::-webkit-datetime-edit, input[type=time]::-webkit-datetime-edit { padding: 0; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; margin: 0; }
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type=file] { padding: 0 8px 0 0; line-height: calc(var(--ctl-h) - 2px); }
input[type=file]::file-selector-button { height: calc(var(--ctl-h) - 2px); margin: 0 10px 0 0; padding: 0 14px; border: 0; border-inline-end: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; }
::placeholder { color: var(--muted); opacity: .75; }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background-color: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.btn { min-height: var(--ctl-h); justify-content: center; }
.btn-sm { min-height: 34px; }
.btn-icon { min-width: var(--ctl-h); padding: 0 10px; }
.btn-sm.btn-icon { min-width: 34px; padding: 0 8px; }
.field { min-width: 0; display: flex; flex-direction: column; }
.field > label { flex: 1 0 auto; display: flex; align-items: flex-end; }
.field > label .check, .field > .check { margin-bottom: 0; }
.field label { line-height: 1.2; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 120px; flex: 1; } .filters .field.grow { flex: 2; min-width: 200px; } .filters .btn { flex: none; }
.search-box { position: relative; }
.search-box .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-inline-start: 38px; }
.pagination { display: flex; gap: 6px; padding: 14px 20px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); }
.pagination a, .pagination span.pg { min-width: 36px; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { background: var(--primary-soft); text-decoration: none; }
.pagination .pg.current { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pagination .pg.disabled { opacity: .4; }
.pagination .info { margin-inline-start: auto; color: var(--muted); font-size: .85rem; }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 550; display: inline-flex; gap: 8px; align-items: center; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--primary); }

/* Document editor */
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: start; padding: 8px 6px; }
.lines-table td { padding: 5px 4px; vertical-align: top; } .lines-table select, .lines-table input { padding-inline: 8px; } .lines-table select { padding-inline-end: 28px; background-position: right 8px center; } html[dir="rtl"] .lines-table select { background-position: left 8px center; }
.lines-table textarea { height: var(--ctl-h); min-height: var(--ctl-h); padding: 10px 12px; resize: none; }
.lines-table input[type=number] { text-align: end; }
.lines-table .ln-total { padding-top: 12px; font-weight: 650; text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals-box { margin-inline-start: auto; width: 360px; max-width: 100%; }
.totals-box .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.totals-box .grand { background: var(--primary); color: var(--on-primary); border-radius: 10px; padding: 12px 14px; margin-top: 10px; font-weight: 700; font-size: 1.1rem; border: 0; }
.info-list { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; }
.info-list dt { color: var(--muted); } .info-list dd { margin: 0; font-weight: 500; }
.doc-chain { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .82rem; font-weight: 600; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bar { width: 42%; max-width: 20px; border-radius: 5px 5px 0 0; min-height: 2px; background: var(--primary); }
.bar.paid { background: var(--ok); opacity: .85; }
.bar-label { font-size: .72rem; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); margin-inline-start: auto; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; background: var(--primary); }
.legend i.paid { background: var(--ok); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.tool-card .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.logo-preview { background: repeating-conic-gradient(#e9e5ea 0 25%, #fff 0 50%) 0 0 / 16px 16px; border-radius: 10px; padding: 14px; display: inline-block; border: 1px solid var(--border); }
.logo-preview.dark { background: var(--sidebar); }
.logo-preview img { height: 70px; display: block; }
.aging { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.aging div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.aging b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { background: var(--imperial); color: var(--convol); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px; text-align: center; gap: 22px; }
.auth-side img { height: 120px; }
.auth-side h1 { font-size: 2rem; letter-spacing: .1em; }
.auth-side p { max-width: 380px; opacity: .8; margin: 0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px; position: relative; }
.auth-box { width: 100%; max-width: 400px; }
.auth-top { position: absolute; top: 18px; inset-inline-end: 18px; display: flex; gap: 8px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .sb-toggle { display: none; }
  html.sb-collapsed { --sidebar-w: 262px; }
  html.sb-collapsed .brand { justify-content: flex-start; padding: 18px 20px; }
  html.sb-collapsed .brand-text, html.sb-collapsed .lbl { display: revert; }
  html.sb-collapsed .nav a { justify-content: flex-start; padding: 9px 12px; gap: 12px; }
  html.sb-collapsed .nav-title { font-size: .68rem; height: auto; margin: 0; padding: 16px 12px 6px; background: none; }
  .sidebar { transform: translateX(-100%); } html[dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45; }
  .main { margin-inline-start: 0; } .burger { display: inline-flex; }
  .content { padding: 16px; } .header { padding: 0 14px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .col-10, .col-9, .col-8, .col-7, .col-6, .col-5, .col-4, .col-3, .col-2 { grid-column: span 12; }
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .aging { grid-template-columns: repeat(2, 1fr); }
  .lines-table thead { display: none; }
  .lines-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
  .lines-table td:nth-child(2) { grid-column: span 2; }
}
@media print { .sidebar, .header, .actions, .no-print { display: none !important; } .main { margin: 0; } .card { box-shadow: none; } }

/* Crédit développeur */
.credit { text-align: center; font-size: .8rem; color: var(--muted, #6b7280); margin-top: 28px; }
.credit a { color: var(--primary); font-weight: 600; text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.auth-main .credit { position: absolute; bottom: 18px; inset-inline: 0; margin: 0; }

/* Groupes de menu (Vente / Achats) */
.nav-parent {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 9px; margin-bottom: 2px;
  background: none; border: 0; color: var(--sidebar-text); font: inherit; font-size: .93rem; cursor: pointer; opacity: .88; text-align: start;
}
.nav-parent:hover { background: rgba(255,255,255,.08); opacity: 1; }
.nav-parent .lbl { flex: 1; }
.nav-parent .chev { display: inline-flex; transition: transform .2s; opacity: .8; }
.nav-group.open > .nav-parent .chev { transform: rotate(180deg); }
.nav-group.open > .nav-parent, .nav-parent.active-parent { opacity: 1; font-weight: 600; }
.nav-sub { display: none; margin: 0 0 4px; padding-inline-start: 22px; }
.nav-group.open > .nav-sub { display: block; }
.nav-sub a { padding: 7px 12px; font-size: .88rem; margin-bottom: 1px; border-inline-start: 1px solid rgba(255,255,255,.18); border-radius: 0 9px 9px 0; }
html[dir="rtl"] .nav-sub a { border-radius: 9px 0 0 9px; }
.nav-sub a.active { box-shadow: none; background: rgba(245,242,243,.16); }
html.sb-collapsed .nav-parent { justify-content: center; padding: 11px 0; gap: 0; }
html.sb-collapsed .nav-parent .chev, html.sb-collapsed .nav-sub { display: none !important; }
@media (max-width: 900px) {
  html.sb-collapsed .nav-parent { justify-content: flex-start; padding: 9px 12px; gap: 12px; }
  html.sb-collapsed .nav-parent .chev { display: inline-flex !important; }
  html.sb-collapsed .nav-group.open > .nav-sub { display: block !important; }
}

/* Actions rapides */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.quick { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border, rgba(0,0,0,.08)); border-radius: 12px; color: inherit; text-decoration: none; transition: .15s; }
.quick:hover { border-color: var(--primary); box-shadow: 0 4px 14px var(--primary-soft); text-decoration: none; }
.quick .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.quick small { display: block; color: var(--muted, #6b7280); font-size: .78rem; }

.badge-grouped { background: var(--primary-soft); color: var(--primary); font-size: .68rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; margin-inline-start: 6px; }
.tabs .count { background: var(--primary-soft); border-radius: 99px; padding: 0 8px; font-size: .75rem; }
@media print { .sidebar, .header, .filters, .actions, .backdrop { display: none !important; } .main { margin: 0 !important; } }

/* Modes de calcul */
.mode-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.mode-btn { border: 1px solid var(--border, #d9dbe3); background: transparent; color: inherit; border-radius: 99px; padding: 6px 14px; font: inherit; font-size: .85rem; cursor: pointer; }
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary, #fff); }
.qty-cell .dims { display: none; gap: 4px; margin-bottom: 4px; }
.qty-cell .dims input { min-width: 0; width: 100%; padding-inline: 6px; }
.qty-cell { min-width: 90px; }
#lines-editor[data-mode="m2"] .qty-cell .dims { display: flex; }
#lines-editor[data-mode="m2"] .qty-cell .dims input[data-f=dim1], #lines-editor[data-mode="m2"] .qty-cell .dims input[data-f=dim2] { display: block; }
#lines-editor[data-mode="ml"] .qty-cell .dims { display: flex; }
#lines-editor[data-mode="ml"] .qty-cell .dims input[data-f=dim2] { display: none; }
#lines-editor[data-mode="m2"] .qty-cell, #lines-editor[data-mode="ml"] .qty-cell { min-width: 190px; }

/* =====================================================================
   Style « Facturago » (forme : arrondis, ombres, tableaux) en gardant le bleu Lascof
   ===================================================================== */
:root { --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px -1px rgba(15, 23, 42, .06); --radius: 16px; }
.card { border-radius: 24px; border-color: transparent; }
[data-theme="dark"] .card { border-color: var(--border); }
.card-h h2 { font-size: 1.02rem; font-weight: 700; }
.kpi { border-radius: 24px; padding: 20px; }
.kpi .ico { width: 48px; height: 48px; border-radius: 16px; }
.kpi .v { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.btn { border-radius: 12px; font-weight: 600; }
.btn-primary { box-shadow: 0 4px 12px rgba(52, 61, 138, .25); }
.btn-primary:hover { background: var(--primary-hover); }
input, select, textarea { border-radius: 12px; }
.table thead th { background: var(--surface-2); text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; color: var(--muted); }
.table tbody tr:hover { background: var(--surface-2); }
.header { background: var(--surface); border-bottom: 1px solid var(--border); }
.nav a, .nav-parent { border-radius: 8px; font-weight: 500; opacity: 1; }
.nav a:hover, .nav-parent:hover { background: rgba(255, 255, 255, .12); }
.nav a.active { background: rgba(245, 242, 243, .18); box-shadow: none; font-weight: 600; }
html[dir="rtl"] .nav a.active { box-shadow: none; }
.mode-btn.active { box-shadow: 0 2px 8px rgba(10, 92, 214, .3); }

/* Touches « Summer mist » */
.kpi .ico, .quick .ico { background: var(--mist); color: var(--primary); }
[data-theme="dark"] .kpi .ico, [data-theme="dark"] .quick .ico { background: rgba(91, 155, 255, .16); color: var(--mist); }
.nav a.active { background: rgba(255, 255, 255, .10); }
.nav-sub a.active { background: rgba(255, 255, 255, .10); }
.brand b { color: #fff; } .brand small { color: var(--sun); }
.auth-side { background: var(--grad-dark); }
.auth-side p { color: #dbe7fb; opacity: .9; }
.badge-grouped, .tabs .count { background: var(--mist); color: var(--primary); }
.avatar { background: var(--primary); color: var(--on-primary); }

.badge-applied { background: var(--ok-soft); color: var(--ok); }

/* Accents « soleil » (comme les boutons du site) et barre latérale marine */
.sidebar { background: var(--grad-dark); }
[data-theme="dark"] .sidebar { background: #04101f; }
.nav a.active, .nav-sub a.active { background: rgba(255, 255, 255, .10); box-shadow: inset 3px 0 0 var(--sun); }
html[dir="rtl"] .nav a.active, html[dir="rtl"] .nav-sub a.active { box-shadow: inset -3px 0 0 var(--sun); }
.btn-primary { background: var(--grad-sun); border-color: transparent; color: #1a1200; box-shadow: 0 6px 16px rgba(255, 138, 0, .30); }
.btn-primary:hover { background: linear-gradient(135deg, #ffd95e 0%, #ff9a1f 100%); color: #1a1200; filter: none; }
.btn-primary .icon { color: #1a1200; }
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.avatar { background: var(--grad-sun); color: #1a1200; }
.tabs a.active { border-color: var(--sun-2); }
.badge-grouped, .tabs .count { background: var(--primary-soft); color: var(--primary); }
.field input:focus, .field select:focus, .field textarea:focus, input:focus, select:focus, textarea:focus { outline-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 92, 214, .22); }

/* Mobile : aucune page ne doit dépasser la largeur de l'écran */
.card, .g-main > *, .g2 > *, .g3 > *, .g4 > * { min-width: 0; }
.card-b, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 900px) {
  .card-h { flex-wrap: wrap; gap: 6px; }
  .main { overflow-x: hidden; }
}
