/* Forfettario 2026 — app shell and components. Grey palette, square corners, mobile first. */
:root {
  --bg: #f4f4f5; --surface: #ffffff; --surface-2: #fafafa; --line: #e4e4e7; --line-strong: #d4d4d8;
  --text: #18181b; --text-2: #52525b; --text-3: #71717a; --ink: #18181b; --ink-contrast: #ffffff;
  --bar: #a1a1aa; --bar-strong: #3f3f46; --warn: #92400e; --warn-bg: #fef3c7; --danger: #991b1b; --danger-bg: #fee2e2;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  --head-bg: #18181b; --head-text: #fafafa; --side: 264px; color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f0f10; --surface: #18181b; --surface-2: #1f1f23; --line: #2a2a2e; --line-strong: #3f3f46;
  --text: #f4f4f5; --text-2: #a1a1aa; --text-3: #8b8b93; --ink: #f4f4f5; --ink-contrast: #18181b;
  --bar: #52525b; --bar-strong: #d4d4d8; --warn: #fcd34d; --warn-bg: #2a2110; --danger: #fca5a5; --danger-bg: #2a1414;
  --head-bg: #27272a; --head-text: #fafafa; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0f0f10; --surface: #18181b; --surface-2: #1f1f23; --line: #2a2a2e; --line-strong: #3f3f46;
  --text: #f4f4f5; --text-2: #a1a1aa; --text-3: #8b8b93; --ink: #f4f4f5; --ink-contrast: #18181b;
  --bar: #52525b; --bar-strong: #d4d4d8; --warn: #fcd34d; --warn-bg: #2a2110; --danger: #fca5a5; --danger-bg: #2a1414;
  --head-bg: #27272a; --head-text: #fafafa; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: var(--text); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.num, td.n, .kpi b, .res b { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; letter-spacing: -.01em; text-decoration: none; color: var(--text); font-size: 15px; }
.brand span { color: var(--text-3); font-weight: 500; }
.menu-btn { appearance: none; background: none; border: 1px solid var(--line-strong); color: var(--text);
  font: 500 14px var(--font); height: 40px; padding: 0 16px; cursor: pointer; }
.side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, var(--side)); background: var(--surface);
  border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .18s ease;
  overflow-y: auto; padding: 20px 0 32px; }
.side.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); display: none; }
.scrim.open { display: block; }
.side .brand { display: block; padding: 0 20px 18px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.nav-group { padding: 14px 0 4px; }
.nav-group h2 { margin: 0 20px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.nav-group a { display: block; padding: 10px 20px; text-decoration: none; color: var(--text-2); border-left: 2px solid transparent; }
.nav-group a:hover { color: var(--text); background: var(--surface-2); }
.nav-group a[aria-current="page"] { color: var(--text); font-weight: 600; border-left-color: var(--ink); background: var(--surface-2); }
.side-foot { margin: 20px 20px 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }

main { min-width: 0; }
.page { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; }
@media (min-width: 960px) {
  body { display: grid; grid-template-columns: var(--side) 1fr; }
  .topbar, .scrim, .menu-btn { display: none; }
  .side { position: sticky; top: 0; height: 100vh; transform: none; width: var(--side); transition: none; }
  .page { padding: 40px 48px 80px; }
}

/* ---------- typography ---------- */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 0 0 8px; }
h1 { font-size: clamp(24px, 4.2vw, 32px); line-height: 1.2; letter-spacing: -.02em; font-weight: 650; margin: 0 0 10px; }
.lede { color: var(--text-2); font-size: 16px; max-width: 640px; margin: 0 0 28px; }
.page h2 { font-size: 18px; font-weight: 650; letter-spacing: -.01em; margin: 40px 0 10px; }
.page h3 { font-size: 15px; font-weight: 600; margin: 24px 0 6px; }
.meta, .small { color: var(--text-3); font-size: 13px; }
.page p, .page li { max-width: 680px; }

/* ---------- tool layout ---------- */
.tool { display: grid; grid-template-columns: 1fr; border: 1px solid var(--line); background: var(--surface); }
@media (min-width: 760px) { .tool { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.tool > * { padding: 20px; min-width: 0; }
.tool .form { border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .tool .form { border-bottom: 0; border-right: 1px solid var(--line); } }
.field { margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }
.row2 > .field, .row2 > .field:last-child { margin-bottom: 14px; }
label, .label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 5px; letter-spacing: .01em; }
input[type=number], input[type=text], select { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: 14px var(--font); }
input:focus, select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 40px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.check input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--ink); }
.tool .form { container: form / inline-size; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@container form (min-width: 380px) { .row2 { grid-template-columns: 1fr 1fr; } .row2 > .field { display: flex; flex-direction: column; justify-content: flex-end; } }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.res { display: flex; flex-direction: column; }
.res .line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.res .line span { color: var(--text-2); }
.kpi { padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.kpi .label { margin: 0; }
.kpi b { display: block; font-size: 32px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.notice { margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--line-strong); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.notice[data-level="attenzione"] { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.notice[data-level="fuori"] { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.profile-note { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); margin: 14px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 650; background: var(--surface-2); }
/* plain content tables in guides */
.page > table, article table { border: 1px solid var(--line); background: var(--surface); margin: 14px 0; }
@media (max-width: 600px) {
  article table, article thead, article tbody, article tr, article td { display: block; width: 100%; }
  article tr:first-child { display: none; }
  article tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  article td { border: 0; padding: 3px 12px; text-align: left !important; }
  article td:first-child { font-weight: 600; }
}

/* ---------- F24 ---------- */
.f24 { border: 1px solid var(--line-strong); background: var(--surface); margin: 18px 0; container: f24 / inline-size; }
.f24-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 16px;
  background: var(--head-bg); color: var(--head-text); }
.f24-head b { font-size: 15px; }
.f24-sec { padding: 8px 16px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.f24 table td.code { font-family: var(--mono); font-size: 13px; }
@container f24 (max-width: 560px) {
  .f24 thead { display: none; }
  .f24 tr { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-auto-flow: row dense; gap: 2px 12px;
    padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .f24 td { border: 0; padding: 0; }
  .f24 td.code { grid-column: 1; grid-row: 1 / span 3; font-weight: 600; }
  .f24 td.desc { grid-column: 2; grid-row: 1; }
  .f24 td.deb, .f24 td.cred { grid-column: 3; grid-row: 1; font-weight: 600; }
  .f24 td.cred:not(:empty)::after { content: " cr."; font-weight: 400; color: var(--text-3); }
  .f24 td.rif, .f24 td.sede, .f24 td.mat { grid-column: 2; font-size: 12px; color: var(--text-3); }
  .f24 td.sede:not(:empty)::before { content: "Sede "; } .f24 td.mat:not(:empty)::before { content: "CF/matr. "; }
  .f24 td:empty { display: none; }
}
.f24-total { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line-strong); font-weight: 650; }

/* ---------- schedule bars ---------- */
.bars td.bar { width: 40%; }
.bars .b { height: 10px; background: var(--bar); }
.bars tr.peak .b { background: var(--bar-strong); }
.bars tr.peak td { font-weight: 600; }

/* ---------- misc ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--ink-contrast); font: 600 14px var(--font); text-decoration: none; cursor: pointer; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.cards { display: grid; grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); background: var(--surface); margin: 14px 0; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.cards a { display: block; padding: 16px 18px; text-decoration: none; border-bottom: 1px solid var(--line); }
@media (min-width: 640px) { .cards a:nth-child(odd) { border-right: 1px solid var(--line); } }
.cards a b { display: block; font-weight: 600; margin-bottom: 2px; }
.cards a span { font-size: 13px; color: var(--text-2); }
.cards a:hover { background: var(--surface-2); }
.box { border: 1px solid var(--line); border-left: 3px solid var(--ink); background: var(--surface); padding: 14px 18px; margin: 24px 0; }
details { border-bottom: 1px solid var(--line); } summary { cursor: pointer; font-weight: 600; padding: 12px 0; min-height: 44px; }
details p { padding-bottom: 12px; }
details p { color: var(--text-2); margin: 8px 0 0; }
ul.ticks { list-style: none; padding: 0; } ul.ticks li { padding: 6px 0 6px 22px; position: relative; border-bottom: 1px solid var(--line); }
ul.ticks li::before { content: ""; position: absolute; left: 2px; top: 15px; width: 8px; height: 8px; background: var(--text-2); }
.foot { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }
[hidden] { display: none !important; }
