/* ---------------------------------------------------------------------------
   Styles des panneaux de données : hero, tableaux, jauges, cartes de livret,
   listes de la colonne latérale. Les couleurs viennent de tokens.css.
--------------------------------------------------------------------------- */

/* Classes d'actif : la teinte suit l'entité, jamais son rang. */
.c-equity        { background: var(--series-1); }
.c-fixed_income  { background: var(--series-3); }
.c-real_estate   { background: var(--series-2); }
.c-alternative   { background: var(--series-6); }
.c-commodity     { background: var(--series-7); }
.c-crypto        { background: var(--series-5); }
.c-cash          { background: var(--series-4); }

.pos { color: var(--positive-500); }
.neg { color: var(--negative-500); }

/* --- Bloc hero : gros chiffre + statistiques ------------------------------- */

.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-5) var(--sp-6);
    min-width: 0;
    flex: 1 1 300px;
}

.hero-stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: var(--ls-tight);
    color: var(--text-strong);
    white-space: nowrap;
}
.stat-sub { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }

/* --- Graphiques SVG ---------------------------------------------------------- */

.chart { width: 100%; height: auto; display: block; overflow: visible; margin-bottom: var(--sp-3); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-faint); font-size: 11px; font-family: var(--font-mono); }
.chart .line-mark { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.chart-caption {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    padding-bottom: var(--sp-8);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-wide);
    color: var(--text-faint);
}

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.9rem; font-size: var(--text-xs); color: var(--text-faint); font-family: var(--font-mono); }
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* --- Titre de section -------------------------------------------------------- */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-8) 0 var(--sp-4);
}
.section-head h2 { font-size: var(--text-xl); white-space: nowrap; }

/* --- Tableaux ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; min-width: 640px; border-collapse: collapse; }

table.data th {
    text-align: left;
    padding: 0 var(--sp-3) var(--sp-2) 0;
    border-bottom: 1px solid var(--border-default);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-caps);
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-faint);
    white-space: nowrap;
}
table.data th.accent-col { color: var(--brand); }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text-strong); }

table.data td {
    padding: var(--sp-3);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    font-size: var(--text-sm);
    color: var(--text-body);
}
table.data td:first-child { padding-left: 0; }
table.data td:last-child { padding-right: 0; }

table.data tbody tr:hover { background: var(--bg-surface); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); }

.cell-name { display: flex; align-items: center; gap: var(--sp-3); }
.cell-bar { width: 3px; height: 26px; border-radius: 2px; flex: 0 0 auto; }
.cell-lines { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-title { font-size: var(--text-sm); color: var(--text-strong); font-weight: 500; white-space: nowrap; }
.cell-sub { font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-faint); }

.row-excluded { opacity: 0.55; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    white-space: nowrap;
}
.chip-caution { background: var(--caution-bg); color: var(--caution-500); }
.chip-muted { background: var(--bg-surface); border: 1px solid var(--border-default); color: var(--text-muted); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.5rem; vertical-align: baseline; }

.empty { color: var(--text-faint); font-size: var(--text-sm); padding: var(--sp-6) 0; text-align: center; }

/* --- Bandeau d'alerte -------------------------------------------------------- */

.alert-link { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: var(--ls-wide); text-transform: uppercase; flex: 0 0 auto; }

/* --- Cartes de livret -------------------------------------------------------- */

.livret-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--sp-3);
}

.livret-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}
.livret-card .card-value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: var(--ls-tight);
    color: var(--text-strong);
    white-space: nowrap;
}
.card-delete {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-2);
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: var(--radius-xs);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-standard);
}
.livret-card:hover .card-delete { opacity: 1; }
.card-delete:hover { color: var(--negative-500); background: var(--negative-bg); }

.livret-add-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-caps);
    text-transform: uppercase;
}
.livret-add-card:hover { border-color: var(--brand); color: var(--brand); }

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: center;
    margin-top: var(--sp-4);
}
.inline-form input {
    height: var(--control-md);
    padding: 0 var(--sp-4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    outline: none;
}
.inline-form input:focus { border-color: var(--brand); }

/* --- Colonne latérale : répartition, enveloppes, jauge, immobilier --------- */

.class-bar { display: flex; height: 10px; gap: 2px; margin-bottom: var(--sp-4); }
.class-bar span { border-radius: 2px; }

.class-legend { display: flex; flex-direction: column; gap: var(--sp-2); }
.class-legend-row {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
}
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.class-legend-row .legend-label { font-size: var(--text-sm); color: var(--text-body); }
.class-legend-row .legend-value { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

.envelope-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.envelope-row { display: flex; flex-direction: column; gap: 5px; }
.envelope-row .envelope-top { display: flex; justify-content: space-between; gap: var(--sp-3); }
.envelope-row .envelope-name { font-size: var(--text-sm); color: var(--text-body); }
.envelope-row .envelope-amount { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.envelope-track { height: 4px; border-radius: var(--radius-pill); background: var(--bg-sunken); }
.envelope-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent); }

/* --- Jauge (couverture du lombard) ------------------------------------------ */

.gauge-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}
.gauge-badge.ok { background: var(--positive-bg); color: var(--positive-500); }
.gauge-badge.warn { background: var(--caution-bg); color: var(--caution-500); }
.gauge-badge.danger { background: var(--negative-bg); color: var(--negative-500); }

.gauge-value-row { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.gauge-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: var(--ls-tight);
    line-height: var(--lh-tight);
    color: var(--text-strong);
}
.gauge-value-unit { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }

.gauge-track {
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-sunken);
    position: relative;
    margin-bottom: 6px;
}
.gauge-fill { display: block; height: 100%; border-radius: var(--radius-pill); }
.gauge-ok      { background: var(--positive-500); }
.gauge-warn    { background: var(--caution-500); }
.gauge-danger  { background: var(--negative-500); }

.gauge-mark { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text-muted); }

.gauge-scale { position: relative; height: 16px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }
.gauge-scale span { position: absolute; white-space: nowrap; transform: translateX(-50%); }
.gauge-scale span:first-child { transform: none; }
.gauge-scale span:last-child { right: 0; left: auto !important; transform: none; }

.gauge-note { margin: var(--sp-3) 0 0; font-size: var(--text-xs); color: var(--text-muted); line-height: var(--lh-normal); }

/* --- Immobilier & passif / charges récurrentes (listes compactes) ---------- */

.re-list { display: flex; flex-direction: column; }
.re-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}
.re-row:first-child { padding-top: 0; }
.re-row:last-child { border-bottom: none; padding-bottom: 0; }
.re-row-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.re-row-label .re-name { font-size: var(--text-sm); color: var(--text-strong); }
.re-row-label .re-sub { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }
.re-row-value { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-strong); white-space: nowrap; }
.re-row-value.neg { color: var(--negative-500); }
.re-row .card-delete { position: static; opacity: 0; margin-left: var(--sp-2); }
.re-row:hover .card-delete { opacity: 1; }
.re-row-edit { cursor: pointer; }
.re-row-edit:hover .re-name,
.re-row-edit:focus-visible .re-name { color: var(--accent); }
.re-row-edit:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.rail-form { display: flex; flex-direction: column; gap: var(--sp-2); }
/* Le libellé identifie la ligne : en modification, il se lit mais ne s'édite pas. */
.rail-form input[readonly] {
    color: var(--text-faint);
    border-style: dashed;
    cursor: default;
}
.rail-form input { width: 100%; }
.rail-form .btn-outline { width: 100%; justify-content: center; }

.rail-add {
    display: grid;
    place-items: center;
    align-self: center;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    line-height: 1;
}
.rail-add:hover { border-color: var(--brand); color: var(--brand); }

/* --- Bandeaux d'alerte / notices -------------------------------------------- */

.notice { border-radius: var(--radius-md); padding: 0.85rem 1.1rem; margin-bottom: var(--sp-4); font-size: var(--text-sm); line-height: var(--lh-normal); border: 1px solid; }
.notice-warn { background: var(--caution-bg); border-color: var(--caution-500); color: var(--caution-500); }
.notice ul { margin: 0.4rem 0 0 1.1rem; }

/* --- File de relecture (à classer) ------------------------------------------ */

.review-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.review-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}
.review-date { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }
.review-label { font-size: var(--text-sm); color: var(--text-strong); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-amount { font-family: var(--font-mono); font-size: var(--text-md); color: var(--text-strong); white-space: nowrap; }
.review-actions { display: flex; gap: var(--sp-2); flex-wrap: nowrap; }

.chip-btn {
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    cursor: pointer;
}
.chip-btn:hover { border-color: var(--brand); color: var(--brand); }

/* --- Actions / statut -------------------------------------------------------- */

.status-msg { font-size: var(--text-xs); color: var(--text-faint); margin-top: var(--sp-3); display: block; min-height: 1em; }

/* --- Panneau générique (fiches SCPI, imports…) ------------------------------ */

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.panel-head h3 { font-size: var(--text-lg); }
