/* Ajustements tactiles et petits écrans */
html, body { max-width: 100%; overflow-x: hidden; }
.shell, .main, .card { min-width: 0; }
.actions { flex-wrap: wrap; }
.actions > form, .actions > div { min-width: 0; }
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 680px; }
.amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.metric small { font-size: .48em; font-weight: 650; color: var(--muted); }
table { font-variant-numeric: tabular-nums; }
th { letter-spacing: .04em; }
td { vertical-align: middle; }
.unallocated { background: #fff0bf; color: #765a00; }
.allocation-choice { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 20px; padding: 15px; background: #eef3ed; border-radius: 10px; }
.allocation-choice input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; }
.allocation-choice label { margin: 0; cursor: pointer; }
.allocation-choice label span { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.total-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.total-row:last-child { border-bottom: 0; }

@media (max-width: 850px) {
    .side { padding: 14px 12px 10px; }
    .brand { margin: 0 0 12px; text-align: center; font-size: 22px; }
    .side nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
        overflow: visible;
    }
    .side nav a {
        margin: 0;
        padding: 9px 4px;
        font-size: 12px;
        line-height: 1.2;
        text-align: center;
        white-space: normal;
    }
    .main { padding: 18px 14px 30px; }
    .top { gap: 12px; align-items: center; }
    .top h1 { font-size: 23px; line-height: 1.2; }
    .top form { flex: 0 0 auto; }
    .grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 16px; border-radius: 11px; }
    .metric { font-size: 24px; overflow-wrap: anywhere; }
    .actions { align-items: stretch; }
    .actions > input, .actions > select { flex: 1 1 145px; width: auto; }
    .actions > .btn, .actions > a.btn { flex: 0 1 auto; text-align: center; }
    input, select, textarea { font-size: 16px; }
    td .actions { flex-wrap: nowrap; align-items: center; }
}

@media (max-width: 480px) {
    .side nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .main { padding: 14px 10px 26px; }
    .top { align-items: flex-start; }
    .top h1 { font-size: 20px; }
    .top .btn { padding: 8px 10px; font-size: 12px; }
    .card { padding: 13px; }
    h2 { font-size: 17px; }
    .metric { font-size: 21px; }
    .actions > form:not([class]) { width: 100%; }
    .btn { min-height: 42px; }
    .table-wrap { padding: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
    .table-wrap table { min-width: 0; display: block; }
    .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-wrap tbody { display: grid; gap: 10px; }
    .table-wrap tr { display: block; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 2px 8px #1a2d2110; }
    .table-wrap td { display: grid; grid-template-columns: minmax(90px, 38%) minmax(0, 62%); gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; }
    .table-wrap td:last-child { border-bottom: 0; }
    .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; text-align: left; }
    .table-wrap td[colspan] { display: block; text-align: center; }
    .table-wrap td[colspan]::before { display: none; }
    .table-wrap td .actions, .table-wrap td.actions { justify-content: flex-end; }
    .table-wrap nav { margin-top: 14px; }
}
