/* ============================================================
   Update Server — console di controllo distribuzione & licenze
   Tema: pannello industriale scuro, accento ambra, dati mono.
   Font: Chakra Petch (titoli) · Spline Sans (testo) ·
         Spline Sans Mono (dati) — fallback di sistema inclusi.
   Nessuna dipendenza JS.
   ============================================================ */

:root {
    color-scheme: dark;

    /* Superfici */
    --bg: #0a0e16;
    --surface: #121826;
    --surface-2: #182032;
    --inset: #0c1220;
    --border: #222c41;
    --border-strong: #344664;

    /* Testo */
    --text: #e7ecf5;
    --muted: #8b96ab;
    --faint: #56617a;

    /* Accento ambra */
    --amber: #ffb454;
    --amber-bright: #ffcd8a;
    --amber-ink: #1d1304;
    --amber-dim: rgba(255, 180, 84, .12);

    /* Stati */
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #ff6b70;

    --font-display: 'Chakra Petch', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Spline Sans', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Spline Sans Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    --radius: 5px;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 14px 34px rgba(2, 5, 12, .5);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1000px 520px at 88% -12%, rgba(255, 180, 84, .07), transparent 62%),
        linear-gradient(rgba(142, 168, 215, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(142, 168, 215, .04) 1px, transparent 1px),
        var(--bg);
    background-size: auto, 34px 34px, 34px 34px, auto;
    background-attachment: fixed;
    min-height: 100vh;
}

::selection { background: var(--amber); color: var(--amber-ink); }

h2 {
    font-family: var(--font-display);
    font-size: 21px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    margin: 0;
}
h2::before { content: '// '; color: var(--amber); letter-spacing: 0; }
h3 {
    font-family: var(--font-display);
    font-size: 14.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em;
    margin: 0 0 12px;
}
h4 {
    font-family: var(--font-mono);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .16em;
    color: var(--muted);
    margin: 22px 0 8px;
}
code {
    font-family: var(--font-mono); font-size: 12.5px;
    color: var(--amber-bright);
    background: var(--inset);
    border: 1px solid var(--border);
    padding: 1px 6px; border-radius: 3px;
}

/* ---------------------------------------------------------- */
/* Sidebar                                                     */
/* ---------------------------------------------------------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: 226px; z-index: 10;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, #101624 0%, #0c111d 100%);
    border-right: 1px solid var(--border);
}
.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 18px;
    text-decoration: none; color: var(--text);
    border-bottom: 1px solid var(--border);
}
.brand-mark { width: 30px; height: 30px; color: var(--amber); flex-shrink: 0; }
.brand-name {
    font-family: var(--font-display);
    font-size: 15px; font-weight: 700; line-height: 1.15;
    text-transform: uppercase; letter-spacing: .09em;
}
.brand-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 9.5px; font-weight: 400; letter-spacing: .14em;
    color: var(--faint); margin-top: 3px;
}

.nav { display: flex; flex-direction: column; padding: 14px 0; }
.nav a {
    display: flex; align-items: baseline; gap: 10px;
    padding: 11px 20px;
    font-family: var(--font-mono);
    font-size: 12px; font-weight: 500;
    text-transform: uppercase; letter-spacing: .12em;
    color: var(--muted); text-decoration: none;
    border-left: 2px solid transparent;
    transition: color .15s, background .15s, border-color .15s;
}
.nav a .nav-idx { font-size: 10px; color: var(--faint); transition: color .15s; }
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.nav a.active {
    color: var(--amber); border-left-color: var(--amber);
    background: linear-gradient(90deg, var(--amber-dim), transparent 75%);
}
.nav a.active .nav-idx { color: var(--amber); }

.side-foot {
    margin-top: auto;
    display: flex; align-items: center; gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono); font-size: 10.5px;
    letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.side-foot .logout {
    margin-left: auto; color: var(--muted); text-decoration: none;
    transition: color .15s;
}
.side-foot .logout:hover { color: var(--amber); }

.led {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
    background: var(--ok);
    box-shadow: 0 0 7px rgba(74, 222, 128, .8);
    animation: led-pulse 2.6s ease-in-out infinite;
}

/* ---------------------------------------------------------- */
/* Area principale                                             */
/* ---------------------------------------------------------- */
.container { margin-left: 226px; padding: 34px 40px 70px; max-width: 1220px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.page-head h2 { margin-right: auto; }

/* ---------------------------------------------------------- */
/* Card                                                        */
/* ---------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    animation: rise .5s cubic-bezier(.22, 1, .36, 1) both;
}
.card.slim { max-width: 640px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head h3 { margin: 0; margin-right: auto; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.card-grid .card { margin-bottom: 0; }
.card-grid .card:nth-child(2) { animation-delay: .08s; }
@media (max-width: 920px) { .card-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- */
/* Statistiche — pannelli HUD                                  */
/* ---------------------------------------------------------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 30px;
}
.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 16px 18px 14px;
    animation: rise .45s cubic-bezier(.22, 1, .36, 1) both;
}
.stat-card::before, .stat-card::after {
    content: ''; position: absolute; width: 13px; height: 13px;
    border: 1px solid var(--amber); opacity: .7; pointer-events: none;
}
.stat-card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.stat-card::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.stat-card:nth-child(1) { animation-delay: .02s; }
.stat-card:nth-child(2) { animation-delay: .07s; }
.stat-card:nth-child(3) { animation-delay: .12s; }
.stat-card:nth-child(4) { animation-delay: .17s; }
.stat-card:nth-child(5) { animation-delay: .22s; }
.stat-card:nth-child(6) { animation-delay: .27s; }
.stat-card .label {
    font-family: var(--font-mono);
    font-size: 10px; font-weight: 500;
    color: var(--muted); text-transform: uppercase; letter-spacing: .15em;
}
.stat-card .value {
    font-family: var(--font-display);
    font-size: 30px; font-weight: 700; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    margin-top: 8px;
}

/* ---------------------------------------------------------- */
/* Tabelle                                                     */
/* ---------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: rise .5s cubic-bezier(.22, 1, .36, 1) .1s both;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
th {
    font-family: var(--font-mono);
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .14em;
    color: var(--muted); background: var(--surface-2);
    border-bottom-color: var(--border-strong);
}
td { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
tbody tr:hover td, table tr:hover td { background: rgba(255, 180, 84, .04); }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions form + form { margin-left: 6px; }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; transition: color .15s; }
.row-link:hover { color: var(--amber); }

/* ---------------------------------------------------------- */
/* Bottoni                                                     */
/* ---------------------------------------------------------- */
.btn {
    display: inline-block; padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em;
    text-decoration: none; cursor: pointer;
    border: 1px solid transparent; border-radius: 3px;
    background: var(--amber); color: var(--amber-ink);
    clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--amber-bright); }
.btn.secondary {
    background: transparent; color: var(--text); border-color: var(--border-strong);
    clip-path: none;
}
.btn.secondary:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; clip-path: none; }
.btn.ghost:hover { color: var(--amber); background: var(--amber-dim); }
.btn.danger { background: #e5484d; color: #fff; }
.btn.danger:hover { background: #f2555a; }
.btn.danger-outline {
    background: transparent; color: var(--err); border-color: rgba(255, 107, 112, .4);
    clip-path: none;
}
.btn.danger-outline:hover { background: rgba(255, 107, 112, .1); border-color: var(--err); }
.btn.block { width: 100%; text-align: center; }
.btn.copied { background: var(--ok); color: #06270f; border-color: transparent; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.inline { display: inline; }

/* ---------------------------------------------------------- */
/* Badge — spie di stato                                       */
/* ---------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em;
    white-space: nowrap;
    border: 1px solid;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.ok { color: var(--ok); background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .35); }
.badge.ok::before { box-shadow: 0 0 6px rgba(74, 222, 128, .9); animation: led-pulse 2.6s ease-in-out infinite; }
.badge.warn { color: var(--warn); background: rgba(251, 191, 36, .08); border-color: rgba(251, 191, 36, .35); }
.badge.err { color: var(--err); background: rgba(255, 107, 112, .08); border-color: rgba(255, 107, 112, .35); }
.badge.neutral { color: var(--muted); background: rgba(139, 150, 171, .08); border-color: rgba(139, 150, 171, .3); }
.badge.sm { padding: 1px 7px; font-size: 9.5px; gap: 5px; }
.badge.sm::before { width: 5px; height: 5px; }

/* ---------------------------------------------------------- */
/* Form                                                        */
/* ---------------------------------------------------------- */
label {
    display: block; margin: 16px 0 6px;
    font-family: var(--font-mono);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .13em;
    color: var(--muted);
}
label.check {
    display: flex; align-items: center; gap: 9px;
    font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
    text-transform: none; letter-spacing: 0; color: var(--text);
    margin: 8px 0;
}
label.check input { width: auto; margin: 0; }
input, textarea, select {
    width: 100%; padding: 10px 12px;
    background: var(--inset); color: var(--text);
    border: 1px solid var(--border); border-radius: 3px;
    font-size: 14px; font-family: var(--font-body);
    transition: border-color .15s, box-shadow .15s;
}
input[type='checkbox'] { accent-color: var(--amber); width: 15px; height: 15px; }
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(255, 180, 84, .18);
}
.btn:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 2px; }
select { width: auto; font-family: var(--font-mono); font-size: 12.5px; }
.checklist {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px;
    background: var(--inset);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 12px 14px;
}
@media (max-width: 560px) { .checklist { grid-template-columns: 1fr; } }
.filterbar { display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------- */
/* Token                                                       */
/* ---------------------------------------------------------- */
.token-row { display: flex; gap: 8px; align-items: stretch; }
.token-row .btn { flex-shrink: 0; align-self: center; }
.token-box {
    flex: 1;
    font-family: var(--font-mono); font-size: 12.5px;
    color: var(--amber-bright);
    background: var(--inset);
    border: 1px solid var(--border-strong); border-radius: 3px;
    padding: 10px 12px; word-break: break-all;
}

/* ---------------------------------------------------------- */
/* Varie                                                       */
/* ---------------------------------------------------------- */
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--faint); font-style: italic; font-family: var(--font-body); }
.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.alert {
    padding: 12px 16px; margin-bottom: 18px;
    font-size: 13.5px; border-radius: 3px;
    border: 1px solid; border-left-width: 3px;
    animation: rise .4s cubic-bezier(.22, 1, .36, 1) both;
}
.alert.error { color: #ffb3b6; background: rgba(255, 107, 112, .09); border-color: rgba(255, 107, 112, .4); border-left-color: var(--err); }
.alert.success { color: #9ef0bd; background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .35); border-left-color: var(--ok); }

/* ---------------------------------------------------------- */
/* Login                                                       */
/* ---------------------------------------------------------- */
body.login-page {
    display: grid; place-items: center; min-height: 100vh; margin: 0;
    background:
        radial-gradient(700px 460px at 50% 32%, rgba(255, 180, 84, .09), transparent 65%),
        linear-gradient(rgba(142, 168, 215, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(142, 168, 215, .05) 1px, transparent 1px),
        var(--bg);
    background-size: auto, 34px 34px, 34px 34px, auto;
}
.login-wrap { width: min(390px, calc(100vw - 40px)); }
.login-wrap .card {
    position: relative; margin: 0; padding: 34px 30px 30px;
    border-radius: 2px;
    animation: rise .6s cubic-bezier(.22, 1, .36, 1) both;
}
.login-wrap .card::before, .login-wrap .card::after {
    content: ''; position: absolute; width: 18px; height: 18px;
    border: 1px solid var(--amber); opacity: .8; pointer-events: none;
}
.login-wrap .card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.login-wrap .card::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.login-head { display: flex; align-items: center; gap: 13px; margin-bottom: 6px; }
.login-head .brand-mark { width: 34px; height: 34px; }
.login-brand {
    font-family: var(--font-display);
    font-size: 19px; font-weight: 700; line-height: 1.15;
    text-transform: uppercase; letter-spacing: .09em;
    margin: 0;
}
.login-sub {
    font-family: var(--font-mono);
    font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
    color: var(--faint); margin: 0 0 10px;
}

/* ---------------------------------------------------------- */
/* Animazioni                                                  */
/* ---------------------------------------------------------- */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
@keyframes led-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------- */
/* Responsive — tablet: sidebar diventa header sticky          */
/* ---------------------------------------------------------- */
@media (max-width: 880px) {
    .sidebar {
        position: sticky; top: 0; width: auto;
        flex-direction: row; flex-wrap: wrap; align-items: center;
        border-right: none; border-bottom: 1px solid var(--border);
    }
    .brand { border-bottom: none; padding: 12px 16px; margin-right: auto; }
    .brand-mark { width: 24px; height: 24px; }
    .brand-name { font-size: 13px; }
    .brand-name br { display: none; }
    .brand-sub { display: none; }
    .nav {
        order: 3; flex-basis: 100%;
        flex-direction: row; padding: 0;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        border-top: 1px solid var(--border);
    }
    .nav a { padding: 13px 14px; border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
    .nav a.active { border-bottom-color: var(--amber); background: none; }
    .nav a .nav-idx { display: none; }
    .side-foot { margin-top: 0; border-top: none; padding: 12px 16px; }
    .container { margin-left: 0; padding: 24px 18px 56px; }
}

/* ---------------------------------------------------------- */
/* Responsive — mobile: tabelle a schede, layout compatto      */
/* ---------------------------------------------------------- */
@media (max-width: 640px) {
    .container { padding: 20px 14px 48px; }
    h2 { font-size: 18px; }
    .page-head { flex-wrap: wrap; row-gap: 10px; }
    .card { padding: 18px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 13px 14px 12px; }
    .stat-card .value { font-size: 24px; }

    /* Tabelle: ogni riga diventa una scheda etichetta/valore */
    .table-wrap { background: transparent; border: none; box-shadow: none; overflow: visible; }
    table, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }
    tr {
        background: var(--surface);
        border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-bottom: 10px; padding: 6px 0;
    }
    tr:last-child { margin-bottom: 0; }
    td {
        display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
        border-bottom: none; padding: 6px 14px;
        text-align: right;
    }
    td::before {
        content: attr(data-label);
        font-family: var(--font-mono); font-size: 10px; font-weight: 500;
        text-transform: uppercase; letter-spacing: .14em;
        color: var(--muted); flex-shrink: 0;
    }
    td.empty { justify-content: flex-start; text-align: left; }
    tbody tr:hover td, table tr:hover td { background: none; }
    .cell-actions { justify-content: flex-end; padding-top: 10px; }

    /* Token e azioni impilati */
    .token-row { flex-direction: column; }
    .token-row .btn { align-self: stretch; text-align: center; }
    .actions { flex-wrap: wrap; }
    .filterbar { flex: 1; }
    .filterbar select { width: 100%; }
}
