:root {
    --bg: #f6f7f3;
    --panel: #ffffff;
    --text: #17211d;
    --muted: #6b756f;
    --line: #dce2dc;
    --green: #1f7a4d;
    --orange: #b86100;
    --red: #b3261e;
    --blue: #245e8f;
    --ink: #101816;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; }
.shell { min-height: 100vh; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 40px);
    background: var(--ink);
    color: #fff;
}
.brand { font-weight: 800; letter-spacing: 0; }
.userbar { display: flex; align-items: center; gap: 12px; color: #dce5df; font-size: 14px; }
.content { width: min(1280px, 100%); margin: 0 auto; padding: 24px clamp(14px, 3vw, 32px) 48px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-panel { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 12px 30px rgba(16, 24, 22, .08); }
h1, h2, h3 { margin: 0 0 14px; letter-spacing: 0; }
h1 { font-size: clamp(26px, 4vw, 38px); }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
.subtle { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.stat { min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; }
.stat strong { font-size: 34px; line-height: 1; }
.section { margin-top: 22px; }
label { display: block; font-weight: 650; font-size: 13px; margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cfd7d1;
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
textarea { min-height: 92px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 10px 14px;
    background: var(--ink);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn.secondary { background: #e7ece8; color: var(--ink); }
.btn.blue { background: var(--blue); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.full { width: 100%; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.tab { border: 1px solid var(--line); background: #fff; padding: 9px 12px; border-radius: 999px; font-weight: 700; color: var(--muted); text-decoration: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 800; background: #eef2ee; color: var(--ink); }
.badge.verde { background: #dff4e8; color: var(--green); }
.badge.arancione { background: #fff0d8; color: var(--orange); }
.badge.rosso { background: #ffe3df; color: var(--red); }
.notice { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; background: #e3f4eb; color: #185f3a; border: 1px solid #b7dec8; }
.errors { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; background: #ffe8e5; color: #912018; border: 1px solid #f4b8b1; }
.mobile-actions { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mobile-actions .btn { min-height: 64px; white-space: normal; text-align: center; }
.anchor-target { scroll-margin-top: 20px; }
.muted-list { margin: 0; padding-left: 18px; color: var(--muted); }
.inline-form { display: inline; }

@media (max-width: 820px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4, .field-grid { grid-template-columns: 1fr; }
    .content { padding-top: 16px; }
    .panel, .card { padding: 14px; }
    .mobile-actions { grid-template-columns: 1fr; }
    table { min-width: 640px; }
}
