/* WorkItUp - stile ripreso da EndItUp: sempre chiaro, accento blu, gradiente blu-viola, bordi leggeri, angoli morbidi. */
:root {
    color-scheme: light;
    --bg: #ffffff;
    --page: #f5f7ff;
    --surface: #f5f7ff;
    --fg: #0c1b31;
    --muted: #4b5568;
    --accent: #2253ff;
    --accent-ink: #1638c4;
    --tint: #eef1ff;
    --violet: #7530ed;
    --sky: #1695fb;
    --night: #0c1b31;
    --border: #dce2f5;
    --ok: #1f7a4d;
    --ok-bg: #e7f5ee;
    --warn: #8a5a00;
    --warn-bg: #fff4dc;
    --danger: #b3261e;
    --danger-bg: #fdecea;
    --brand-gradient: linear-gradient(120deg, #1695fb 0%, #294bf8 47%, #7530ed 100%);
    --nav-width: 17rem;
    --topbar-height: 3.5rem;
}

* { box-sizing: border-box; }

html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.5; }

body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--fg); }
body.nav-open { overflow: hidden; }

a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { margin: 0.25rem 0 1.5rem; }
.eyebrow { margin: 0 0 0.15rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 0.5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* --- Barra in alto ------------------------------------------------------- */

.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 0.75rem;
    height: var(--topbar-height); padding: 0 1rem;
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--fg); min-height: 2.75rem; }
.brand img { display: block; border-radius: 8px; }
.brand-text { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-text b { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.5rem; height: 2.5rem; border: 0; border-radius: 8px;
    background: transparent; color: var(--fg); font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.icon-button:hover { background: var(--surface); }

.user-menu { position: relative; margin-left: auto; }
.user-menu > summary { list-style: none; cursor: pointer; border-radius: 999px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; border-radius: 999px;
    background: var(--brand-gradient); color: #fff; font-size: 0.8rem; font-weight: 700;
}
.user-menu-panel {
    position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 13rem; z-index: 50;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgb(12 27 49 / 0.12);
}
.user-menu-who { display: flex; flex-direction: column; margin: 0; padding: 0.7rem 0.9rem; }

/* --- Impianto: menu laterale + contenuto --------------------------------- */

.shell { flex: 1; display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); align-items: start; }

.sidenav {
    position: sticky; top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height)); overflow-y: auto;
    padding: 0.75rem; background: var(--bg); border-right: 1px solid var(--border);
}
.sidenav-head { display: none; }
.sidenav a, .sidenav summary { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: 8px; color: var(--fg); text-decoration: none; }
.sidenav a:hover, .sidenav summary:hover { background: var(--surface); }
.sidenav a.is-active { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); font-weight: 600; }
.sidenav .icon { flex: none; color: var(--accent); }
.sidenav-group summary { list-style: none; cursor: pointer; font-weight: 600; }
.sidenav-group summary::-webkit-details-marker { display: none; }
.sidenav-group summary::after { content: ""; margin-left: auto; width: 0.45rem; height: 0.45rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.12s; }
.sidenav-group[open] summary::after { transform: rotate(45deg); }
.sidenav-group a { padding-left: 2.35rem; font-size: 0.93rem; }
.sidenav-home { font-weight: 600; margin-bottom: 0.25rem; }

main { min-width: 0; padding: 1.5rem 2rem 3rem; background: var(--page); min-height: calc(100vh - var(--topbar-height)); }

.nav-toggle, .scrim { display: none; }

@media (max-width: 1023px) {
    .shell { display: block; }
    .nav-toggle { display: inline-flex; }
    .user-menu { margin-left: auto; }
    .sidenav {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 70; width: min(20rem, 86vw); height: 100dvh;
        transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: 0 0 40px rgb(12 27 49 / 0.2);
    }
    body.nav-open .sidenav { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 60; background: rgb(12 27 49 / 0.4); }
    .sidenav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0.25rem 0.5rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
    main { padding: 1.25rem 1rem 2.5rem; }
}

@media (prefers-reduced-motion: reduce) { .sidenav { transition: none; } }

/* --- Testata di pagina, pulsanti ----------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.5rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; }
.page-desc { margin: 0 0 1rem; }

.button, .link-button { font: inherit; cursor: pointer; }
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    min-height: 2.5rem; padding: 0.5rem 1rem; border: 1px solid var(--accent); border-radius: 8px;
    background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
}
.button:hover { filter: brightness(1.08); }
.button:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }
.link-button { background: none; border: 0; padding: 0; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.button-quiet { background: transparent; border-color: var(--border); color: var(--fg); font-weight: 500; }
.button-quiet:hover { background: var(--surface); filter: none; }
.button svg { flex: none; }
.button-danger { background: var(--danger); border-color: var(--danger); }
.button-danger-quiet { background: transparent; border-color: transparent; color: var(--danger); font-weight: 500; }
.button-danger-quiet:hover { background: var(--danger-bg); filter: none; }
.button.is-busy { position: relative; color: transparent; pointer-events: none; }
.button.is-busy::after { content: ""; position: absolute; width: 1rem; height: 1rem; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.button-quiet.is-busy::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .button.is-busy::after { animation-duration: 2s; } }

/* --- Schede, home -------------------------------------------------------- */

.card { border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; background: var(--bg); }
.module-grid { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.module-title { display: flex; align-items: center; gap: 0.6rem; font-size: 1.05rem; margin-bottom: 0.6rem; }
.module-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 10px; background: var(--brand-gradient); color: #fff; }
.module-icon .icon { color: #fff; }
.module-links { list-style: none; margin: 0; padding: 0; }
.module-links li { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0; border-top: 1px solid var(--border); }
.module-links a { text-decoration: none; padding: 0.15rem 0; flex: 1; }
.module-links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* --- Badge, avvisi ------------------------------------------------------- */

.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-ink); }

.alert, .notice { padding: 0.7rem 1rem; border-radius: 8px; margin: 0 0 1rem; }
.alert { background: var(--danger-bg); color: var(--danger); }
.notice { background: var(--ok-bg); color: var(--ok); }
.grid-notice { background: var(--warn-bg); color: var(--warn); }

/* --- Moduli -------------------------------------------------------------- */

label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.93rem; }
label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; min-height: 2.5rem; }
.req { color: var(--danger); }

input, select, textarea {
    font: inherit; font-weight: 400; width: 100%; min-height: 2.5rem; padding: 0.5rem 0.7rem;
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg);
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin: 0.25rem 0 0; color: var(--danger); font-size: 0.85rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.9rem 1rem; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }

/* --- Lookup -------------------------------------------------------------- */

.lookup { position: relative; }
.lookup .lookup-input { padding-right: 2.2rem; }
.lookup-clear { position: absolute; right: 0.2rem; top: 0.2rem; width: 2.1rem; height: 2.1rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.lookup-clear:hover { background: var(--surface); }
.suggestions {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 30; max-height: 15rem; overflow-y: auto;
    margin: 0.25rem 0 0; padding: 0.25rem; list-style: none;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgb(12 27 49 / 0.14); font-weight: 400;
}
.suggestions li { display: flex; flex-direction: column; padding: 0.45rem 0.6rem; border-radius: 6px; cursor: pointer; }
.suggestions li span { font-size: 0.82rem; color: var(--muted); }
.suggestions li:hover, .suggestions li.active { background: var(--surface); }
.suggestions li.lookup-empty { cursor: default; color: var(--muted); }
.suggestions li.lookup-more { color: var(--accent); font-weight: 600; text-align: center; }

/* --- Tabelle (DataTables) ------------------------------------------------ */

.grid-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem; overflow-x: auto; }
.dt-container { font-size: 0.93rem; }
.dt-container .dt-layout-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin: 0.4rem 0; }
.dt-container .dt-layout-row.dt-layout-table { display: block; margin: 0; }
.dt-container .dt-layout-cell { display: flex; align-items: center; gap: 0.5rem; }
.dt-container .dt-search, .dt-container .dt-length { display: flex; align-items: center; gap: 0.5rem; }
.dt-container .dt-search label, .dt-container .dt-length label { display: inline; font-weight: 400; }
.dt-container .dt-search input { width: 15rem; max-width: 100%; margin: 0; }
.dt-container .dt-length select { width: auto; min-width: 4.5rem; }
.dt-container .dt-info { color: var(--muted); font-size: 0.875rem; }
.dt-container .dt-paging nav { display: flex; gap: 0.25rem; }
.dt-container .dt-paging-button { min-width: 2.25rem; min-height: 2.25rem; padding: 0 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; cursor: pointer; }
.dt-container .dt-paging-button:hover:not(.disabled) { background: var(--surface); }
.dt-container .dt-paging-button.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.dt-container .dt-paging-button.disabled { opacity: 0.45; cursor: default; }
.dt-container .dt-processing { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 0.5rem 1rem; border-radius: 999px; background: var(--fg); color: #fff; font-size: 0.85rem; z-index: 5; }
.dt-container { position: relative; }

table.dt-table { width: 100%; border-collapse: collapse; }
table.dt-table th, table.dt-table td { padding: 0.65rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.dt-table thead th { position: relative; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--bg); user-select: none; }
table.dt-table thead th.dt-orderable-asc, table.dt-table thead th.dt-orderable-desc { cursor: pointer; }
table.dt-table thead th .dt-column-order { display: inline-block; margin-left: 0.35rem; width: 0.6rem; vertical-align: middle; }
table.dt-table thead th .dt-column-order::before { content: "\2195"; color: #aab3cf; font-size: 0.8rem; }
table.dt-table thead th.dt-ordering-asc .dt-column-order::before { content: "\2191"; color: var(--accent); }
table.dt-table thead th.dt-ordering-desc .dt-column-order::before { content: "\2193"; color: var(--accent); }
table.dt-table tbody tr { cursor: pointer; }
table.dt-table tbody tr:hover { background: var(--surface); }
table.dt-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.dt-table tbody tr.is-inactive td { color: var(--muted); }
table.dt-table tbody tr.is-inactive td:first-child::after { content: "Disattivato"; margin-left: 0.5rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--danger-bg); color: var(--danger); }
table.dt-table td.num, table.dt-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt-table td.dt-empty { text-align: center; color: var(--muted); padding: 2rem 1rem; cursor: default; }
.row-link { color: var(--fg); font-weight: 600; text-decoration: none; }
tr:hover .row-link { color: var(--accent); }

.grid-tools { margin-bottom: 0.75rem; }
.grid-sort { flex-direction: row; align-items: center; gap: 0.6rem; font-weight: 500; }
.grid-sort select { width: auto; flex: 1; }

/* Sotto i 760 px le righe diventano schede, ma la tabella resta DataTables: paginazione, ricerca e ordinamento restano attivi */
@media (max-width: 760px) {
    .grid-tools { display: block; }
    .grid-wrap { padding: 0.5rem; border: 0; background: transparent; overflow: visible; }
    .dt-container .dt-search, .dt-container .dt-search input { width: 100%; }
    .dt-container .dt-layout-row { justify-content: flex-start; }
    .dt-container .dt-layout-cell { flex-wrap: wrap; }
    table.dt-cards, table.dt-cards tbody, table.dt-cards tr, table.dt-cards td { display: block; width: 100%; }
    table.dt-cards thead { display: none; }
    table.dt-cards tbody tr { margin: 0 0 0.75rem; padding: 0.4rem 0.9rem; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
    table.dt-cards tbody tr:hover { background: var(--bg); }
    table.dt-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px dashed var(--border); text-align: right !important; }
    table.dt-cards td:empty { display: none; }
    table.dt-cards td:last-child { border-bottom: 0; }
    table.dt-cards td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--muted); font-size: 0.78rem; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: 0.03em; }
    table.dt-cards td:first-child { font-size: 1.02rem; border-bottom: 1px solid var(--border); padding-bottom: 0.55rem; margin-bottom: 0.15rem; }
    table.dt-cards td.dt-empty { display: block; text-align: center !important; }
    table.dt-cards td.dt-empty::before { content: none; }
}
@media (min-width: 761px) { .grid-tools { display: none !important; } }

/* --- Modal --------------------------------------------------------------- */

dialog.modal {
    width: min(48rem, calc(100% - 2rem)); max-height: min(92vh, 52rem); padding: 0; border: 0; border-radius: 16px;
    background: var(--bg); color: var(--fg); box-shadow: 0 24px 80px rgb(12 27 49 / 0.35); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgb(12 27 49 / 0.45); }
.modal-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem 0.9rem; border-bottom: 1px solid var(--border); }
.modal-form .alert { margin: 0.9rem 1.25rem 0; }
.modal-form .form-grid { padding: 1.1rem 1.25rem; overflow-y: auto; flex: 1; align-content: start; }
.modal-foot { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.8rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface); }
.modal-foot-left, .modal-foot-right { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.confirm-bar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; padding: 0.8rem 1.25rem; background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.modal-loading { padding: 2rem 1.25rem; }
@media (max-width: 640px) {
    dialog.modal { width: 100%; max-width: 100%; max-height: 96dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
    .modal-foot-right { width: 100%; }
    .modal-foot-right .button { flex: 1; }
}

/* --- Avvisi, caricamento ------------------------------------------------- */

.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(24rem, calc(100% - 2rem)); }
.toast { padding: 0.7rem 1rem; border-radius: 10px; background: var(--fg); color: #fff; box-shadow: 0 8px 24px rgb(12 27 49 / 0.25); animation: toast-in 0.18s ease; }
.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.top-loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 120; background: var(--brand-gradient); background-size: 200% 100%; animation: shimmer 1s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Piè di pagina ------------------------------------------------------- */

.footer { border-top: 1px solid #e3e7f5; background: #f5f7ff; color: #5c6270; font-size: 0.875rem; }
.footer-inner { max-width: 80rem; margin: 0 auto; padding: 1.1rem 2rem; }
.footer-brand { display: flex; align-items: center; gap: 0.75rem; }
.footer-brand img { flex: none; border-radius: 7px; }
.footer-brand p { margin: 0; line-height: 1.4; }
.footer-brand strong { color: var(--fg); }
.footer-brand span { display: block; }
@media (max-width: 640px) { .footer-inner { padding: 1rem; } }

/* --- Dashboard ----------------------------------------------------------- */

/* Colori dei grafici: palette validata (blu, arancio, acqua), rampa ordinale blu per gli stati di avanzamento, colori di stato riservati */
.dash, .dv-tip {
    --dv-s1: #2a78d6; --dv-s2: #eb6834; --dv-s3: #1baf7a;
    --dv-seq1: #86b6ef; --dv-seq2: #2a78d6; --dv-seq3: #0d366b;
    --dv-good: #0ca30c; --dv-warning: #fab219; --dv-critical: #d03b3b; --dv-neutral: #9aa6c4;
    --dv-grid: #e6eaf6;
}

.section-title { margin: 2rem 0 0.25rem; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 0.75rem; margin: 0 0 1rem; }
.kpi {
    display: flex; flex-direction: column; gap: 0.1rem; padding: 0.85rem 1rem; text-decoration: none; color: var(--fg);
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px; border-left-width: 4px;
}
.kpi:hover { background: var(--surface); }
.kpi-label { font-size: 0.85rem; color: var(--muted); }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.kpi-hint { font-size: 0.82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.kpi-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--muted); }
.kpi.tone-ok { border-left-color: var(--dv-good); }
.kpi.tone-ok .kpi-icon { background: var(--ok); }
.kpi.tone-warn { border-left-color: var(--dv-warning); }
.kpi.tone-warn .kpi-icon { background: var(--warn); }
.kpi.tone-bad { border-left-color: var(--dv-critical); }
.kpi.tone-bad .kpi-icon { background: var(--danger); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 27rem), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.chart-card { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.chart-title { font-size: 1.05rem; margin: 0; }
.chart-title a { color: var(--fg); text-decoration: none; }
.chart-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.chart-sub { margin: 0.1rem 0 0; }
.chart-empty { margin: 1.5rem 0; text-align: center; }
.chart-plot { min-width: 0; }
.button-small { min-height: 2rem; padding: 0.15rem 0.7rem; font-size: 0.85rem; }

.dv-svg { display: block; width: 100%; height: auto; overflow: visible; }
.dv-grid { stroke: var(--dv-grid); stroke-width: 1; }
.dv-text { font-size: 11.5px; fill: var(--muted); font-family: inherit; }
.dv-cat { fill: var(--fg); font-size: 12px; }
.dv-value { fill: var(--fg); font-weight: 600; }
.dv-onfill { fill: #fff; font-weight: 600; }
.dv-ink { fill: var(--fg); font-weight: 600; }
.dv-mark { stroke: none; }
.dv-hit { fill: transparent; outline: none; }
.dv-hit.is-active, .dv-hit:focus-visible { fill: color-mix(in srgb, var(--accent) 7%, transparent); }
.dv-hit:focus-visible { stroke: var(--accent); stroke-width: 1.5; }

.dv-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0; padding: 0; list-style: none; font-size: 0.85rem; }
.dv-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.dv-swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; flex: none; }
.dv-swatch-none { background: transparent; }

.dv-tip {
    position: absolute; z-index: 60; pointer-events: none; min-width: 9rem; max-width: 18rem; padding: 0.55rem 0.7rem;
    background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgb(12 27 49 / 0.16); font-size: 0.85rem;
}
.dv-tip-title { display: block; margin-bottom: 0.25rem; }
.dv-tip-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.1rem 0; }
.dv-tip-label { flex: 1; color: var(--muted); }
.dv-tip-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.dv-tip-total { border-top: 1px solid var(--border); margin-top: 0.2rem; padding-top: 0.25rem; }

.chart-table { overflow-x: auto; }
.dv-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dv-table th, .dv-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.dv-table thead th { color: var(--muted); font-weight: 600; }
.dv-table .dv-num { text-align: right; font-variant-numeric: tabular-nums; }

.is-loading { pointer-events: none; }
.kpi.is-loading .kpi-label, .kpi.is-loading .kpi-value, .chart-skeleton { background: linear-gradient(90deg, var(--surface), #e9edfb, var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 6px; color: transparent; }
.kpi.is-loading .kpi-label { width: 60%; }
.kpi.is-loading .kpi-value { width: 35%; margin-top: 0.3rem; }
.chart-skeleton { height: 12rem; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .kpi.is-loading .kpi-label, .kpi.is-loading .kpi-value, .chart-skeleton { animation: none; } }
