/* Master of Yield — design system condiviso
   Palette "Ledger": verde-petrolio come colore della sostenibilità del reddito,
   rosso riservato esclusivamente ai segnali di erosione reale. */

:root {
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface-sunken: #F4F4F1;
    --border: #EDECE8;
    --border-strong: #DCDBD5;
    --text-primary: #16211E;
    --text-secondary: #5A635F;
    --text-muted: #8B938F;
    --accent: #0F5C4D;
    --accent-hover: #0A4539;
    --accent-soft: #E6F2EF;
    --positive: #0F5C4D;
    --negative: #B3261E;
    --negative-soft: #FBEAE8;
    --warning: #B26B00;
    --warning-soft: #FDF3E3;
    --row-hover: #F2F4F3;
    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 2px rgba(22, 33, 30, 0.05);
    --shadow-md: 0 4px 16px rgba(22, 33, 30, 0.08);
}

[data-theme="dark"] {
    --bg: #0F1419;
    --surface: #161C23;
    --surface-sunken: #11161C;
    --border: #1F262E;
    --border-strong: #3E4750;
    --text-primary: #E8EDEB;
    --text-secondary: #A8B2AE;
    --text-muted: #8A948F;
    --accent: #2F7D69;
    --accent-hover: #3A8F78;
    --accent-soft: #10312A;
    --positive: #4FA58C;
    --negative: #F87171;
    --negative-soft: #2C1614;
    --warning: #FBBF24;
    --warning-soft: #2E2312;
    --row-hover: #1D252D;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    margin: 0;
    padding: 1.5rem;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* I numeri allineati in colonna sono metà del prodotto: cifre a larghezza fissa
   così le percentuali non "ballano" da una riga all'altra. */
table, .stat-value, .dg-table {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
}

h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-top: 2rem;
}

.subtitle, p.subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
    max-width: 780px;
    margin-bottom: 1.5rem;
}

/* Cards / stat boxes */
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Tables */
table {
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
th {
    background: var(--surface-sunken);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border-strong);
}
td {
    border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--row-hover); }

/* Chart / content cards */
.chart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

/* Links */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Utility colors already used across pages */
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.no-data { color: var(--text-muted); font-style: italic; }

/* Badge provider: sostituisce il nome esteso nella tabella principale,
   per risparmiare spazio senza perdere il riconoscimento a colpo d'occhio. */
.provider-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 26px;
    border-radius: var(--radius-sm);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: var(--surface-sunken);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Quality Score: badge pieno, il numero sintetico più importante della tabella */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.score-high   { background: var(--accent-soft);   color: var(--accent); }
.score-mid    { background: var(--warning-soft);  color: var(--warning); }
.score-low    { background: var(--negative-soft); color: var(--negative); }

.disclaimer {
    margin: 2.5rem auto 1.5rem;
    padding: 1.2rem 1.4rem;
    max-width: 900px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.disclaimer p {
    font-size: 0.74rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 0.7rem 0;
}
.disclaimer p:last-child { margin-bottom: 0; }
.disclaimer b { color: var(--text-primary); }

/* =====================================================================
   Smartphone e tablet
   ===================================================================== */
@media (max-width: 900px) {
    body { padding: 0.9rem; }
}
@media (max-width: 720px) {
    .sd-head { margin-bottom: 1.2rem; }
    .sd-head h1, .pf-head h1 { font-size: 1.55rem; }
    .sd-section { padding: 1rem 0.9rem; border-radius: 10px; }
    .sc-kpis, .sd-account { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .sd-tile { padding: 0.8rem 0.9rem; }
    .sd-tile-value { font-size: 1.2rem; }
    .sc-tools { flex-direction: column; align-items: stretch; }
    .sc-search { min-width: 0; width: 100%; }
    .sc-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.2rem; max-width: 100%; }
    .hm-tools-right { min-width: 0; max-width: 100%; }
    .sd-two { grid-template-columns: minmax(0, 1fr) !important; }
    .sd-two > *, .sd-page > * { min-width: 0; }
    .sc-chips button { flex-shrink: 0; }
    .sd-table { font-size: 0.8rem; }
    /* Sul telefono, in verticale, la prima colonna mostra solo il ticker: il nome per esteso
       è nella scheda del fondo, che si apre toccando il ticker. */
    .sd-table td:first-child .sd-fund,
    .sd-table td:first-child .hm-issuer,
    .sd-table td:first-child .sc-issuer-link { display: none; }
    .sd-table th:first-child, .sd-table td:first-child { max-width: 5.5rem; padding-right: 0.5rem; }
    .sd-table td .sd-fund, .sc-table td .sd-fund { min-width: 0; }
    /* la prima colonna (il fondo) resta ferma mentre la tabella scorre di lato */
    .sd-table th:first-child, .sd-table td:first-child {
        position: sticky; left: 0; z-index: 2; background: var(--surface);
        box-shadow: 3px 0 6px -3px rgba(0, 0, 0, 0.15);
    }
    .hide-sm { display: none !important; }
    .sd-notes { font-size: 0.75rem; }
    .disclaimer { padding: 1rem; }
}
