:root {
  --bg: #F3F5F3; --surface: #FFFFFF; --surface-2: #F7F9F8; --ink: #16211E; --muted: #5B6B66; --line: #DCE3E0;
  --accent: #0B6E69; --accent-ink: #FFFFFF; --accent-soft: #DDEFED;
  --good: #1D7A3E; --good-soft: #E1F1E5; --warn: #A86200; --warn-soft: #FBEBD2; --bad: #B3261E; --bad-soft: #F8E0DE;
  --radius: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1614; --surface: #16201D; --surface-2: #1A2522; --ink: #E4ECE9; --muted: #95A6A0; --line: #27332F;
    --accent: #4FC2B9; --accent-ink: #0F1614; --accent-soft: #16332F;
    --good: #6DD08E; --good-soft: #173020; --warn: #F0B35A; --warn-soft: #352812; --bad: #F28B82; --bad-soft: #3A1B19;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1 { font-size: clamp(22px, 3vw, 28px); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 16px; margin: 26px 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* barra superiore */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.tabs button { font: inherit; background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.logout { display: flex; align-items: center; gap: 8px; margin: 0; }

/* layout */
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 20px 60px; }
@media (max-width: 600px) { .wrap, .topbar-inner { padding-left: 16px; padding-right: 16px; } }
.panel { display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; flex-direction: column; gap: 4px; max-width: 80ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid-form { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
.inline-form { display: flex; gap: 10px; align-items: end; }
.grow { flex: 1; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; }

/* campi */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field > legend { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; background: var(--surface-2); }
.chip input { width: auto; }

/* bottoni */
.btn { font: inherit; font-weight: 600; border-radius: 7px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-small { padding: 4px 10px; font-size: 12.5px; }

/* avvisi e pill */
.alert { border-radius: var(--radius); padding: 10px 14px; margin: 0; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-good { background: var(--good-soft); color: var(--good); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; text-transform: uppercase; }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* job in corso */
.output { display: flex; flex-direction: column; gap: 16px; }
.job-status { display: flex; flex-direction: column; gap: 10px; }
.job-status-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; font-size: 12.5px; }
.activity li { display: flex; gap: 8px; min-width: 0; }
.activity .tool { color: var(--accent); font-weight: 600; white-space: nowrap; }
.activity .detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* scheda valutazione */
.eval-head { display: flex; flex-direction: column; gap: 6px; }
.eval-head h2 { margin: 0; font-size: 20px; text-wrap: balance; }
.eval-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .value { font-family: var(--mono); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.good .value { color: var(--good); }
.kpi.bad .value { color: var(--bad); }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .cols-3 { grid-template-columns: 1fr; } }
.list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.footer-note { font-size: 12px; color: var(--muted); }

/* tabelle */
.table-box { padding: 0; overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.table th.num { text-align: right; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: var(--surface-2); }
.results { min-width: 1080px; }
.results .where { min-width: 230px; }
.results .where b { display: block; }
.results .notes { color: var(--muted); font-size: 12.5px; min-width: 260px; max-width: 40ch; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.toolbar .field { flex-direction: row; align-items: center; gap: 8px; }
.toolbar select { width: auto; }
details.card summary { cursor: pointer; font-weight: 700; }
details.card ul { margin: 10px 0 0; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
