/* Kagegumi — charte « Néons de Kabukichō » (spec ui-v1-design §3). Variables, squelette, composants. */

:root {
    --night: #0d0b14;
    --surface: #1a1528;
    --surface-deep: #150f22;
    --line: #2a2440;
    --text: #e8e3f0;
    --muted: #9a90b5;
    --neon: #ff3d8b;
    --cyan: #7fe7ff;
    --ok: #2ecc71;
    --ok-text: #5ee89a;
    --warn: #ffcf5c;
    --bad: #ff6b6b;
    --bad-text: #ff8a8a;
    --radius: 8px;
    --font: -apple-system, 'Helvetica Neue', 'Hiragino Sans', 'Noto Sans JP', Arial, sans-serif;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/* Le fond est aussi celui de <html> : aucune zone sans couleur pendant un chargement ou le fondu entre pages. */
html { background: var(--night); }

body {
    margin: 0;
    background: var(--night);
    color: var(--text);
    font: 15px/1.5 var(--font);
}

a { color: var(--cyan); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.positive { color: var(--ok-text); }
.negative { color: var(--bad-text); }
.label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Squelette ---------- */

.layout-app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.layout-guest { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto; /* fenêtre basse : la fin du menu (Déconnexion) reste atteignable */
    display: flex; flex-direction: column; gap: 20px;
    padding: 20px 16px;
    background: var(--surface-deep);
    border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.seal {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px;
    background: var(--neon); color: var(--night); font-weight: 800; font-size: 1.1rem;
    box-shadow: 0 0 14px color-mix(in srgb, var(--neon) 60%, transparent);
}
.brand-name { font-weight: 800; letter-spacing: .08em; color: var(--neon); text-shadow: 0 0 8px color-mix(in srgb, var(--neon) 60%, transparent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { padding: 8px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link[aria-current="page"] { color: var(--neon); background: color-mix(in srgb, var(--neon) 13%, transparent); }
.city-switch { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 12px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); }
.city-switch form { flex: 1 1 auto; min-width: 0; } /* trois villes (sprint 25) : retour à la ligne plutôt que débordement */
.city-tab { width: 100%; padding: 6px 4px; white-space: nowrap; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.city-tab:hover { color: var(--text); background: var(--surface); }
.city-tab[aria-current="true"] { color: var(--neon); background: color-mix(in srgb, var(--neon) 13%, transparent); }
.city-tab:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.alert form { margin: 0; }
.sidebar-status { margin: auto 0 0; display: grid; gap: 2px; }
.sidebar-status dd { margin: 0 0 8px; }
.treasury { font-size: 1.2rem; font-weight: 700; }
.logout { color: var(--muted); font-size: .85rem; }
.sidebar > .account-link + .account-link, .sidebar > .account-link + .logout { margin-top: -12px; } /* les trois liens du compte, groupés */

.main { padding: 28px 32px 64px; max-width: 1200px; width: 100%; min-width: 0; } /* min-width : un tableau large défile dans son cadre au lieu d'élargir la page */
.page-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section { margin: 28px 0; }

/* Téléphone (spec sprint 33 §3) : bandeau fin en haut, onglets en bas ; le menu latéral s'efface sous 800 px. */
.mobile-topbar, .mobile-tabs { display: none; }

@media (max-width: 800px) {
    .layout-app { grid-template-columns: 1fr; }
    .layout-app .sidebar { display: none; }
    .main { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); } /* 20 px en haut : le bandeau de ville (city.css) remonte d'autant */
    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        position: sticky; top: 0; z-index: 20;
        padding: 6px 16px; min-height: 52px;
        background: var(--surface-deep); border-bottom: 1px solid var(--line);
    }
    .mobile-brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; min-width: 0; }
    .mobile-brand .seal { width: 30px; height: 30px; font-size: .95rem; }
    .mobile-brand .treasury { font-size: 1rem; white-space: nowrap; }
    .mobile-date { min-width: 0; overflow: hidden; color: var(--muted); font-size: .78rem; text-align: center; white-space: nowrap; text-overflow: ellipsis; }
    .mobile-city { min-height: 44px; padding: 0 4px; display: inline-flex; align-items: center; border: 0; background: none; color: var(--cyan); font: inherit; font-size: .85rem; white-space: nowrap; }
    .mobile-tabs {
        display: flex; justify-content: space-around;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        padding: 4px 0 env(safe-area-inset-bottom);
        background: var(--surface-deep); border-top: 1px solid var(--line);
    }
    .mobile-tabs a, .mobile-tabs button {
        flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        border: 0; background: none; color: var(--muted); font: inherit; font-size: .72rem; text-decoration: none; cursor: pointer;
    }
    .mobile-tabs .tab-icon { font-size: 1.2rem; line-height: 1; }
    .mobile-tabs [aria-current="page"] { color: var(--neon); }
    .dialog.dialog--sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
    .more-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
    #dialog-more [data-testid="more-era"] { margin: 8px 0 0; padding: 0 10px; }
    .more-links form { margin: 0; }
    .more-links .nav-link { display: flex; align-items: center; width: 100%; min-height: 44px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
    .more-links .nav-link[aria-current="true"] { color: var(--neon); }
    .more-account { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
    .more-account .nav-link { display: flex; align-items: center; min-height: 44px; }
}

/* ---------- Bandeaux ---------- */

.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { margin: 0; padding: 10px 14px; border-radius: 6px; background: var(--surface); border-left: 3px solid var(--ok); transition: opacity .4s; }
.flash-error { border-left-color: var(--bad); }
.flash-leaving { opacity: 0; }
.verify-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 20px; padding: 10px 14px; border-radius: 6px; background: var(--surface); border-left: 3px solid var(--warn); }
.verify-banner p { margin: 0; }
.verify-banner form { margin: 0; }
/* Saisons (spec sprint 30 §6) : bandeau discret ; barre du compte sans clan. */
.season-banner { margin: 4px 0 16px; font-size: 0.9rem; }
.guest-account-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: flex-end; padding: 10px 16px; font-size: 0.9rem; }
.button-link { padding: 0; border: 0; background: none; color: var(--warn); font: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- Chiffres clés ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--neon); border-radius: var(--radius); padding: 10px 14px; }
.kpi-info { border-top-color: var(--cyan); }
.kpi-bad { border-top-color: var(--bad); }
.kpi-value { font-size: 1.5rem; font-weight: 700; }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid transparent; border-radius: 5px; padding: 6px 12px;
    font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
    background: transparent; color: var(--text);
}
.btn-primary { background: var(--neon); color: var(--night); box-shadow: 0 0 12px color-mix(in srgb, var(--neon) 40%, transparent); }
.btn-secondary { border-color: var(--cyan); color: var(--cyan); }
.btn-danger { border-color: color-mix(in srgb, var(--bad) 60%, transparent); color: var(--bad-text); }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
/* Action impossible : reste focalisable ; sa raison s'affiche au focus clavier (le title reste pour la souris). */
.btn[aria-disabled="true"] { position: relative; background: transparent; color: var(--muted); border-color: var(--line); box-shadow: none; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { filter: none; }
.btn[aria-disabled="true"]:focus-visible::after {
    content: attr(title); position: absolute; left: 0; top: calc(100% + 6px); z-index: 10;
    width: max-content; max-width: 260px; padding: 6px 10px; border-radius: 5px; white-space: normal;
    background: var(--surface-deep); border: 1px solid var(--line); color: var(--text); font-weight: 400; font-size: .8rem;
}
.btn:focus-visible, .nav-link:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Badges et jauges ---------- */

.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .75rem; font-weight: 600; border: 1px solid; }
.badge-ok { color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.badge-bad { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.badge-info { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); background: color-mix(in srgb, var(--cyan) 13%, transparent); }
/* Paliers de chaleur (sprint 17) : couleur du badge et liseré de la carte. */
.heat-card { border-left: 3px solid var(--ok); }
.heat-card .badge { color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.heat-watched { border-left-color: var(--cyan); }
.heat-watched .badge { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }
.heat-targeted { border-left-color: var(--warn); }
.heat-targeted .badge { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.heat-burning { border-left-color: var(--bad); }
.heat-burning .badge { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.badge-idle { color: var(--muted); border-color: var(--line); }
.gauge { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.gauge-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--neon)); }

/* ---------- Cartes et tableaux ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title h3 { margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td.num, .table th.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- Alertes « À faire » ---------- */

.alerts { display: grid; gap: 8px; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--cyan); }
.alert-warn { border-left-color: var(--warn); }
.alert-danger { border-left-color: var(--bad); }
.all-clear { color: var(--ok-text); }

/* ---------- Formulaires et fenêtres ---------- */

label { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; }
input, select {
    font: inherit; color: var(--text); background: var(--night);
    border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px;
}
.form-row { display: grid; gap: 12px; margin-bottom: 14px; }
/* Case à cocher et son texte sur une ligne (sprint 49) ; un [hidden] l'emporte sur l'affichage des boutons. */
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; margin-bottom: 12px; }
[hidden] { display: none !important; }
fieldset.form-row { border: 0; padding: 0; margin-inline: 0; }
.choice { color: var(--text); font-size: .95rem; }
.choice.is-disabled { color: var(--muted); }

.dialog {
    width: min(440px, calc(100vw - 32px)); padding: 0; color: var(--text);
    background: var(--surface-deep); border: 1px solid color-mix(in srgb, var(--neon) 55%, transparent); border-radius: 10px;
    box-shadow: 0 0 30px color-mix(in srgb, var(--neon) 20%, transparent);
}
.dialog::backdrop { background: rgb(5 3 10 / .7); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.dialog-header h2 { margin: 0; }
.dialog-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.dialog-body { padding: 14px 18px 18px; }
.preview { background: var(--night); border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; min-height: 2.5em; }
.preview-error { color: var(--bad-text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.is-live .preview-submit { display: none; }
.preview.is-stale { opacity: .5; }

/* ---------- Pages d'accueil (connexion, inscription) ---------- */

.auth { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.auth h1 { color: var(--neon); text-shadow: 0 0 8px color-mix(in srgb, var(--neon) 60%, transparent); }
.auth form { display: grid; gap: 12px; }
.conditions { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.conditions .is-met { color: var(--ok-text); }
.conditions .is-unmet { color: var(--muted); }
.events-banner { display: grid; gap: 6px; margin: 0 0 20px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.events-banner .event { margin: 0; padding-left: 10px; border-left: 3px solid var(--muted); }
.events-banner .event.is-good { border-left-color: var(--ok); }
.events-banner .event.is-bad { border-left-color: var(--warn); }
.event-card.is-good { border-left: 3px solid var(--ok); }
.event-card.is-bad { border-left: 3px solid var(--warn); }
.event-line { color: var(--cyan); }
.warn-line { color: var(--warn); }
.tutorial-card { margin: 0 0 20px; border-left: 3px solid var(--neon); }
.tutorial-card.is-finished { padding: 12px 16px; border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: var(--radius); background: var(--surface); }
.tutorial-bar { height: 4px; margin: 4px 0 10px; border-radius: 2px; background: var(--line); overflow: hidden; }
.tutorial-bar span { display: block; height: 100%; background: var(--neon); }
.tutorial-hidden { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; }
.tutorial-card .actions form { margin: 0; }
.good-usage { display: block; font-size: 0.8em; max-width: 36ch; }
/* Chiffres et boutons d'une ligne ne se coupent pas : c'est le texte (usage des marchandises) qui passe à la ligne. */
.table td.num { white-space: nowrap; }
.table td .actions { flex-wrap: nowrap; }
.market-help { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.market-help p, .market-help ol { margin: 4px 0; }
.market-help ol { padding-left: 20px; }
.market-help ul { margin: 4px 0; padding-left: 20px; }
.shipment-estimate { margin-top: 8px; }
.cargo-value { font-size: 0.85em; white-space: nowrap; }
.storage-detail { font-size: 0.85em; margin: 6px 0 0; }
.ship-lines label { display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: 4px 12px; margin: 4px 0; }
.ship-lines label small { grid-column: 1; }
.ship-lines label input { grid-column: 2; grid-row: 1 / span 2; }
.district-description { font-size: 0.85em; margin: 0 0 8px; max-width: 60ch; }
/* Grands rendez-vous passés (sprint 19) : grisés. */
.card.is-past { opacity: .6; }
/* Cartes empilées dans une section (menus dépliants de l'aide, rapports et rivaux des opérations) : un écart entre elles,
   comme dans une grille ; dans la carte, le gap espace les paragraphes, sans leurs marges en plus. */
.section > .card + .card { margin-top: 10px; }
.card > p { margin: 0; }
/* Un titre de groupe après une carte (familles de bâtiments de l'aide) s'en détache. */
.section > .card + h3 { margin-top: 20px; }
/* Menu dépliant fermé : pas d'espace sous son résumé (le gap de la carte ne compte qu'une fois ouvert). */
details.card { display: block; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 10px; }
/* Carte (sprint 21) : une tuile par quartier, liseré selon la vocation, couleur selon l'état. */
.map-city-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.map-tile { border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.map-tile h3 { margin: 0 0 4px; font-size: 1rem; }
.map-tile:not(.is-mine) { opacity: .75; }
.map-tile.kind-nightlife { border-left-color: var(--neon); }
.map-tile.kind-port { border-left-color: var(--cyan); }
.map-tile.kind-commercial { border-left-color: var(--warn); }
.map-tile.kind-business { border-left-color: #9a90b5; }
.map-tile.kind-industrial { border-left-color: #8a6d4a; }
.map-buildings { list-style: none; margin: 6px 0; padding: 0; }
.map-buildings .state-open { color: var(--ok-text); }
.map-buildings .state-reduced { color: var(--warn); }
.map-buildings .state-suspended, .map-buildings .state-raided { color: var(--bad-text); }
.map-buildings .state-works { color: var(--cyan); }
.map-landmark, .map-event { margin: 2px 0; font-size: .85rem; }
.map-event { color: var(--warn); }
.map-city.is-absent { opacity: .55; }
.account-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.account-facts dd { margin: 0; overflow-wrap: anywhere; }
.account-link { color: var(--muted); font-size: .85rem; }
.account-link[aria-current="page"] { color: var(--text); }
.site-footer { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .85rem; }
.site-footer a { color: var(--muted); }
.legal { max-width: 70ch; }
.legal h2 { margin-top: 28px; }
.legal dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.legal dd { margin: 0; }
/* Négoce (sprint 26) : livraison d'un contrat, sur une ligne quand la place le permet. */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 8px; }
/* Postes de protection (sprint 45) : le bouton « Rappeler » au bout de la ligne du poste. */
/* Ouverture d'un bâtiment (feedbacks n° 6) : un type pas encore possible est grisé, avec sa raison. */
.choice--disabled { opacity: .55; }
.protection-post { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.protection-recall { margin: 0; }
[data-testid="protection-form"] label { min-width: 0; }
[data-testid="protection-form"] select, [data-testid="protection-form"] input { width: 100%; max-width: 100%; box-sizing: border-box; }
.inline-form label { display: grid; gap: 4px; font-size: .85rem; }
.inline-form input[type="number"] { width: 7rem; }
/* Vitrine publique (sprint 28) */
.home { max-width: 1040px; margin: 0 auto; }
.home-hero { padding: 24px 0 8px; }
.home-hero h1 { font-size: 2.4rem; margin: 0 0 8px; }
.home-logo { display: block; width: 160px; height: 160px; margin: 0 0 16px; }
.auth-logo { display: block; width: 96px; height: 96px; margin: 0 0 12px; }
.home-tagline { font-size: 1.25rem; margin: 0 0 8px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.home-cities { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0; } /* quatre villes (sprint 43) */
@media (max-width: 1100px) { .home-cities { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.home-city { overflow: hidden; background: var(--surface); color: var(--text); }
.home-city .city-banner { margin: -16px -16px 12px; }
.home-steps { display: grid; gap: 8px; padding-left: 20px; }
@media (max-width: 720px) {
    .home-cities { grid-template-columns: 1fr; }
    .home-hero h1 { font-size: 1.8rem; }
    .home-logo { width: 112px; height: 112px; }
}

/* Téléphone (spec sprint 33 §4) : chaque ligne devient une carte, chaque cellule « étiquette : valeur ». */
.mobile-only { display: none; }
@media (max-width: 720px) {
    .table-wrap:has(> .table--cards) { overflow: visible; }
    .table--cards thead { display: none; }
    .table--cards, .table--cards tbody, .table--cards td { display: block; width: 100%; }
    /* Deux valeurs par ligne : la carte reste courte ; le titre et les boutons prennent toute la largeur. */
    .table--cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; margin-bottom: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
    .table--cards td:first-child, .table--cards td.actions-cell, .table--cards td[colspan] { grid-column: 1 / -1; }
    .table--cards td:first-child small { font-weight: 400; font-size: .85rem; }
    .table--cards td[colspan] { font-weight: 400; color: var(--muted); } /* ligne « aucune donnée » : pas un titre */
    .table--cards .cargo-value { white-space: normal; } /* valeur d'un envoi : passe à la ligne dans la carte */
    .table.table--cards { background: none; overflow: visible; }
    .table.table--cards td, .table.table--cards td.num { padding: 3px 0; border: 0; text-align: left; white-space: normal; min-width: 0 !important; }
    .table--cards td:first-child { font-weight: 700; font-size: 1.02rem; }
    .table--cards td[data-label]:not(:first-child)::before { content: attr(data-label) " : "; color: var(--muted); font-size: .82rem; }
    .table--cards td[data-label=""]::before { content: none; }
    .table--cards td.actions-cell { padding-top: 8px; }
    .table--cards td.actions-cell .actions, .table--cards td.actions-cell { display: flex; flex-wrap: wrap; gap: 8px; }
    .table--cards td.actions-cell .actions { flex: 1 1 100%; }
    .table--cards td.actions-cell .btn { flex: 1 1 40%; justify-content: center; }
    .mobile-only { display: block; }
    .table--desktop-only, .table-wrap:has(> .table--desktop-only) { display: none; }
}
/* Annonces de l'Immobilier (spec sprint 33 §4) : ligne courte, dépliée pour agir. */
.listing-line { margin-bottom: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.listing-line summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 12px; cursor: pointer; list-style: none; }
.listing-line summary::-webkit-details-marker { display: none; }
.listing-line summary::after { content: '▸'; color: var(--muted); }
.listing-line[open] summary::after { content: '▾'; }
.listing-line summary .num { margin-left: auto; white-space: nowrap; }
.more-alerts { margin-top: 8px; }
.more-alerts summary { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; color: var(--muted); list-style: none; }
.more-alerts summary::-webkit-details-marker { display: none; }
.more-alerts summary::before { content: '▸'; }
.more-alerts[open] summary::before { content: '▾'; }
.more-alerts .alerts { margin-top: 8px; }
/* Onglets de l'aide : la barre passe à la ligne sur mobile plutôt que de déborder. */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--neon); border-bottom-color: var(--neon); }
.tab:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.listing-line-body { padding: 0 12px 12px; }
.listing-line-body p { margin: 0 0 6px; }
.listing-line-body .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.listing-line-body .actions .btn { flex: 1 1 40%; justify-content: center; }

/* Téléphone (spec sprint 33 §4) : fenêtres plein écran, cibles de 44 px, champs de 16 px (pas de zoom d'iOS). */
@media (max-width: 720px) {
    .dialog:not(.dialog--sheet) { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
    .dialog:not(.dialog--sheet)[open] { display: flex; flex-direction: column; }
    .dialog-header { position: sticky; top: 0; z-index: 1; padding-bottom: 10px; background: var(--surface-deep); }
    .dialog-body { flex: 1; overflow-y: auto; }
    .dialog-actions { position: sticky; bottom: 0; flex-wrap: wrap; padding: 10px 0 env(safe-area-inset-bottom); background: var(--surface-deep); }
    .dialog-actions .btn { flex: 1 1 40%; justify-content: center; }
    .btn, .nav-link, .dialog-close, .city-tab, .button-link { min-height: 44px; }
    .dialog-close { min-width: 44px; }
    input, select, textarea { font-size: 16px; min-height: 44px; }
    input[type="checkbox"], input[type="radio"] { min-height: 0; width: 22px; height: 22px; }
    .card .actions .btn { flex: 1 1 40%; justify-content: center; }
    .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
    .map-grid { grid-template-columns: 1fr; }
}

/* Caps d'époque (spec sprint 42) : la marque ✓ / ✗ / · tient lieu de puce. */
.milestone-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 2px; }

/* Graphique de la page Comptes (spec sprint 48 §3) : SVG du serveur, qui s'étire sur la largeur (390 px compris). */
.ledger-chart { margin: 12px 0 4px; }
.ledger-chart svg { display: block; width: 100%; height: auto; background: var(--surface-deep); border: 1px solid var(--line); border-radius: var(--radius); }
.ledger-chart__revenue { fill: var(--ok); }
.ledger-chart__charges { fill: var(--bad); }
.ledger-chart__purchases { fill: var(--warn); }
.ledger-chart__transport { fill: var(--cyan); }
.ledger-chart__axis { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ledger-chart__net { fill: none; stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ledger-chart__dot { fill: var(--text); }
.ledger-chart__dot.negative { fill: var(--bad-text); }
.ledger-chart__days { display: grid; grid-template-columns: repeat(var(--days), 1fr); font-size: .75rem; color: var(--muted); text-align: center; margin-top: 4px; }
.ledger-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 8px 0 12px; font-size: .85rem; color: var(--muted); }
.ledger-legend__swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.ledger-legend__net { background: var(--text); height: 3px; vertical-align: 3px; }
.ledger-legend__swatch.ledger-chart__revenue { background: var(--ok); }
.ledger-legend__swatch.ledger-chart__charges { background: var(--bad); }
.ledger-legend__swatch.ledger-chart__purchases { background: var(--warn); }
.ledger-legend__swatch.ledger-chart__transport { background: var(--cyan); }
@media (max-width: 480px) {
    .ledger-chart__days span:nth-child(even) { visibility: hidden; } /* une date sur deux sous 480 px */
}

/* Réapprovisionnement automatique (spec sprint 49 §3) : ligne de la carte « Bilan du jour » et liste de la fenêtre. */
.restock-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 12px; }
.restock-goods li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }

/* Filtres des bâtiments du tableau de bord (spec sprint 49 §7 bis) : plusieurs lignes sur mobile. */
.building-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; margin: 0 0 12px; }
.building-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.building-filters label.checkbox { flex-direction: row; align-items: center; margin-bottom: 0; color: var(--muted); font-size: .85rem; }
/* Case, compteur et bouton à la hauteur des champs (retour de l'utilisateur : ils remontaient au niveau des libellés). */
.building-filters label.checkbox, .building-filters p, .building-filters .btn { align-self: flex-end; min-height: 36px; }
.building-filters p { display: flex; align-items: center; }
.building-filters select, .building-filters input[type="search"] { min-height: 36px; box-sizing: border-box; }
.building-filters input[type="search"] { min-width: 200px; }
.building-filters p { margin: 0; }
.cards > [hidden] { display: none; }

/* Liste compacte des bâtiments au tableau de bord (spec sprint 50 §3). */
.overview-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.overview-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.overview-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.overview-figures { grid-column: 1; font-size: .85rem; }
.overview-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.overview-actions form { margin: 0; }
.small-link { font-size: .8rem; font-family: var(--font); font-style: normal; margin-left: 8px; }
@media (max-width: 600px) {
    .overview-row { grid-template-columns: 1fr; }
    .overview-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
}
/* Onglets de la page « Locaux et bâtiments » (spec sprint 50 §2). */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--neon); }
