/* MUFUTA BUSINESS AMBASSADORS — identité or, anthracite, ivoire */
:root {
  --gold: #D9A23C;
  --gold-deep: #B57E22;
  --bronze: #9A5B1E;
  --gold-soft: #F6E7C6;
  --anthracite: #242424;
  --anthracite-2: #34312D;
  --ink: #2B2926;
  --muted: #6E675C;
  --ivory: #FAF6EC;
  --ivory-2: #F3ECDC;
  --paper: #FFFDF8;
  --line: #E6DCC6;
  --ok: #2F7D4F;   --ok-bg: #E4F2E8;
  --warn: #9A6200; --warn-bg: #FBEFD5;
  --bad: #A93A2F;  --bad-bg: #F8E3E0;
  --info: #2D5E8A; --info-bg: #E2ECF5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36,36,36,.06), 0 6px 18px rgba(36,36,36,.06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--ivory); font-size: 15px; line-height: 1.5; }
a { color: var(--bronze); }
a:hover { color: var(--anthracite); }
h1, h2, h3 { color: var(--anthracite); line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 252px; flex: none; background: var(--paper); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { padding: 22px 30px 12px; text-align: center; border-bottom: 1px solid var(--line); }
.sidebar .brand img { width: 150px; height: auto; display: block; margin: 0 auto; }
.role-pill { display: inline-block; margin-top: 8px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--bronze); background: var(--gold-soft); padding: 3px 10px; border-radius: 99px; font-weight: 600; }
.nav { list-style: none; margin: 0; padding: 12px 10px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: var(--ivory-2); }
.nav a.active { background: var(--anthracite); color: #fff; }
.nav a.active .icon { color: var(--gold); }
.nav .badge { margin-left: auto; }
.nav-cta { padding: 4px 10px 12px; }
.sidebar-foot { padding: 14px 18px 20px; border-top: 1px solid var(--line); font-size: .85rem; }
.sidebar-foot .who { font-weight: 600; color: var(--anthracite); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.env-banner { background: var(--bronze); color: #fff; text-align: center; font-size: .8rem; padding: 4px 8px; letter-spacing: .03em; }
.bottom-nav { display: none; }

/* ---------- composants ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 700; color: var(--anthracite); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.accent { background: var(--anthracite); border-color: var(--anthracite); }
.stat.accent .label { color: #CFC5B0; }
.stat.accent .value { color: var(--gold); }
.currency-block { margin-bottom: 18px; }
.currency-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--bronze); margin: 0 0 8px; font-size: .95rem; }
.currency-title .code { background: var(--gold-soft); border-radius: 6px; padding: 1px 8px; font-size: .78rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: var(--gold); color: var(--anthracite); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--anthracite); }
.btn-primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn-dark { background: var(--anthracite); border-color: var(--anthracite); color: #fff; }
.btn-dark:hover { background: #000; color: var(--gold); }
.btn-danger { background: var(--paper); border-color: #E3B9B3; color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #24653F; color: #fff; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-new { width: 100%; background: var(--gold); border-color: var(--gold); color: var(--anthracite); }
.btn-new:hover { background: var(--gold-deep); color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--ivory-2); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.gold { background: var(--gold); color: var(--anthracite); }
.badge.dark { background: var(--anthracite); color: #fff; }
.status-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.flash { border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--ok-bg); border-color: #BFDDC8; color: #1F5A37; }
.flash.error { background: var(--bad-bg); border-color: #EBC3BD; color: #7E2A21; }
.flash.warn { background: var(--warn-bg); border-color: #EBD3A0; color: #6E4700; }
.flash.info { background: var(--info-bg); border-color: #BCD0E3; color: #234B6E; }
.notice { background: var(--gold-soft); border: 1px solid #EBD3A0; border-left: 4px solid var(--gold); color: #5E4310; border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: .92rem; }
.alert-box { background: var(--bad-bg); border: 1px solid #EBC3BD; border-left: 4px solid var(--bad); border-radius: 10px; padding: 10px 14px; color: #7E2A21; margin-bottom: 12px; }
.suspended-banner { background: var(--warn-bg); border-bottom: 1px solid #EBD3A0; color: #6E4700; padding: 10px 18px; font-weight: 600; text-align: center; }

/* ---------- formulaires ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; color: var(--anthracite); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #D9CDB3; border-radius: 10px; background: #fff; font: inherit; color: var(--ink);
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,162,60,.25); }
input[type=file] { font: inherit; max-width: 100%; }
.req { color: var(--bad); }
.check-list { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 500; margin: 0; }
.check:hover { border-color: var(--gold); }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--gold-deep); flex: none; }
.check .t { font-weight: 600; display: block; }
.check .d { font-weight: 400; color: var(--muted); font-size: .84rem; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline > .field { flex: 1 1 160px; margin-bottom: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; background: var(--paper); }
legend { font-weight: 700; color: var(--bronze); padding: 0 6px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters .field { margin: 0; }
details.filters-box { margin-bottom: 14px; }
details.filters-box > summary { cursor: pointer; font-weight: 600; color: var(--bronze); padding: 6px 0; list-style: none; }
details.filters-box > summary::-webkit-details-marker { display: none; }

/* lignes de déclaration */
.line-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.line-row .field { margin: 0; }
.line-row .unit-tag { font-size: .78rem; color: var(--muted); }
.estimate { background: var(--anthracite); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; }
.estimate h3 { color: var(--gold); margin-bottom: 8px; }
.estimate .total { font-size: 1.6rem; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.estimate ul { margin: 8px 0; padding-left: 18px; font-size: .92rem; }
.estimate .err { color: #FFB4A8; }
.estimate .notice { margin-top: 10px; }

/* ---------- tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--ivory); }
.old { text-decoration: line-through; color: var(--muted); }
.new { color: var(--ok); font-weight: 700; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: .86rem; }
.kv dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid var(--paper); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: .8rem; color: var(--muted); }

.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--gold); margin-bottom: 6px; }
.empty p { margin-bottom: 12px; }
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.code-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.6rem; letter-spacing: .12em; background: var(--anthracite); color: var(--gold); padding: 14px 18px; border-radius: 12px; text-align: center; margin: 12px 0; user-select: all; }
.notif { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.notif.unread .msg { font-weight: 700; }
.notif .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); margin-top: 7px; flex: none; }
.notif.read .dot { background: transparent; }
.notif form { margin: 0; }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.company-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.company-mark { width: 44px; height: 44px; border-radius: 10px; background: var(--anthracite); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex: none; }
.company-head { display: flex; gap: 12px; align-items: center; }

/* ---------- pages d'authentification ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px 40px; background: radial-gradient(circle at top, #FFFDF8 0, var(--ivory) 55%, var(--ivory-2) 100%); }
.auth-card { width: 100%; max-width: 440px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 40px rgba(36,36,36,.10); padding: 26px 24px; }
.auth-card.wide { max-width: 680px; }
.auth-logo { display: block; width: 190px; height: auto; margin: 0 auto 10px; }
.auth-card h1 { text-align: center; font-size: 1.25rem; }
.auth-card .lead { text-align: center; color: var(--muted); margin-bottom: 18px; }
.auth-links { text-align: center; margin-top: 16px; font-size: .92rem; }
.auth-links a { font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px 14px; }
  .topbar img { width: 38px; height: 38px; }
  .topbar .title { line-height: 1.05; }
  .topbar .title b { display: block; color: var(--anthracite); letter-spacing: .08em; font-size: .95rem; }
  .topbar .title span { color: var(--bronze); font-size: .66rem; letter-spacing: .16em; font-weight: 700; }
  .topbar .spacer { flex: 1; }
  .topbar .icon-link { position: relative; color: var(--anthracite); padding: 8px; display: inline-flex; }
  .topbar .icon-link .dot-count { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; border-radius: 99px; font-size: .64rem; min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 700; }
  .content { padding: 16px 14px 100px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 1.12rem; }
  .card { padding: 14px; border-radius: 12px; }
  h1 { font-size: 1.25rem; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--anthracite); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #CFC5B0; text-decoration: none; font-size: .68rem; padding: 4px 2px; font-weight: 600; text-align: center; }
  .bottom-nav a.active { color: var(--gold); }
  .bottom-nav a.fab { color: var(--anthracite); }
  .bottom-nav a.fab .fab-circle { width: 52px; height: 52px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; margin-top: -24px; box-shadow: 0 4px 14px rgba(0,0,0,.35); border: 3px solid var(--anthracite); }
  .bottom-nav a.fab span.l { color: var(--gold); }
  .line-row { grid-template-columns: 1fr 1fr; }
  .line-row .f-product { grid-column: 1 / -1; }
  .line-row .f-remove { grid-column: 1 / -1; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .hide-mobile { display: none; }
  /* tableaux en cartes */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 8px 12px; background: #fff; }
  table.responsive td { border: none; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; flex: none; }
  table.responsive td.num { white-space: normal; }
  table.responsive td.cell-main { display: block; text-align: left; font-weight: 600; }
  table.responsive td.cell-main::before { display: none; }
  .table-wrap { margin: 0; }
}
@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .actions, form { display: none !important; }
  .content { padding: 0; }
}
.mt { margin-top: 10px; } .mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .gap-top { margin-top: 18px; }
@media (min-width: 861px) { .hide-desktop { display: none; } }
a.stat { display: block; text-decoration: none; color: inherit; } a.stat:hover { border-color: var(--gold); }
/* correction administrative et comparatif (v1.1) */
.corr-row { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; }
.corr-row.is-removed { opacity: .55; background: var(--ivory-2); }
.corr-row.is-removed select, .corr-row.is-removed input[type=text] { text-decoration: line-through; }
.corr-date { max-width: 260px; }
.check-sm { padding: 8px 10px; min-height: 42px; align-items: center; }
.estimate table { color: #fff; font-size: .9rem; }
.estimate th { color: #CFC5B0; border-bottom-color: #4a4640; }
.estimate td { border-bottom-color: #3a3732; }
.estimate .chg { color: #E9D7AE; font-size: .82rem; }
.estimate .totals { display: flex; flex-wrap: wrap; gap: 18px; align-items: baseline; margin-top: 10px; }
.estimate .totals .old-total { color: #CFC5B0; text-decoration: line-through; }
.estimate .kind { font-size: .72rem; padding: 1px 8px; border-radius: 99px; background: #4a4640; color: #fff; margin-left: 6px; }
.estimate .kind.added { background: var(--gold); color: var(--anthracite); }
.estimate .kind.removed { background: var(--bad); }
.estimate .kind.replaced { background: var(--info); }
.compare { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.compare.validated { border-color: #BFDDC8; background: #FBFEFC; }
.row-removed td { opacity: .6; }
.row-removed td.cell-main { text-decoration: line-through; }
.row-total td { font-weight: 700; border-top: 2px solid var(--line); }
@media (max-width: 860px) {
  .corr-row { grid-template-columns: 1fr 1fr; }
  .corr-date { max-width: none; }
  .estimate table.responsive tr { background: #2f2c28; border-color: #4a4640; }
  .estimate table.responsive td::before { color: #CFC5B0; }
}
td.cell-main .small, td.cell-main .muted { font-weight: 400; }
