/* Ripulisci S3 — stile dell'interfaccia (nessuna dipendenza esterna) */

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e3e8ef;
    --text: #1b2333;
    --muted: #64708a;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #e8f0fe;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fdecec;
    --warning: #b45309;
    --warning-soft: #fff6e5;
    --success: #15803d;
    --success-soft: #e8f7ee;
    --info: #1d4ed8;
    --info-soft: #e8f0fe;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar: 248px;
    --topbar: 60px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141d;
        --surface: #161d2a;
        --surface-2: #1b2433;
        --border: #263043;
        --text: #e6eaf2;
        --muted: #93a0b8;
        --primary: #4f8cff;
        --primary-hover: #6b9dff;
        --primary-soft: #1a2a4a;
        --danger: #f26b6b;
        --danger-hover: #ff8585;
        --danger-soft: #3a1d22;
        --warning: #f0b453;
        --warning-soft: #3a2e17;
        --success: #4ccf7f;
        --success-soft: #16301f;
        --info: #7fa9ff;
        --info-soft: #1a2a4a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
p { margin: 0 0 1em; }
code, pre, .code { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: .05em .35em; border-radius: 5px; word-break: break-all; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8em 1em; overflow-x: auto; }
small { font-size: .85em; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.lead { font-size: 1.05rem; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }
.visually-hidden, .hp-field {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; }

/* ------------------------------------------------------------ Layout app */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 30;
    display: flex; align-items: center; gap: 12px; padding: 0 20px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    background: var(--primary); color: #fff; font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}
.topbar-right { margin-left: auto; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .92rem; }
.user-chip .icon { width: 18px; height: 18px; }
.btn-icon { display: none; background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; }

.shell { display: flex; padding-top: var(--topbar); min-height: 100vh; }
.sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); z-index: 20;
    overflow-y: auto; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.nav { list-style: none; margin: 0; padding: 0; }
.nav-title { margin: 18px 12px 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.nav-link {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin: 1px 0;
    border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: .94rem;
    background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link .icon { width: 19px; height: 19px; opacity: .85; }
.nav-logout { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.nav-version { font-size: .75rem; color: var(--muted); padding: 8px 12px 0; }
.nav-backdrop { display: none; }

.content { flex: 1; min-width: 0; margin-left: var(--sidebar); padding: 28px 32px 48px; max-width: calc(1200px + var(--sidebar)); }
.page-head { margin-bottom: 18px; }

@media (max-width: 900px) {
    .btn-icon { display: inline-flex; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0,0,0,.35); z-index: 15; }
    .content { margin-left: 0; padding: 20px 16px 40px; }
    .user-chip span, .topbar .brand span:last-child { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ------------------------------------------------------------ Cards, grid */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 20px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .card { padding: 18px 16px; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card .stat { box-shadow: none; background: var(--surface-2); }
.stat-value { display: block; font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ------------------------------------------------------------ Forms */
.form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=search], select, textarea {
    width: 100%; padding: 9px 12px; font: inherit; font-size: .95rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[type=file] { font: inherit; max-width: 100%; }
.input-sm { width: 90px !important; display: inline-block; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: .83rem; margin: 5px 0 0; }
.hint-list { color: var(--muted); font-size: .85rem; padding-left: 1.2em; }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 400; font-size: .93rem; margin: 8px 0; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; flex: none; accent-color: var(--primary); }
.checks { margin: 4px 0 14px; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px 6px; margin: 0 0 16px; min-width: 0; }
.fieldset legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form input, .inline-form select { width: auto; min-width: 140px; }
.inline-form label { margin: 0; font-weight: 400; }
form.inline { display: inline; }

.strength { height: 5px; background: var(--border); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

/* ------------------------------------------------------------ Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; font: inherit; font-size: .93rem; font-weight: 600; line-height: 1.2;
    border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
    text-decoration: none !important; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.actions form { margin: 0; }

/* ------------------------------------------------------------ Alerts, badges */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; font-size: .93rem; }
.alert ul { margin: 6px 0 0; padding-left: 1.2em; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert code { background: rgba(127,127,127,.12); border-color: transparent; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ------------------------------------------------------------ Tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact td, .table-compact th { padding: 7px 8px; }
.table td.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.details { max-width: 420px; word-break: break-word; }
.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; font-size: .9rem; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 16px; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: none; }
.checklist .ok .dot { background: var(--success); }
.checklist .ko .dot { background: var(--danger); }
.checklist .warn .dot { background: var(--warning); }
.file-list { font-size: .88rem; padding-left: 1.2em; }

/* ------------------------------------------------------------ Guest pages */
.guest { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.guest-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 10px 30px rgba(16,24,40,.08); padding: 32px 30px; }
.guest-card.guest-wide { max-width: 680px; }
.guest-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; margin-bottom: 22px; }
.guest-title { font-size: 1.4rem; margin-bottom: 16px; }
.guest-foot { color: var(--muted); font-size: .8rem; margin-top: 16px; }
.guest h2 { margin-top: 1.4em; font-size: 1.05rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 8px; }
.maint-icon .icon { width: 48px; height: 48px; color: var(--warning); margin-bottom: 8px; }
@media (max-width: 480px) { .guest-card { padding: 24px 18px; } }

.steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; font-size: .82rem; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 6px; }
.steps li span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); font-weight: 700; font-size: .75rem; }
.steps li.current { color: var(--text); font-weight: 600; }
.steps li.current span { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps li.done span { background: var(--success-soft); color: var(--success); border-color: transparent; }
.steps li + li::before { content: ""; width: 16px; height: 1px; background: var(--border); }

/* ------------------------------------------------------------ Captcha */
.captcha-box label { margin-bottom: 6px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-row img { border-radius: var(--radius-sm); border: 1px solid var(--border); max-width: 100%; height: auto; background: #eef1f6; }
.captcha-box input { text-transform: uppercase; letter-spacing: .15em; }

/* ------------------------------------------------------------ S3 */
.test-area { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 18px; }
.test-result { font-size: .9rem; }
.test-result.ok { color: var(--success); }
.test-result.ko { color: var(--danger); }
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); background: color-mix(in srgb, var(--danger-soft) 45%, var(--surface)); border-radius: var(--radius); padding: 16px 18px; }
.danger-zone h3 { margin-top: 0; color: var(--danger); }
.danger-zone .btn { margin-top: 8px; }

.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-head h2 { margin-bottom: 4px; word-break: break-all; }
.job-head p { margin-bottom: 14px; font-size: .88rem; word-break: break-all; }
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 6px 0 10px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.progress.indeterminate .progress-bar { width: 35% !important; animation: slide 1.3s ease-in-out infinite; }
.progress.done .progress-bar { background: var(--success); }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate .progress-bar { animation: none; width: 100% !important; opacity: .5; } }
.phase { margin-bottom: 16px; }
.job-log {
    list-style: none; margin: 0; padding: 12px 14px; max-height: 340px; overflow-y: auto;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: var(--mono); font-size: .8rem; line-height: 1.6;
}
.job-log li { border-bottom: 1px dashed var(--border); padding: 2px 0; word-break: break-word; }
.job-log li:last-child { border-bottom: 0; }
.job-log li.err { color: var(--danger); }
.job-log li.ok { color: var(--success); }

.copy { cursor: pointer; user-select: all; font-size: 1em; }
