/* Budget (section de /dashboard) : s'appuie sur Bootstrap (Lux) et /css/site.css comme le reste du site.
   Tout est rangé sous .budget-page pour ne pas toucher au reste de la page. */

.budget-page {
  --page: #f9fafb; --surface: #fff; --ink: var(--bs-body-color, #111827); --ink2: #4b5563; --muted: #6b7280;
  --grid: #eef0f3; --axis: #d1d5db; --border: var(--bs-border-color, #e5e7eb); --hover: rgba(17,24,39,.05);
  /* Série principale = couleur du site ; secondaire = gris foncé */
  --s1: var(--bs-primary, #ff7a00); --s1-soft: #ffd3a8; --s2: #374151; --s2-soft: #c7ccd4;
  --good: #198754; --good-bg: rgba(25,135,84,.10); --bad: #dc3545; --bad-bg: rgba(220,53,69,.10);
  --warn: #b45309; --warn-bg: rgba(255,153,0,.12);
}

.budget-page code { font-size: 13px; background: var(--hover); padding: 1px 5px; border-radius: 4px; color: inherit; }
.budget-page .muted { color: var(--muted); }
.budget-page .good { color: var(--good); }
.budget-page .bad { color: var(--bad); }
.budget-page .strong { font-weight: 650; }
.budget-page .nowrap { white-space: nowrap; }
.budget-page .num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ===== Blocs : pas d'effet carte, comme les autres sections du tableau de bord ===== */
.budget-page section { margin: 0 0 24px; }
.budget-page section h2 { font-size: 1.1rem; margin: 0 0 6px; }
.budget-page section h3 { font-size: .95rem; margin: 20px 0 8px; }
.budget-page section > p.muted { margin: 0 0 12px; font-size: 13px; }
.budget-page .modal-body > div > section:last-child,
.budget-page .modal-body > section:last-child { margin-bottom: 0; }

.budget-page .insights ul { margin: 0; padding-left: 20px; }
.budget-page .insights li { margin: 4px 0; }
.budget-page .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* ===== Graphiques SVG ===== */
.budget-page .chart { margin: 0; }
.budget-page .chart svg { width: 100%; height: auto; display: block; }
.budget-page .chart .grid { stroke: var(--grid); stroke-width: 1; }
.budget-page .chart .baseline { stroke: var(--axis); stroke-width: 1; }
.budget-page .chart .budget { stroke: var(--ink2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.budget-page .chart .axis-lbl { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.budget-page .chart .axis-lbl.sub { font-size: 10.5px; opacity: .8; }
.budget-page .chart .lbl { fill: var(--muted); font-size: 12px; }
.budget-page .chart .val { fill: var(--ink); font-size: 13px; font-weight: 600; }
.budget-page .chart .s1 { fill: var(--s1); }
.budget-page .chart .soft1 { fill: var(--s1-soft); }
.budget-page .chart .s2 { fill: var(--s2); }
.budget-page .chart .soft2 { fill: var(--s2-soft); }
.budget-page .chart .hit:hover path, .budget-page .chart .hit:focus path { opacity: .85; }
.budget-page .chart .hit:focus { outline: none; }
.budget-page .chart .line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.budget-page .chart .s1-line { stroke: var(--s1); stroke-width: 2; }
.budget-page .chart .proj1 { stroke: var(--s1); stroke-width: 2; stroke-dasharray: 2 5; }
.budget-page .chart .reserve { stroke: var(--bad); stroke-width: 1; stroke-dasharray: 4 4; }
.budget-page .chart .dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.budget-page .chart .dot.hollow { fill: var(--surface); stroke: var(--ink2); stroke-width: 2; }
.budget-page .chart .hit:hover .dot, .budget-page .chart .hit:focus .dot { r: 6; }
.budget-page .chart .halo text { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.budget-page .legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink2); margin: 0 0 4px; }
.budget-page .legend span { display: inline-flex; align-items: center; gap: 6px; }
.budget-page .key-line { display: inline-block; width: 20px; height: 0; border-top: 2px solid var(--s1); }
.budget-page .key-line.proj1 { border-top: 2px dotted var(--s1); }
.budget-page .key-line.budget { border-top: 2px dashed var(--ink2); }

/* ===== Barres horizontales (catégories) ===== */
.budget-page .hbars { display: flex; flex-direction: column; gap: 2px; }
.budget-page .hrow { display: grid; grid-template-columns: minmax(110px, 190px) 1fr minmax(120px, auto); align-items: center; gap: 12px;
                     padding: 5px 4px; border-radius: 6px; color: inherit; text-decoration: none; }
.budget-page .hrow:hover, .budget-page .hrow:focus { background: var(--hover); outline: none; }
.budget-page .hlabel { font-size: 14px; }
.budget-page .htrack { position: relative; height: 12px; background: #f3f4f6; border-radius: 6px; }
.budget-page .hbar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--s1); border-radius: 6px; min-width: 2px; }
.budget-page .hrow.accent .hbar { background: var(--s2); }
.budget-page .hrow.accent .hlabel { font-weight: 650; }
.budget-page .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.budget-page .hval { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-page .hval .good, .budget-page .hval .bad { font-size: 12px; }

/* ===== Tableaux ===== */
.budget-page .scroll { overflow-x: auto; }
.budget-page table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.budget-page table.data th { text-align: left; font-weight: 600; color: var(--ink2); border-bottom: 1px solid var(--axis); padding: 6px 8px; vertical-align: bottom; }
.budget-page table.data td { border-bottom: 1px solid var(--grid); padding: 5px 8px; vertical-align: middle; }
.budget-page table.data tfoot td { font-weight: 650; border-top: 1px solid var(--axis); border-bottom: 0; }
.budget-page table.heat td.num:not(.strong) { background: color-mix(in oklab, var(--s1) var(--i, 0%), transparent); }
.budget-page table.heat td.dark { color: #fff; }
.budget-page details { border-top: 1px solid var(--grid); }
.budget-page details summary { display: flex; justify-content: space-between; gap: 12px; padding: 10px 4px; cursor: pointer; list-style: none; }
.budget-page details summary::-webkit-details-marker { display: none; }
.budget-page details summary::before { content: "▸"; color: var(--muted); margin-right: 6px; }
.budget-page details[open] summary::before { content: "▾"; }
.budget-page details summary span:first-child { flex: 1; }
.budget-page details table { margin: 0 0 12px; }

/* ===== Filtres, formulaires ===== */
.budget-page .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.budget-page .filters input[type=search] { flex: 1 1 220px; width: auto; }
.budget-page .actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.budget-page .inline-form { display: inline; margin: 0; }
.budget-page textarea.code { width: 100%; min-height: 55vh; font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; tab-size: 2; resize: vertical; }
.budget-page input.amount { width: 140px; text-align: right; font-variant-numeric: tabular-nums; margin-left: auto; }
.budget-page table.balances input[type=text]:not(.amount) { min-width: 150px; }
.budget-page .balance-date { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }

/* ===== Import des relevés ===== */
.budget-page .dropzone { display: block; position: relative; border: 2px dashed var(--axis); border-radius: 14px; padding: 28px 16px; text-align: center; cursor: pointer; transition: background .1s, border-color .1s; }
.budget-page .dropzone:hover, .budget-page .dropzone.over { border-color: var(--s1); background: color-mix(in oklab, var(--s1) 8%, transparent); }
.budget-page .dropzone strong { display: block; font-size: 16px; margin-bottom: 4px; }
/* Le champ fichier, invisible, couvre la zone : clic et glisser-déposer passent par lui. */
.budget-page .dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.budget-page .formats { font-size: 13px; margin: 12px 0 0; padding-left: 20px; }

/* ===== Montants en dollars et en euros ===== */
.budget-page .dual { display: inline-flex; flex-direction: column; line-height: 1.15; }
.budget-page .dual small { font-size: .62em; font-weight: 400; color: var(--muted); }
.budget-page td .dual, .budget-page .num .dual { align-items: flex-end; }
.budget-page td .dual small { font-size: 11px; }

/* ===== Infobulle des graphiques ===== */
#tip { position: fixed; pointer-events: none; z-index: 2000; background: #fff; color: #111827; border: 1px solid #e5e7eb;
       box-shadow: 0 4px 16px rgba(0,0,0,.15); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.45; opacity: 0; transition: opacity .1s; max-width: 280px; }
#tip b { display: block; margin-bottom: 2px; }

@media (max-width: 640px) {
  .budget-page .hrow { grid-template-columns: 1fr auto; }
  .budget-page .htrack { grid-column: 1 / -1; grid-row: 2; }
}
