/* ── GR SERVIZI — GESTIONALE PATENTI ───────────────────────────────────────────
   Design system unico degli strumenti interni GR Servizi (vedi design.md):
   palette dal sito grservizi.eu (lance-theme.css), angoli squadrati, sidebar scura,
   font Schibsted Grotesk (display/numeri) + Hanken Grotesk (corpo).
   ---------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=Schibsted+Grotesk:wght@500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* ── Token design system (fonte di verità) ── */
    --brand:#669900; --brand-deep:#527a00; --brand-soft:#e7f0d6;
    --gold:#e2922f;  --gold-deep:#c67d20;  --gold-soft:#fae9cf;
    --ink:#16202c;   --bg:#f6f4ef;         --surface:#ffffff; --surface-2:#f0f4e8;
    --muted:#5c6b7a; --ink-2:#5c6b7a;
    --line:rgba(18,33,48,.10); --line-strong:rgba(18,33,48,.16);
    --ok:#669900; --warn:#e2922f; --crit:#c0392b; --crit-soft:#f6e1de;

    --radius:0px;
    --shadow-sm:0 1px 2px rgba(18,33,48,.06), 0 1px 3px rgba(18,33,48,.07);
    --shadow-md:0 6px 22px rgba(18,33,48,.13);

    --f-display:'Schibsted Grotesk', system-ui, sans-serif;
    --f-body:'Hanken Grotesk', system-ui, sans-serif;

    --side-w:232px;
    --side-brand:#8cc224;   /* verde più chiaro: accento leggibile sulla sidebar scura */

    /* ── Alias legacy: il markup/JS esistente usa questi nomi ── */
    --green:var(--brand); --green-dark:var(--brand-deep); --green-deeper:#3f5e00;
    --green-light:var(--brand-soft); --green-mid:#cfe0a8;
    --red:var(--crit); --red-light:var(--crit-soft);
    --orange:var(--gold); --orange-light:var(--gold-soft);
    --blue:var(--brand-deep);
    --gray-50:#faf9f6; --gray-100:#f1efe9; --gray-200:#e6e3db; --gray-300:#d3cfc4;
    --gray-500:#8a93a0; --gray-600:var(--muted); --gray-700:#3c4753; --gray-900:var(--ink);
    --white:#ffffff;
    --radius-lg:0px;
    --shadow:var(--shadow-sm); --shadow-lg:var(--shadow-md);
}

body {
    font-family: var(--f-body);
    font-size: 14.5px;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.mt-s { margin-top: 8px; }
.num { font-family: var(--f-display); font-variant-numeric: tabular-nums; }

/* ── LOGIN ──────────────────────────────────────────────────────────────────── */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(1100px 460px at 50% -8%, var(--brand-soft), transparent 60%),
        var(--bg);
}
.login-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    padding: 40px 38px;
    width: 380px;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-title { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.login-form .field { margin-bottom: 16px; }
.login-form label {
    display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px;
    color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}
.login-form input {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line-strong); background: var(--surface);
    font-size: 15px; font-family: inherit; color: var(--ink);
}
.login-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(102,153,0,.18); }

/* Marchio GR: quadrato pieno brand + wordmark */
.gr-mark {
    background: var(--brand); color: #fff;
    font-family: var(--f-display); font-weight: 800; letter-spacing: .02em;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.gr-mark-lg { width: 46px; height: 46px; font-size: 18px; }
.gr-wordmark { font-family: var(--f-display); font-weight: 700; font-size: 17px; color: var(--ink); line-height: 1.1; }
.gr-wordmark span { display: block; font-family: var(--f-body); font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
/* Compat: vecchio blocco logo login */
.logo-gr-block { background: var(--brand); color: #fff; font-family: var(--f-display); font-weight: 800; font-size: 15px; padding: 10px 16px; line-height: 1.2; white-space: nowrap; }
.logo-gr-block span { display: block; font-size: 11px; font-weight: 500; opacity: .9; }

/* ── APP SHELL: SIDEBAR + CONTENUTO ─────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--side-w);
    background: var(--ink);
    color: rgba(255,255,255,.72);
    display: flex; flex-direction: column;
    z-index: 120;
}
.side-logo {
    display: flex; align-items: center; gap: 11px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-logo .gr-mark { width: 38px; height: 38px; font-size: 15px; }
.side-logo-txt { font-family: var(--f-display); font-weight: 700; font-size: 15px; color: #fff; line-height: 1.15; }
.side-logo-txt span { display: block; font-family: var(--f-body); font-size: 10.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.55); }

.side-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-group { padding: 16px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.36); }
.side-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    color: rgba(255,255,255,.72);
    font-size: 14.5px; font-weight: 500; font-family: inherit;
    text-decoration: none; cursor: pointer;
    border: none; background: transparent; text-align: left; width: 100%;
    border-left: 3px solid transparent;
    transition: background .14s, color .14s;
}
.side-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active {
    background: rgba(140,194,36,.12);
    color: #fff; font-weight: 600;
    border-left-color: var(--side-brand);
}
.side-item.active svg { opacity: 1; color: var(--side-brand); }
.side-foot { margin-top: auto; padding: 12px 10px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-logout {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; background: transparent; border: none; cursor: pointer;
    color: rgba(255,255,255,.6); font-size: 14px; font-family: inherit; text-align: left;
}
.side-logout:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-logout svg { width: 17px; height: 17px; }

.content { margin-left: var(--side-w); flex: 1; min-width: 0; }

/* Intestazione pagina */
.content-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 20px 28px 14px;
}
.head-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.head-title { font-family: var(--f-display); font-weight: 700; font-size: 24px; color: var(--ink); margin-top: 2px; }
.head-date { font-size: 13px; color: var(--muted); font-family: var(--f-display); }

/* ── MAIN ───────────────────────────────────────────────────────────────────── */
.main { padding: 6px 28px 40px; }

/* ── TOOLBAR ────────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 10px; margin-bottom: 18px;
    background: var(--surface);
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    box-shadow: var(--shadow-sm);
}
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-date { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.label-sm { font-size: 13px; color: var(--muted); font-weight: 500; }
.input-sm {
    padding: 7px 10px;
    border: 1px solid var(--line-strong);
    font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--ink);
}
.input-sm:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(102,153,0,.15); }
.check-filter { display: flex; align-items: center; gap: 5px; font-size: 14px; cursor: pointer; color: var(--gray-700); }
.check-filter input[type=checkbox] { accent-color: var(--brand); }

/* ── TABLE ──────────────────────────────────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: 11px 14px;
    text-align: left;
    font-size: 11.5px; font-weight: 700;
    color: var(--ink);
    text-transform: uppercase; letter-spacing: .05em;
    background: var(--surface-2);
    border-bottom: 2px solid var(--brand);
    white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:nth-child(even) { background: var(--gray-50); }
.table tbody tr:hover { background: var(--brand-soft); }
.loading { text-align: center; padding: 36px; color: var(--gray-500); }

/* ── BADGES ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px; }
.badge-green  { background: var(--brand-soft); color: var(--brand-deep); }
.badge-orange { background: var(--gold-soft); color: var(--gold-deep); }
.badge-red    { background: var(--crit-soft); color: var(--crit); }
.badge-gray   { background: var(--gray-200); color: var(--gray-700); }
.badge-blue   { background: var(--surface-2); color: var(--brand-deep); }

.step-badge  { font-size: 12px; border-radius: 3px; padding: 3px 9px; font-weight: 600; display: inline-block; }
.step-new    { background: var(--gray-200);   color: var(--gray-700); }
.step-mid    { background: #e8eef4;           color: #41586b; }
.step-late   { background: var(--gold-soft);  color: var(--gold-deep); }
.step-warn   { background: var(--crit-soft);  color: var(--crit); }
.step-done   { background: var(--brand-soft); color: var(--brand-deep); }
.hint        { font-size: 11px; font-weight: 400; color: var(--gray-500); font-style: italic; }

.doc-pills { display: flex; flex-wrap: wrap; gap: 3px; }
.doc-pill { font-size: 11px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.doc-ok   { background: var(--brand-soft); color: var(--brand-deep); }
.doc-miss { background: var(--crit-soft); color: var(--crit); }
.doc-warn { background: var(--gold-soft); color: var(--gold-deep); }

.scad { font-size: 12px; }
.scad-ok   { color: var(--muted); }
.scad-soon { color: var(--gold-deep); font-weight: 700; }
.scad-exp  { color: var(--crit); font-weight: 700; }

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px;
    border: none; cursor: pointer;
    font-size: 14.5px; font-weight: 600; font-family: var(--f-display);
    transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost   { background: var(--surface); color: var(--gray-700); border: 1px solid var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger  { background: var(--crit-soft); color: var(--crit); }
.btn-danger:hover { background: #efd2ce; }
.btn-sm      { padding: 6px 13px; font-size: 13.5px; }
.btn-block   { width: 100%; justify-content: center; }
.btn-icon    { background: transparent; border: none; cursor: pointer; padding: 5px 9px; color: var(--muted); font-size: 15px; }
.btn-icon:hover { background: var(--brand-soft); color: var(--brand-deep); }
.btn-icon-danger { color: var(--crit); }
.btn-icon-danger:hover { background: var(--crit-soft); color: var(--crit); }

/* ── DASHBOARD ──────────────────────────────────────────────────────────────── */
.dash-kpis {
    display: flex; flex-wrap: wrap; gap: 14px;
    margin-bottom: 18px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-top: 3px solid var(--brand);
    box-shadow: var(--shadow-sm);
    padding: 15px 18px 16px;
    display: flex; flex-direction: column; gap: 4px;
    flex: 1 1 220px; max-width: 320px;
}
.kpi.is-warn { border-top-color: var(--gold); }
.kpi.is-crit { border-top-color: var(--crit); }
.kpi.is-neutral { border-top-color: var(--line-strong); }
.kpi.clickable { cursor: pointer; transition: box-shadow .15s, transform .05s; }
.kpi.clickable:hover { box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi-label svg { width: 16px; height: 16px; }
.kpi-num { font-family: var(--f-display); font-weight: 800; font-size: 34px; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi.is-crit .kpi-num { color: var(--crit); }
.kpi-sub { font-size: 12px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }

.panel { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-title { font-family: var(--f-display); font-weight: 700; font-size: 15.5px; color: var(--ink); }
.panel-hint { font-size: 12px; color: var(--muted); font-weight: 500; }
.panel-link { font-size: 13px; color: var(--brand-deep); font-weight: 600; cursor: pointer; background: none; border: none; font-family: var(--f-display); }
.panel-link:hover { text-decoration: underline; }
.panel-empty { padding: 22px 18px; color: var(--gray-500); font-size: 13.5px; }

/* Righe scadenze */
.sc-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.sc-row:last-child { border-bottom: none; }
.sc-row:hover { background: var(--gray-50); }
.sc-bar { width: 3px; align-self: stretch; background: var(--gold); flex-shrink: 0; }
.sc-row.exp .sc-bar { background: var(--crit); }
.sc-name { font-weight: 600; color: var(--ink); cursor: pointer; }
.sc-name:hover { color: var(--brand-deep); }
.sc-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sc-tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 3px; background: var(--surface-2); color: var(--gray-700); }
.sc-when { margin-left: auto; text-align: right; }
.sc-date { font-family: var(--f-display); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.sc-when.soon .sc-date { color: var(--gold-deep); }
.sc-when.exp .sc-date { color: var(--crit); }
.sc-days { font-size: 11px; color: var(--muted); }

/* Prossimi passi */
.step-link { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.step-link:last-child { border-bottom: none; }
.step-link:hover { background: var(--surface-2); }
.step-dot { width: 10px; height: 10px; flex-shrink: 0; }
.step-link .sl-label { font-size: 14px; color: var(--ink); font-weight: 500; }
.step-link .sl-sub { font-size: 11.5px; color: var(--muted); }
.step-link .sl-n { margin-left: auto; font-family: var(--f-display); font-weight: 700; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Barre distribuzione step */
.bar-row { display: flex; align-items: center; gap: 11px; padding: 8px 18px; }
.bar-label { display: flex; align-items: center; gap: 8px; width: 148px; flex-shrink: 0; font-size: 13px; color: var(--gray-700); }
.bar-dot { width: 9px; height: 9px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; }
.bar-num { width: 74px; flex-shrink: 0; display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; }
.bar-count { font-family: var(--f-display); font-weight: 700; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-pct { width: 32px; text-align: right; font-family: var(--f-display); font-weight: 600; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-click { cursor: pointer; transition: background .12s; }
.bar-click:hover { background: var(--surface-2); }

/* Pagamenti mini */
.pay-row { display: flex; gap: 12px; padding: 14px 18px; }
.pay-cell { flex: 1; border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 10px 12px; }
.pay-cell.crit { border-left-color: var(--crit); }
.pay-n { font-family: var(--f-display); font-weight: 800; font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.pay-l { font-size: 12px; color: var(--muted); }

/* Attività recenti */
.rec-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.rec-row:last-child { border-bottom: none; }
.rec-row:hover { background: var(--gray-50); }
.rec-name { font-weight: 600; color: var(--ink); cursor: pointer; }
.rec-name:hover { color: var(--brand-deep); }
.rec-when { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--f-display); }

/* ── MODAL ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(18,33,48,.52);
    z-index: 200;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 16px; overflow-y: auto;
}
.modal { background: var(--surface); width: 100%; max-width: 660px; box-shadow: var(--shadow-md); border: 1px solid var(--line); }
.modal-xl { max-width: 920px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--brand);
    padding: 15px 24px;
}
.modal-header h2 { font-family: var(--f-display); font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .01em; }
.modal-close { background: rgba(255,255,255,.18); border: none; font-size: 16px; cursor: pointer; color: #fff; padding: 4px 9px; }
.modal-close:hover { background: rgba(255,255,255,.32); }
.modal-body { padding: 22px 26px; max-height: 72vh; overflow-y: auto; }
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; padding: 16px 26px;
    border-top: 1px solid var(--line);
    background: var(--gray-50);
}

/* ── FORM ───────────────────────────────────────────────────────────────────── */
.form-section { margin-bottom: 24px; }
.section-title {
    font-family: var(--f-display);
    font-size: 12px; font-weight: 700;
    color: var(--brand-deep);
    text-transform: uppercase; letter-spacing: .07em;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: var(--brand-soft);
    border-left: 3px solid var(--brand);
}
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field-span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    font-size: 15px; font-family: inherit;
    background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(102,153,0,.15);
}
.check-inline { display: flex; align-items: center; gap: 7px; font-size: 14px; margin-top: 8px; cursor: pointer; color: var(--gray-700); }
.check-inline input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 12px; }
.doc-card {
    background: var(--gray-50);
    border: 1px solid var(--line);
    border-top: 3px solid var(--green-mid);
    padding: 12px;
}
.doc-label { font-family: var(--f-display); font-size: 12px; font-weight: 700; color: var(--brand-deep); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.doc-card select { width: 100%; padding: 6px 8px; border: 1px solid var(--line-strong); font-size: 14px; font-family: inherit; background: var(--surface); }
.doc-card select:focus { outline: none; border-color: var(--brand); }

/* ── ALERT ──────────────────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; margin-bottom: 18px; font-size: 14px; }
.alert-error { background: var(--crit-soft); color: var(--crit); border-left: 3px solid var(--crit); }

/* ── CONTATORE + RESET ───────────────────────────────────────────────────────── */
.toolbar-bottom { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 2px; }
#contatore-pratiche { font-size: 13px; color: var(--gray-500); font-weight: 500; margin-left: auto; }

/* ── PAGINAZIONE ─────────────────────────────────────────────────────────────── */
.paginazione {
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap; gap: 4px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line); border-top: none;
    box-shadow: var(--shadow-sm);
}
.pag-btn {
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--gray-700);
    font-size: 13px; font-weight: 600; font-family: var(--f-display);
    cursor: pointer; transition: background .12s, border-color .12s;
}
.pag-btn:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }
.pag-btn.pag-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pag-btn:disabled { opacity: .35; cursor: default; }
.pag-ellipsis { font-size: 14px; color: var(--gray-500); padding: 0 4px; }

/* ── TOAST ───────────────────────────────────────────────────────────────────── */
#toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: #fff;
    padding: 12px 24px;
    font-size: 14px; font-weight: 600; font-family: var(--f-display);
    box-shadow: var(--shadow-md);
    z-index: 999; opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
}
#toast.show { opacity: 1; }
#toast.toast-error { background: var(--crit); }

/* ── ORDINAMENTO COLONNE ──────────────────────────────────────────────────────── */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { background: var(--brand-soft); }
.sort-ico { display: inline-block; font-size: 11px; opacity: .6; margin-left: 2px; }

/* ── MAIUSCOLO AUTOMATICO NEI FORM ───────────────────────────────────────────── */
.modal input[type="text"], .modal textarea { text-transform: uppercase; }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 1150px) {
    .dash-kpis { grid-template-columns: repeat(2, 1fr); }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar {
        position: static; width: 100%; bottom: auto;
        flex-direction: row; align-items: center; flex-wrap: wrap;
    }
    .side-logo { border-bottom: none; padding: 12px 16px; }
    .side-nav { flex-direction: row; padding: 8px; flex: 1; gap: 2px; overflow-x: auto; }
    .side-group { display: none; }
    .side-item { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .side-item.active { border-left: none; border-bottom-color: var(--side-brand); }
    .side-foot { margin: 0; border-top: none; padding: 8px 12px; }
    .content { margin-left: 0; }
    .content-head { flex-direction: column; align-items: flex-start; gap: 4px; }
}
@media (max-width: 700px) {
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .doc-grid { grid-template-columns: 1fr 1fr; }
    .toolbar { flex-direction: column; align-items: flex-start; }
    .dash-kpis { grid-template-columns: 1fr; }
    .main, .content-head { padding-left: 16px; padding-right: 16px; }
}
