:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #6b7489;
    --border: #e1e5ec;
    --primary: #1f5aa6;
    --primary-dark: #17467f;
    --ok: #1e8a4c;
    --ok-bg: #e3f4ea;
    --warn: #a86b00;
    --warn-bg: #fff3d6;
    --err: #b3261e;
    --err-bg: #fbe4e2;
    --sidebar: #16233b;
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; font-weight: 600; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 600; }
code, pre { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
pre { background: #f0f2f6; border: 1px solid var(--border); border-radius: 6px; padding: .75rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ---- layout ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--sidebar); color: #d7deea; display: flex; flex-direction: column; padding: 1rem .75rem; }
.content { flex: 1; padding: 1.5rem 2rem; min-width: 0; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1.25rem; }
.brand-mark { font-size: 1.8rem; line-height: 1; color: #7fb2ff; }
.brand-name { font-weight: 700; font-size: 1.05rem; color: #fff; }
.brand-sub { font-size: .78rem; color: #8e9ab3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #c4cde0; padding: .55rem .75rem; border-radius: 6px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: .5rem; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot .btn-link { color: #9fc3ff; }

/* ---- componenti ---- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.reveal { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,90,166,.12); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1200px) { .grid-2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-value { font-size: 1.7rem; font-weight: 600; }
.stat-label { color: var(--muted); font-size: .85rem; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); padding: .5rem; }
.table td { border-bottom: 1px solid var(--border); padding: .55rem .5rem; vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f7f9fc; }
.table tr.row-off td { opacity: .55; }
.table input:not([type=checkbox]), .table select { width: 100%; min-width: 140px; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab { background: none; border: none; padding: .6rem 1rem; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef1f6; color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.off { background: #eceef2; color: #7d8596; }
.badge.folder { background: #e6eefb; color: var(--primary); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; background: #b9c0cc; }
.dot.on { background: #22a35a; box-shadow: 0 0 0 3px rgba(34,163,90,.15); }
.dot.warn { background: #e0a100; }
.dot.off { background: #b9c0cc; }

.alert { padding: .7rem 1rem; border-radius: 6px; margin: .75rem 0; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.text-err { color: var(--err); }
.text-warn { color: var(--warn); }
.grow { flex: 1; }

/* ---- form ---- */
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid #cbd2dd; border-radius: 6px; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,90,166,.25); border-color: var(--primary); }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
.form-row { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: 1fr 2fr; gap: .75rem; margin-bottom: 1rem; }
.form-grid .full, .form-grid .check { grid-column: 1 / -1; }
.search { min-width: 280px; }
input.switch { width: 18px; height: 18px; cursor: pointer; }

.btn { font: inherit; padding: .45rem .9rem; border-radius: 6px; border: 1px solid #cbd2dd; background: #fff; color: var(--text); cursor: pointer; }
.btn:hover:not(:disabled) { background: #f2f4f8; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1e18; }
.btn-danger-outline { color: var(--err); border-color: #e6b8b4; }
.btn-link { background: none; border: none; padding: 0; cursor: pointer; font: inherit; }
.confirm { display: inline-flex; align-items: center; gap: .35rem; }

.token-box { display: flex; align-items: flex-start; gap: .75rem; background: #f0f4fb; border: 1px dashed var(--primary); border-radius: 6px; padding: .75rem; margin-bottom: .75rem; }
.token-box code { font-size: 14px; word-break: break-all; flex: 1; }
.token-box pre { flex: 1; margin: 0; background: none; border: none; padding: 0; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); }
.login-card { width: 340px; display: flex; flex-direction: column; gap: .85rem; }
.brand-login { padding: 0 0 .5rem; }
.brand-login .brand-name { color: var(--text); }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Si è verificato un errore." }
