/* logger.innsoft.it — stile unico, nessuna dipendenza esterna */
:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e3e8ef;
    --text: #1b2333;
    --muted: #6b7486;
    --primary: #2563eb;
    --primary-ink: #ffffff;
    --sidebar: #111827;
    --sidebar-ink: #cbd2de;
    --sidebar-active: #1f2a3d;
    --error: #dc2626;
    --error-bg: #fde8e8;
    --fatal: #7f1d1d;
    --warn: #b45309;
    --warn-bg: #fdf1dc;
    --info: #1d4ed8;
    --info-bg: #e3ecfd;
    --ok: #15803d;
    --ok-bg: #dcf3e4;
    --neutral-bg: #eef1f5;
    --row-hover: #f1f5fb;
    --row-current: #e7efff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #161b22;
        --surface-2: #1c222b;
        --border: #2b333e;
        --text: #e3e8ef;
        --muted: #8b95a5;
        --primary: #4c8dff;
        --sidebar: #0a0d12;
        --sidebar-ink: #aab3c2;
        --sidebar-active: #1c2430;
        --error: #f87171;
        --error-bg: #3a1618;
        --fatal: #fca5a5;
        --warn: #f5b451;
        --warn-bg: #3a2a10;
        --info: #8ab4ff;
        --info-bg: #15264a;
        --ok: #4ade80;
        --ok-bg: #12301d;
        --neutral-bg: #232a34;
        --row-hover: #1b2230;
        --row-current: #1a2a46;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 600; }
h1:focus { outline: none; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 1.1rem 0 .5rem; font-weight: 600; }
code, pre { font-family: Consolas, "Cascadia Mono", monospace; font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.txt-error { color: var(--error); }

/* ── layout ─────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 228px; flex: 0 0 228px; background: var(--sidebar); color: var(--sidebar-ink);
    display: flex; flex-direction: column; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 600; font-size: 1.05rem; padding: .25rem .5rem 1.25rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
    background: var(--primary); color: #fff; font-weight: 700;
}
.brand-dim { color: #7d8799; font-weight: 400; margin-left: -.45rem; }
.brand.big { font-size: 1.4rem; color: var(--text); justify-content: center; padding-bottom: .5rem; }
.brand.small { color: var(--text); padding: 0; font-size: 1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: .6rem; color: var(--sidebar-ink); padding: .55rem .65rem; border-radius: 8px; }
.nav-item:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 1.1rem; text-align: center; opacity: .85; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #222b38; padding-top: .75rem; }
.user { font-size: .82rem; padding: 0 .65rem .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8c96a8; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { padding: 1.5rem 1.75rem 3rem; max-width: 1600px; width: 100%; }
.backdrop { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1.1rem; align-items: start; }
.cols > .card { margin-bottom: 0; }

/* ── controlli ──────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); padding: .45rem .8rem; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.btn-danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--border)); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { padding: .2rem .5rem; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; font-size: 1rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .25rem .4rem; }
.link { font-size: .88rem; }

input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: .42rem .6rem; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
textarea { width: 100%; resize: vertical; }
.toggle { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }

.form { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }
.form > label:not(.toggle) { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.form > label input, .form > label select, .form > label textarea { font-weight: 400; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); padding: .42rem .8rem; font: inherit; cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { min-width: 220px; flex: 1; }

.alert { border: 1px solid var(--border); background: var(--info-bg); color: var(--text); border-radius: 8px; padding: .65rem .85rem; margin-bottom: 1rem; }
.alert-error { background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 35%, transparent); color: var(--error); }
.alert-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* ── badge ──────────────────────────────────────────────── */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.lvl-fatal { background: var(--fatal); color: #fff; }
.lvl-error { background: var(--error-bg); color: var(--error); }
.lvl-warn { background: var(--warn-bg); color: var(--warn); }
.lvl-info { background: var(--info-bg); color: var(--info); }
.lvl-debug { background: var(--neutral-bg); color: var(--muted); }
.st-nuovo { background: var(--neutral-bg); color: var(--muted); }
.st-visto { background: var(--info-bg); color: var(--info); }
.st-risolto { background: var(--ok-bg); color: var(--ok); }
.st-ignorato { background: var(--neutral-bg); color: var(--muted); text-decoration: line-through; }
.badge.tag { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 500; }
a.badge.tag:hover { text-decoration: none; filter: brightness(1.1); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.inline-form input { flex: 1; min-width: 140px; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { border: 1px dashed var(--border); border-radius: 999px; padding: .3rem .75rem; }

/* ── tabelle ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tr.current { background: var(--row-current); }
.grid.compact td { padding: .3rem .5rem; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .chk { width: 32px; }
.grid.logs tbody tr { cursor: pointer; }
.grid .msg { word-break: break-word; min-width: 260px; }
.grid .app { white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.grid tr.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--primary) 18%, transparent); } to { background: transparent; } }
.exc { margin-right: .25rem; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.bulk { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; background: var(--row-current); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: 1rem; }
.bulk input { flex: 1; min-width: 160px; }

.split { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
.split.with-detail { grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr); }
.split > .card { margin-bottom: 0; }
.detail-card { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; align-self: start; }

/* ── dettaglio ──────────────────────────────────────────── */
.detail-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.field { margin-bottom: 1rem; }
.field > label { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; margin-bottom: .3rem; }
pre.block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem; margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
pre.stack { font-size: .78rem; }
pre.key { user-select: all; margin-top: .5rem; }
code.wrap { word-break: break-all; }

/* ── dashboard ──────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-error .tile-value { color: var(--error); }
.tile-open { border-left: 4px solid var(--error); }
.tile-warn .tile-value { color: var(--warn); }
.legend { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .82rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: .5rem; }
.dot.lvl-error { background: var(--error); }
.dot.lvl-warn { background: var(--warn); }
.dot.lvl-info { background: color-mix(in srgb, var(--info) 45%, transparent); }
.chart { width: 100%; height: 160px; display: block; }
.chart .bar-bg { fill: transparent; }
.chart g:hover .bar-bg { fill: var(--row-hover); }
.chart .bar-error { fill: var(--error); }
.chart .bar-warn { fill: var(--warn); }
.chart .bar-other { fill: color-mix(in srgb, var(--info) 45%, transparent); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: .35rem; }

/* ── pagine senza menu ──────────────────────────────────── */
.empty-layout { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.center-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.center-card h1 { margin-bottom: .5rem; }
.center-card .btn { margin-top: 1rem; }
.center-card.login .alert { text-align: left; margin-top: 1rem; }

/* ── mobile ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .split.with-detail { grid-template-columns: 1fr; }
    .detail-card { position: static; max-height: none; }
}
@media (max-width: 760px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
    .menu-open .sidebar { transform: none; }
    .menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
    .topbar { display: flex; align-items: center; gap: .5rem; padding: .6rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
    .page { padding: 1rem 16px 2rem; }
    .cols { grid-template-columns: 1fr; }
    .filters > * { flex: 1 1 100%; }
    .filters input[type=search] { min-width: 0; }
    .grid .msg { min-width: 200px; }
}

/* ── errori Blazor ──────────────────────────────────────── */
#blazor-error-ui {
    background: #fff7d6; color: #333; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    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: "Si è verificato un errore."; }
