/* Design system monocromatico ispirato a shadcn/ui (New York), vedi docs/DIRETTIVE-GRAFICHE.md */

:root {
    --background: 0 0% 100%;
    --foreground: 0 0% 9%;
    --card: 0 0% 100%;
    --card-foreground: 0 0% 9%;
    --muted: 0 0% 96%;
    --muted-foreground: 0 0% 45%;
    --border: 0 0% 90%;
    --input: 0 0% 90%;
    --primary: 0 0% 9%;
    --primary-foreground: 0 0% 100%;
    --secondary: 0 0% 96%;
    --secondary-foreground: 0 0% 9%;
    --ring: 0 0% 9%;
    --accent-warning: 0 65% 45%;
    --accent-warning-bg: 0 65% 96%;
    --chart-1: 217 91% 55%;
    --chart-2: 158 64% 40%;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

[data-theme="dark"] {
    --background: 0 0% 9%;
    --foreground: 0 0% 96%;
    --card: 0 0% 12%;
    --card-foreground: 0 0% 96%;
    --muted: 0 0% 16%;
    --muted-foreground: 0 0% 63%;
    --border: 0 0% 22%;
    --input: 0 0% 22%;
    --primary: 0 0% 96%;
    --primary-foreground: 0 0% 9%;
    --secondary: 0 0% 18%;
    --secondary-foreground: 0 0% 96%;
    --ring: 0 0% 80%;
    --accent-warning: 0 70% 60%;
    --accent-warning-bg: 0 40% 18%;
    --chart-1: 217 91% 65%;
    --chart-2: 158 64% 50%;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 150ms ease, color 150ms ease;
}

h1, h2, h3, p {
    margin: 0;
}

a {
    color: inherit;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Layout */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.app-header__brand {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.app-header__brand strong {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.app-header__brand span {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Card */

.card {
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1.25rem;
}

.card__title {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.card__description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 1rem;
}

/* Stat card */

.stat-card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.stat-card__label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stat-card__hint {
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

/* Button */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.btn--primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn--primary:hover {
    opacity: 0.88;
}

.btn--outline {
    background-color: transparent;
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

.btn--outline:hover {
    background-color: hsl(var(--muted));
}

.btn--ghost {
    background-color: transparent;
    color: hsl(var(--foreground));
}

.btn--ghost:hover {
    background-color: hsl(var(--muted));
}

.btn--sm {
    height: 1.875rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
}

.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Badge */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 500;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
}

.badge--warning {
    color: hsl(var(--accent-warning));
    border-color: hsl(var(--accent-warning) / 0.35);
    background-color: hsl(var(--accent-warning-bg));
}

/* Dropzone */

.dropzone {
    border: 1px dashed hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.25rem;
    text-align: center;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.dropzone--dragover {
    border-color: hsl(var(--foreground));
    background-color: hsl(var(--muted));
}

.dropzone--disabled {
    opacity: 0.55;
}

.dropzone__icon {
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
}

.dropzone__title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.dropzone__hint {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 1rem;
}

.dropzone__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Collapsible (details/summary) */

.collapsible {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    background-color: hsl(var(--card));
    padding: 0;
}

.collapsible__summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    user-select: none;
}

.collapsible__summary::-webkit-details-marker {
    display: none;
}

.collapsible__summary .section-title {
    margin-bottom: 0;
}

.collapsible__chevron {
    color: hsl(var(--muted-foreground));
    transition: transform 150ms ease;
    flex-shrink: 0;
}

.collapsible[open] .collapsible__chevron {
    transform: rotate(180deg);
}

.collapsible__body {
    padding: 0 1.25rem 1.25rem;
}

/* Bar (mini grafico a barre dentro le celle tabella) */

.bar-cell {
    position: relative;
}

.bar-cell__fill {
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    right: 0.5rem;
    background-color: hsl(var(--chart-1) / 0.16);
    border: 1px solid hsl(var(--chart-1) / 0.35);
    border-radius: 4px;
    z-index: 0;
}

.bar-cell__value {
    position: relative;
    z-index: 1;
}

/* Table */

.table-wrap {
    overflow-x: auto;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead th {
    text-align: left;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid hsl(var(--border));
    white-space: nowrap;
}

th.sortable-th {
    cursor: pointer;
    user-select: none;
}

th.sortable-th:hover {
    color: hsl(var(--foreground));
}

th.sortable-th::after {
    content: "";
    display: inline-block;
    width: 0.5rem;
    margin-left: 0.25rem;
    opacity: 0.35;
}

th.sortable-th[data-sort-dir="asc"]::after {
    content: "↑";
    opacity: 1;
}

th.sortable-th[data-sort-dir="desc"]::after {
    content: "↓";
    opacity: 1;
}

tbody td {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid hsl(var(--border));
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: hsl(var(--muted) / 0.5);
}

td.num, th.num {
    text-align: right;
}

/* Alert */

.alert {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
}

.alert--error {
    border-color: hsl(var(--accent-warning) / 0.4);
    background-color: hsl(var(--accent-warning-bg));
    color: hsl(var(--accent-warning));
}

/* Empty state */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: hsl(var(--muted-foreground));
}

.empty-state__title {
    font-size: 0.9375rem;
    color: hsl(var(--foreground));
    font-weight: 500;
    margin-bottom: 0.25rem;
}

/* Footer note */

.footnote {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}
