/* Praesidium — tema dark */
:root {
    color-scheme: dark;
    --bg: #0f1216;
    --bg-elev: #161b21;
    --bg-elev-2: #1d232b;
    --border: #2a323c;
    --text: #e3e8ee;
    --text-muted: #8b96a3;
    --accent: #3b9eff;
    --accent-strong: #1f84ea;
    --ok: #3fbf7f;
    --warn: #e5a84b;
    --error: #ef5f5f;
    --info: #5fb3ef;
    --radius: 8px;
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 600; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--text-muted); font-weight: 600; }
code { font-family: var(--mono); font-size: .9em; color: #c9d4e0; }
small, .small { font-size: .8rem; }
.muted { color: var(--text-muted); }
.text-warn { color: var(--warn); }
.text-error { color: var(--error); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex: 0 0 220px;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1rem .75rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--accent); margin-bottom: 1.25rem; }
.brand-lg { font-size: 1.4rem; justify-content: center; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); padding: .45rem .7rem; border-radius: 6px; }
.nav a:hover { background: var(--bg-elev-2); text-decoration: none; }
.nav a.active { background: var(--accent-strong); color: #fff; }
.nav-section { margin: 1rem .7rem .3rem; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .6rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}
.topbar form { margin: 0; }
.topbar .user { color: var(--text); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.topbar .user small { color: var(--text-muted); }
.tenant-select { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); }
.tenant-select select { min-width: 240px; }
.spacer { flex: 1; }
.content { padding: 1.5rem; max-width: 1500px; }

/* login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.login-card h1 { text-align: center; font-size: 1.1rem; color: var(--text-muted); }

/* card, tiles */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.card h2:first-child { margin-top: 0; }
.card.narrow { max-width: 420px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.tile { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.tile-value { font-size: 1.8rem; font-weight: 600; }
.tile-label { color: var(--text-muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols-wide-left { grid-template-columns: 3fr 2fr; align-items: start; }
@media (max-width: 1100px) { .cols, .cols-wide-left { grid-template-columns: 1fr; } }

/* forms */
label { display: flex; flex-direction: column; gap: .25rem; color: var(--text-muted); margin-bottom: .6rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
input, select, textarea {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .4rem .55rem; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input:disabled { opacity: .6; }
textarea { width: 100%; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.w-sm { width: 90px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .75rem 0; }
.toolbar label { flex-direction: row; align-items: center; margin: 0; }
.search { min-width: 240px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .25rem 1rem; max-height: 320px; overflow: auto; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; margin-bottom: .75rem; }
.checklist label { margin: 0; }

/* buttons */
.btn {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--bg-elev-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .4rem .85rem; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-danger { background: #8c2a2a; border-color: var(--error); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .15rem .5rem; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; margin-top: .5rem; }

/* tables */
.grid { width: 100%; border-collapse: collapse; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: .75rem; }
.grid th, .grid td { padding: .45rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid th { background: var(--bg-elev-2); color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.grid tbody tr:hover { background: #1a2028; }
.grid td input, .grid td select { width: 100%; }
.grid .num { text-align: right; }
.row-disabled { opacity: .55; }
.row-selected { background: #1c2a3a !important; }
.grid tbody tr[onclick], .grid tbody tr { cursor: default; }

/* key/value */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .3rem .75rem; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

/* badges, alerts */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid transparent; }
.badge-ok { background: #173a2a; color: var(--ok); border-color: #24583f; }
.badge-error { background: #3d1c1c; color: var(--error); border-color: #6b2c2c; }
.badge-warn { background: #3b2e17; color: var(--warn); border-color: #66501f; }
.badge-info { background: #172f40; color: var(--info); border-color: #24506d; }
.badge-muted { background: #22282f; color: var(--text-muted); border-color: var(--border); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; }
.dot-ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-off { background: #4a5460; }
.alert { padding: .6rem .9rem; border-radius: 6px; border: 1px solid; margin: 0 0 1rem; }
.alert-ok { background: #13281e; border-color: #24583f; color: #bfe9d2; }
.alert-error { background: #2e1616; border-color: #6b2c2c; color: #f4c4c4; }

pre.output {
    background: #0a0d10; border: 1px solid var(--border); border-radius: 6px;
    padding: .6rem; max-height: 360px; overflow: auto;
    font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; word-break: break-all;
}
pre.output-err { color: #f2b8b8; }

/* errori Blazor */
#blazor-error-ui {
    background: #3d1c1c; color: var(--text);
    bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .4);
    display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Errore"; }
.validation-message { color: var(--error); }

/* codice QR del 2FA: scuro su chiaro, leggibile da tutte le app */
.qr { background: #fff; padding: .5rem; border-radius: var(--radius); width: max-content; margin-bottom: .6rem; }
.qr svg { display: block; width: 200px; height: 200px; }
