/* MAYKA Real Estate — identité : crème, bruns, taupe, noir. Thème clair unique, par choix.
   Mise en page : menu latéral sur ordinateur ; barre d'onglets en bas et bouton « + » sur téléphone. */
:root {
  --bg: #f7f1e9; --surface: #fffdf9; --sunken: #f1e9de; --line: #e4d9cb; --line-strong: #cfc0ad;
  --ink: #282624; --muted: #776c62; --brand: #7b6049; --brand-dark: #5a4534; --taupe: #a9937d; --tint: #efe5d8;
  --good: #2e6a4f; --good-bg: #e3efe7; --warn: #9a5c14; --warn-bg: #f7ead5; --bad: #a03a2d; --bad-bg: #f6e1dc; --info: #4b607a; --info-bg: #e6ebf1;
  --display: 'Manrope', 'Segoe UI', system-ui, sans-serif; --body: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --r: 14px; --r-s: 10px; --shadow: 0 1px 2px rgba(40, 38, 36, .05), 0 8px 24px rgba(40, 38, 36, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; line-height: 1.15; }
h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { flex: none; }
.muted, small { color: var(--muted); }
small { font-size: 12.5px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 12.5px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- cadre ---------- */
#app { min-height: 100%; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.brand { display: block; padding: 0 20px 10px; }
.brand img { width: 100%; max-width: 150px; display: block; margin: 0 auto; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .nav-top { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-s); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14.5px; }
.side nav a:hover, .nav-top:hover { background: var(--sunken); }
.side nav a.on, .nav-top.on { background: var(--brand); color: #fff; }
.side nav a .count { margin-left: auto; }
.side nav a.on .count { background: rgba(255, 255, 255, .22); color: #fff; }
.switch { display: grid; gap: 4px; margin: 6px 0 4px; padding: 10px 12px; background: var(--sunken); border-radius: var(--r-s); }
.switch span { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.switch select { border: 0; background: transparent; font-weight: 700; font-family: var(--display); padding: 2px 0; width: 100%; }
.side-hint { font-size: 13px; color: var(--muted); padding: 8px 12px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.me strong, .me small { display: block; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--tint); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.top, .tabs { display: none; }
.view { padding: 30px clamp(18px, 3.2vw, 44px) 60px; max-width: 1240px; width: 100%; display: flex; flex-direction: column; gap: 22px; }
.loading { color: var(--muted); padding: 40px 0; }
.demo-banner { background: var(--ink); color: #f7f1e9; border-radius: var(--r-s); padding: 8px 14px; font-size: 13px; font-weight: 500; }

/* ---------- en-tête de page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div:first-child { display: grid; gap: 6px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.left { margin-top: 12px; }
.section-title { font-size: 15px; margin-bottom: 10px; }
section + section { margin-top: 0; }

/* ---------- boutons, champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-text { color: var(--bad); border-color: transparent; background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 10px; color: var(--muted); position: relative; text-decoration: none; }
.icon-btn:hover, .icon-btn.on { background: var(--sunken); color: var(--ink); }
.link { border: 0; background: none; color: var(--brand-dark); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 0; }
.link.back { color: var(--muted); font-size: 13.5px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: #fff; }
textarea { resize: vertical; min-height: 64px; }
input:disabled, select:disabled, textarea:disabled { background: var(--sunken); color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.unit, .amount-box { position: relative; }
.unit b, .amount-box b { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; font-size: 13px; pointer-events: none; }
.unit input { padding-right: 52px; }
.amount-box input { font: 800 28px/1.2 var(--display); min-height: 60px; padding-right: 40px; font-variant-numeric: tabular-nums; }
.amount-box b { font-size: 22px; }
.seg { display: inline-flex; background: var(--sunken); border-radius: var(--r-s); padding: 3px; gap: 2px; max-width: 100%; }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); min-height: 38px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(40, 38, 36, .14); }
.seg.filter { align-self: flex-start; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label, .check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.lines { display: grid; gap: 8px; margin-top: 8px; }
.line { display: flex; align-items: center; gap: 8px; }
.line select { width: auto; flex: none; }
.line input { flex: 1; min-width: 0; }
.line.pay { flex-wrap: wrap; }
.line.pay input[type=date] { flex: 1 1 130px; }
.line.pay select { flex: 1 1 130px; }
.line.member input[type=email] { flex: 2; }
.fold > summary { cursor: pointer; font-weight: 600; color: var(--brand-dark); padding: 8px 0; }
.fold[open] > summary { margin-bottom: 10px; }
.fold > .field, .fold > div { margin-bottom: 14px; }
.sub-title { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.scan-btn { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 12px 14px; border: 1px dashed var(--line-strong); background: var(--sunken); border-radius: var(--r); color: var(--brand-dark); }
.scan-btn strong, .scan-btn small { display: block; }
.drop { display: grid; justify-items: center; gap: 4px; padding: 24px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--sunken); cursor: pointer; color: var(--brand-dark); text-align: center; }
.doc-pill { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; background: var(--sunken); border-radius: 8px; font-size: 13.5px; margin-bottom: 6px; }
.doc-pill span { flex: 1; overflow-wrap: anywhere; }
.doc-pill .icon-btn { width: 28px; height: 28px; }

/* ---------- cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.pad { padding: 16px 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head > div { display: grid; gap: 2px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two-cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.grid.two-cols.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.project-card { text-align: left; cursor: pointer; gap: 8px; }
.project-card:hover { border-color: var(--taupe); }
.project-card h3 { font-size: 18px; }
.big-num { font: 800 28px/1.1 var(--display); font-variant-numeric: tabular-nums; margin-top: 6px; }
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.mini dt { font-size: 12px; color: var(--muted); }
.mini dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.card-go { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-dark); font-weight: 600; font-size: 13.5px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 6px; align-content: start; box-shadow: var(--shadow); min-width: 0; }
.kpi p { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi strong { font: 800 26px/1.1 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.dark { background: var(--ink); border-color: var(--ink); color: #f7f1e9; }
.kpi.dark p, .kpi.dark small { color: #cbbfb2; }
.pos { color: var(--good); } .neg { color: var(--bad); } .warn { color: var(--warn); } .na { color: var(--taupe); }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--tint); color: var(--brand-dark); font: 700 12px var(--body); }
.count.hot { background: var(--warn-bg); color: var(--warn); }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--tint); color: var(--brand-dark); white-space: nowrap; text-transform: none; letter-spacing: 0; }
.chip.good { background: var(--good-bg); color: var(--good); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); } .chip.brand { background: var(--brand); color: #fff; }
.chip.plain { background: transparent; border: 1px dashed var(--taupe); color: var(--brand-dark); }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--tint); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.bar.bad i { background: var(--bad); } .bar.light { background: rgba(255, 255, 255, .18); } .bar.light i { background: #e7d6c2; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--taupe); }
.dot.green, .dot.good { background: var(--good); } .dot.amber, .dot.warn { background: #c98a2b; } .dot.red, .dot.bad { background: var(--bad); } .dot.info { background: var(--info); }

/* ---------- listes ---------- */
.rows { display: grid; gap: 8px; }
.rows.flat { gap: 0; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); text-align: left; min-width: 0; }
.rows.flat .row { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
button.row:hover { background: #fbf6ee; }
.row-date { flex: none; width: 92px; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tags { display: flex; align-items: center; gap: 6px; flex: none; }
.clip { color: var(--muted); display: inline-flex; }
.row-num { flex: none; text-align: right; display: grid; font-variant-numeric: tabular-nums; min-width: 96px; }
.row-num b { font-family: var(--display); font-weight: 700; }
.row-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.doc-ic { color: var(--taupe); display: inline-flex; }
.score { font: 800 18px var(--display); flex: none; min-width: 58px; text-align: right; }
.score small { font-weight: 600; font-size: 11px; }
.score.green { color: var(--good); } .score.amber { color: var(--warn); } .score.red { color: var(--bad); }
.list-sum { padding: 13px 18px; font-size: 14px; color: var(--muted); }
.list-sum strong { color: var(--ink); }
.group > summary { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--sunken); cursor: pointer; border-top: 1px solid var(--line); }
.group > summary b { margin-left: auto; font-family: var(--display); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar select { width: auto; flex: 0 1 200px; }
.search { flex: 1 1 240px; position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 12px; color: var(--muted); }
.search input { padding-left: 36px !important; }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 34px 20px; color: var(--muted); }
.empty strong { color: var(--ink); font-family: var(--display); }
.empty.boot { margin-top: 15vh; }

/* ---------- tableau de bord ---------- */
.legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.legend span, .plain dt { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.actual { background: var(--brand); } .lg.planned { background: var(--line-strong); } .lg.noreceipt { background: var(--taupe); }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.bar-name { font-weight: 600; font-size: 14px; }
.bar-track { position: relative; height: 18px; background: var(--sunken); border-radius: 5px; }
.bar-track i { position: absolute; left: 0; border-radius: 5px; }
.bar-track .planned { top: 0; bottom: 0; background: var(--line-strong); opacity: .7; }
.bar-track .actual { top: 4px; bottom: 4px; background: var(--brand); }
.bar-row.over .actual { background: var(--bad); }
.bar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; display: grid; min-width: 92px; font-size: 14px; }
.bar-val small { font-weight: 400; }
.plain { display: grid; gap: 0; }
.plain > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.plain > div:first-child { border-top: 0; }
.plain dd { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.plain .total { border-top: 2px solid var(--ink); font-weight: 700; }
.todo { display: grid; }
.todo button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; font-size: 14px; }
.todo li:first-child button { border-top: 0; }
.todo button span:nth-child(2) { flex: 1; }
.todo button b { font-variant-numeric: tabular-nums; }
.todo button:hover { color: var(--brand-dark); }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--good); font-weight: 600; font-size: 14px; }
.split { height: 12px; border-radius: 6px; background: var(--taupe); overflow: hidden; }
.split i { display: block; height: 100%; background: var(--brand); }

/* ---------- bilan ---------- */
.result { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.result th, .result td { padding: 9px 0; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.result thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.result tbody th { text-align: left; font-weight: 500; }
.result td { font-weight: 700; padding-left: 14px; }
.result td.muted { font-weight: 500; }
.result .sub th { padding-left: 16px; color: var(--muted); font-size: 13.5px; } .result .sub td { font-weight: 500; color: var(--muted); }
.result .total th, .result .total td { border-top: 2px solid var(--ink); font: 800 17px var(--display); }
.result .total.neg td:first-of-type { color: var(--bad); }
.budget { display: grid; }
.budget-row { display: grid; grid-template-columns: minmax(110px, 1.2fr) 130px 1fr 1fr minmax(60px, 1fr); gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.budget-row.head { border-top: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.budget-row.head span:nth-child(n+3) { text-align: right; }
.budget-row.idle .b-name { color: var(--muted); }
.b-name { font-weight: 600; }
.b-input { min-height: 38px !important; text-align: right; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- journal ---------- */
.timeline { display: grid; }
.timeline li { display: flex; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line); }
.timeline li .dot { margin-top: 6px; }
.timeline li.unread { background: #fbf4e6; }
.timeline small { display: block; margin-top: 2px; }
.diff { margin: 4px 0; font-size: 13.5px; display: grid; gap: 2px; }
.diff s { color: var(--muted); }
.plain-list { display: grid; gap: 4px; font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.report { margin-top: 12px; padding: 12px 14px; background: var(--good-bg); border-radius: var(--r-s); font-size: 14px; }
.report ul { list-style: disc; padding-left: 18px; margin-top: 6px; display: grid; gap: 3px; }
.report .warn { color: var(--warn); }

/* ---------- simulateur ---------- */
.sim { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 18px; align-items: start; }
.sim-form { gap: 16px; }
.sim-result { position: sticky; top: 20px; display: grid; gap: 16px; }
.verdict { border-top: 5px solid var(--taupe); }
.verdict.green { border-top-color: var(--good); } .verdict.amber { border-top-color: #c98a2b; } .verdict.red { border-top-color: var(--bad); }
.verdict-top { display: flex; justify-content: space-between; gap: 16px; }
.score-big { font: 800 44px/1 var(--display); }
.score-big small { font-size: 15px; font-weight: 600; }
.verdict-reco { text-align: right; display: grid; gap: 2px; }
.verdict-reco strong { font: 800 24px var(--display); font-variant-numeric: tabular-nums; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vs > div { background: var(--sunken); border-radius: var(--r-s); padding: 12px; display: grid; gap: 2px; }
.vs p { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.vs strong { font: 800 19px var(--display); font-variant-numeric: tabular-nums; }
.warns { display: grid; gap: 8px; font-size: 14px; }
.warns li { display: flex; gap: 8px; align-items: flex-start; }
.warns .ic { color: var(--warn); margin-top: 2px; }
.sim-bar { display: none; }

/* ---------- panneaux, confirmations, messages ---------- */
.sheet-wrap, .modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; }
.modal-wrap { align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.sheet-back { position: absolute; inset: 0; background: rgba(40, 38, 36, .42); }
.sheet { position: relative; width: min(480px, 100%); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(40, 38, 36, .18); animation: slide .18s ease-out; }
.sheet.wide { width: min(640px, 100%); }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet > header h2 { font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.sheet > footer { display: flex; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); align-items: center; }
.modal { position: relative; background: var(--surface); border-radius: var(--r); padding: 22px; width: min(420px, 100%); display: grid; gap: 10px; box-shadow: 0 20px 60px rgba(40, 38, 36, .3); }
.modal h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#toast-root { position: fixed; left: 18px; bottom: 18px; z-index: 80; pointer-events: none; display: grid; gap: 8px; max-width: min(360px, calc(100% - 36px)); }
.toast { background: var(--ink); color: #f7f1e9; padding: 12px 16px; border-radius: var(--r-s); box-shadow: 0 10px 30px rgba(40, 38, 36, .3); display: grid; gap: 2px; font-size: 14px; }
.toast span { color: #d5c9bc; font-size: 13px; }
.toast.error { background: var(--bad); } .toast.error span { color: #f6e1dc; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* ---------- tablette ---------- */
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two-cols, .grid.two-cols.even, .sim { grid-template-columns: minmax(0, 1fr); }
  .sim-result { position: static; }
}

/* ---------- téléphone ---------- */
@media (max-width: 760px) {
  #app { display: block; padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .side { display: none; }
  .top { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .top-brand { font: 800 15px var(--display); letter-spacing: .28em; text-decoration: none; color: var(--ink); }
  .top select { flex: 1; min-width: 0; min-height: 38px; border: 0; background: var(--sunken); font-weight: 700; padding: 6px 10px; }
  .top > span { flex: 1; }
  .pip { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
  .tabs { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabs.single { grid-template-columns: 1fr; }
  .tabs a { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; border-radius: 10px; }
  .tabs a.on { color: var(--brand-dark); }
  .fab { justify-self: center; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 18px rgba(90, 69, 52, .4); }
  .view { padding: 18px 16px 30px; gap: 16px; }
  h1 { font-size: 22px; }
  .page-head .actions [data-add-expense] { display: none; }
  .card { padding: 16px; }
  .pad { padding: 14px 16px; }
  .kpi strong { font-size: 21px; } .kpi { padding: 13px 14px; }
  .grid.kpis { gap: 10px; }
  .row { flex-wrap: wrap; gap: 6px 10px; padding: 12px 16px; }
  .row-date { width: auto; order: 3; font-size: 12.5px; }
  .exp-row .row-main { flex: 1 1 60%; order: 1; }
  .exp-row .row-num { order: 2; min-width: 0; }
  .exp-row .row-tags { order: 4; margin-left: auto; }
  .row-main strong, .row-main small { white-space: normal; }
  .doc-row .row-actions { width: 100%; }
  .hide-s { display: none; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; order: 3; height: 14px; }
  .budget-row { grid-template-columns: 1fr 104px 84px; }
  .budget-row > span:nth-child(4), .budget-row > span:nth-child(5) { display: none; }
  .two { gap: 10px; }
  .three { gap: 8px; }
  .sheet, .sheet.wide { width: 100%; }
  .line.member { flex-wrap: wrap; } .line.member input, .line.member select { flex: 1 1 100%; }
  #toast-root { left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  [data-route=simulateur] { padding-bottom: 90px; }
  .sim-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom, 0px)); z-index: 25; background: var(--ink); color: #f7f1e9; padding: 10px 16px; font-size: 13px; }
  .sim-bar span { display: grid; } .sim-bar small { color: #cbbfb2; font-size: 11px; } .sim-bar b { font-family: var(--display); } .sim-bar .neg { color: #f0a497; }
  .sim-bar .score.green { color: #8fd0ad; } .sim-bar .score.amber { color: #f0c377; } .sim-bar .score.red { color: #f0a497; }
  .verdict-top { flex-direction: column; } .verdict-reco { text-align: left; }
}
@media (max-width: 420px) { .two { grid-template-columns: minmax(0, 1fr); } .seg button { padding: 8px 10px; } }
@media (max-width: 760px) {
  .toolbar select { flex: 1 1 130px; min-width: 0; }
  .page-head .actions .btn { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
  .seg.filter { align-self: stretch; overflow-x: auto; flex-wrap: nowrap; }
  .seg.filter button { white-space: nowrap; }
}

/* ---------- garde-fous de largeur (Safari iOS compris) ----------
   Sur iPhone, un champ date garde une largeur propre et déborde de sa colonne
   si on ne neutralise pas son apparence native. */
input, select, textarea { min-width: 0; max-width: 100%; }
select { text-overflow: ellipsis; }
input[type=date] { -webkit-appearance: none; appearance: none; display: block; width: 100%; text-align: left; line-height: 1.3; }
input[type=date]::-webkit-date-and-time-value { text-align: left; min-height: 1.3em; }
.field, .form > *, .card > *, .line > *, .sheet-body > * { min-width: 0; }
.btn { max-width: 100%; }
.timeline li > div { min-width: 0; overflow-wrap: anywhere; }
.line.member select { flex: 1 1 220px; width: auto; }
.row-num, .bar-val, .kpi small, .hint, .muted { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .actions .btn, .card-head .btn { white-space: normal; text-align: center; line-height: 1.2; padding-top: 6px; padding-bottom: 6px; }
  .card-head { flex-wrap: wrap; }
  .budget-row { grid-template-columns: minmax(0, 1fr) 96px minmax(64px, auto); gap: 8px; }
  .line.member select, .line.member input { flex: 1 1 100%; width: 100%; }
  .line.member .icon-btn { margin-left: auto; }
  .timeline li { padding: 12px 16px; }
  .amount-box input { font-size: 24px; }
}
@media (max-width: 420px) { .three { grid-template-columns: repeat(3, minmax(0, 1fr)); } .unit input { padding-right: 34px; } .unit b { right: 8px; font-size: 12px; } }
.b-name { overflow-wrap: anywhere; }
@media (max-width: 360px) { .budget-row { grid-template-columns: minmax(0, 1fr) 84px minmax(56px, auto); } .b-name { font-size: 13.5px; hyphens: auto; } }

.works-total { display: grid; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.works-total strong { font: 800 20px var(--display); }
.field.envelope { max-width: 420px; }
.field.envelope .b-input { text-align: left; min-height: 44px !important; }
