:root { --pico-font-size: 15px; }
body { font-size: 15px; }
.topnav { padding: .2rem 1rem; border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: 1rem; }
.topnav ul li { padding: .3rem .4rem; }
.topnav .brand { text-decoration: none; }
.content { padding: 0 1rem 2rem; }
.narrow { max-width: 760px; margin: 0 auto; }
.login { max-width: 400px; margin-top: 8vh; text-align: center; }
.login form { text-align: left; }
.inline { display: inline; margin: 0; }
.inline button { margin: 0; }
.small, small { font-size: .85em; }
.muted { color: var(--pico-muted-color); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.pre { white-space: pre-wrap; }
.good { color: #3fb950; }
.bad { color: #f85149; }
.warn { color: #d29922; }
.danger { color: #f85149 !important; border-color: #f85149 !important; }
button.link { background: none; border: 0; padding: 0; margin: 0; color: var(--pico-primary); font-size: inherit; cursor: pointer; display: inline; width: auto; }
button.small, a.small[role=button], .small button { padding: .25rem .6rem; font-size: .8em; margin: 0; }
.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: rgba(63,185,80,.15); border: 1px solid #3fb950; }
.flash.bad { background: rgba(248,81,73,.15); border: 1px solid #f85149; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h2 { margin: 0; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-actions [role=button], .row-actions button { margin: 0; }
.filters { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.filters input, .filters select, .filters button { margin: 0; width: auto; }
table.compact td, table.compact th { padding: .35rem .5rem; }
td.actions { white-space: nowrap; font-size: .85em; }
td.actions form { display: inline; }
tr.muted td { opacity: .6; }

.badge { display: inline-block; padding: .1em .55em; border-radius: 999px; font-size: .75em; font-weight: 600; vertical-align: middle; letter-spacing: .02em; }
.badge.online { background: rgba(63,185,80,.2); color: #3fb950; }
.badge.offline { background: rgba(248,81,73,.2); color: #f85149; }
.badge.unknown { background: rgba(139,148,158,.2); color: #8b949e; }
.badge.job-pending { background: rgba(88,166,255,.2); color: #58a6ff; }
.badge.job-running { background: rgba(210,153,34,.2); color: #d29922; }
.badge.job-sent { background: rgba(163,113,247,.2); color: #a371f7; }
.badge.job-done { background: rgba(63,185,80,.2); color: #3fb950; }
.badge.job-failed, .badge.job-expired { background: rgba(248,81,73,.2); color: #f85149; }
.badge.job-cancelled { background: rgba(139,148,158,.2); color: #8b949e; }
.tag { display: inline-block; background: var(--pico-muted-border-color); border-radius: 4px; padding: 0 .4em; font-size: .75em; margin-right: .25em; }

.stats { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 110px; padding: .5rem 1rem; border-radius: 8px; background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); text-decoration: none; color: inherit; }
.stat .n { font-size: 1.8em; font-weight: 700; line-height: 1.1; }
.stat.online .n { color: #3fb950; } .stat.offline .n { color: #f85149; } .stat.unknown .n { color: #8b949e; } .stat.jobs .n { color: #58a6ff; }
.stat.actions { flex-direction: row; gap: .5rem; margin-left: auto; border: 0; background: none; }

.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.group { margin-bottom: 1.25rem; }
.group header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .4rem; }
.group h3 { margin: 0; font-size: 1.1em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.card { display: block; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--pico-muted-border-color); border-left-width: 4px; background: var(--pico-card-background-color); text-decoration: none; color: inherit; }
.card:hover { border-color: var(--pico-primary); }
.card.online { border-left-color: #3fb950; } .card.offline { border-left-color: #f85149; } .card.unknown { border-left-color: #8b949e; }
.card.disabled { opacity: .5; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: .3rem 0; border-bottom: 1px solid var(--pico-muted-border-color); line-height: 1.35; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid article { margin: 0; }
.detail-grid h4 { margin-bottom: .5rem; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
dl.kv dt { color: var(--pico-muted-color); }
dl.kv dd { margin: 0; }
.uptime { display: flex; gap: 1.5rem; }
.uptime .n { display: block; font-size: 1.4em; font-weight: 700; }
pre.out { max-height: 320px; overflow: auto; font-size: .8em; padding: .5rem .75rem; margin: 0; white-space: pre-wrap; }
details.inline-details { display: inline; }
details.inline-details summary { display: inline; cursor: pointer; }
details.inline-details form { display: inline-flex; gap: .3rem; align-items: center; }
details.inline-details input { margin: 0; width: 160px; padding: .2rem .4rem; height: auto; }
select[multiple] { height: auto; }
fieldset { margin-bottom: 1rem; }
label small { display: block; }

.badge.term-connected { background: rgba(63,185,80,.2); color: #3fb950; }
.badge.term-connecting { background: rgba(88,166,255,.2); color: #58a6ff; }
.badge.term-waiting { background: rgba(210,153,34,.2); color: #d29922; }
.badge.term-closed { background: rgba(139,148,158,.2); color: #8b949e; }
.badge.term-error, .badge.term-socket { background: rgba(248,81,73,.2); color: #f85149; }
.stat.terminals .n { color: #a371f7; }
#term { height: calc(100vh - 230px); min-height: 320px; background: #0d1117; padding: 6px; border-radius: 8px; border: 1px solid var(--pico-muted-border-color); }
#term .xterm { height: 100%; }
#term-mode { width: auto; margin: 0; padding: .25rem 2rem .25rem .6rem; font-size: .85em; height: auto; }
.term-readonly { background: rgba(139,148,158,.15); border: 1px solid var(--pico-muted-border-color); border-radius: 6px; padding: .4rem .8rem; margin-bottom: .5rem; font-size: .9em; }
.term-new { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.term-new label { margin: 0; }
.term-new input, .term-new select { margin: 0; }
.term-new button { margin: 0; white-space: nowrap; }

/* Iscrizioni alle notifiche */
.bell { text-decoration: none; font-size: .9em; cursor: help; }
.sub-inherited { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .8em; color: var(--pico-muted-color); }
.sub-inherited li { margin-bottom: .2rem; }
.sub-inherited strong { font-weight: 600; }

/* Riga informativa della sessione remota persistente (pagina del terminale) */
.term-remote { margin: .2rem 0 .4rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* versione di fianco al nome nella barra */
.brand .ver { color: var(--pico-muted-color); font-weight: 400; font-size: .72em; letter-spacing: .02em; }

/* Statistiche ed eventi */
.stats-filters { flex-wrap: wrap; align-items: flex-end; }
.stats-filters .f-item { display: flex; flex-direction: column; gap: .15rem; }
.stats-filters .f-item > label { margin: 0; }
.stats-filters .combo { min-width: 190px; }
.stats-filters input[type=number] { width: 6rem; }
.stat.text .n { font-size: 1.35em; white-space: nowrap; }
.chart-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.chart-head select { width: auto; margin: 0; padding: .2rem 2rem .2rem .5rem; height: auto; font-size: .85em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--pico-primary); }
th.sort-asc::after { content: " ▲"; font-size: .7em; }
th.sort-desc::after { content: " ▼"; font-size: .7em; }
button.link.exp { width: 1.2em; text-align: center; color: var(--pico-muted-color); }
tr.chk-row td { background: rgba(139,148,158,.06); font-size: .9em; }
tr.chk-row td.sub { padding-left: 1.4rem; }
tr.outage-open td { background: rgba(248,81,73,.08); }
tr.outage-open td:first-child { box-shadow: inset 3px 0 0 #f85149; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: .75rem; }

/* Allarmi e manutenzione */
.badge.sev-warning { background: rgba(210,153,34,.2); color: #d29922; }
.badge.sev-critical { background: rgba(248,81,73,.2); color: #f85149; }
.badge.state-firing { background: rgba(248,81,73,.2); color: #f85149; }
.badge.state-pending { background: rgba(210,153,34,.2); color: #d29922; }
.badge.state-ok { background: rgba(63,185,80,.2); color: #3fb950; }
.badge.maint-on { background: rgba(88,166,255,.2); color: #58a6ff; }
.badge.maint-off { background: rgba(139,148,158,.2); color: #8b949e; }
tr.sev-row-warning td:first-child { box-shadow: inset 3px 0 0 #d29922; }
tr.sev-row-critical td:first-child { box-shadow: inset 3px 0 0 #f85149; }
tr.maint-active td { background: rgba(88,166,255,.08); }
tr.maint-active td:first-child { box-shadow: inset 3px 0 0 #58a6ff; }
.stat.alerts .n { color: #8b949e; }
.stat.alerts.on .n { color: #f85149; }
.maint-banner { background: rgba(88,166,255,.1); border: 1px solid #58a6ff; border-radius: 6px; padding: .5rem .9rem; margin-bottom: 1rem; }
.maint-banner div { margin-top: .15rem; }
.rule-list { list-style: none; padding: 0; margin: .25rem 0 0; }
.rule-list li { padding: .25rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.rule-list li.muted { opacity: .6; }

/* Campi del form che compaiono solo quando servono */
.afield[hidden], .mfield[hidden], .tgt[hidden] { display: none !important; }
.dur { display: flex; gap: .4rem; align-items: center; }
.dur input { width: 6rem; margin: 0; }
.dur select, .dur .combo { width: auto; min-width: 7rem; margin: 0; }
.dow { display: flex; gap: .9rem; flex-wrap: wrap; margin-bottom: .5rem; }
.dow label { margin: 0; }

/* Approvazione dei comandi: arancione, per non confonderlo con il blu di "in coda". */
.badge.job-awaiting { background: rgba(240,136,62,.22); color: #f0883e; box-shadow: inset 0 0 0 1px rgba(240,136,62,.5); }
.stat.approvals .n { color: #8b949e; }
.stat.approvals.on { border-color: #f0883e; background: rgba(240,136,62,.12); }
.stat.approvals.on .n { color: #f0883e; }
article.approval { border: 1px solid #f0883e; border-left-width: 4px; background: rgba(240,136,62,.07); margin-bottom: 1rem; }
article.approval h3 { margin: 0; font-size: 1.1em; }
article.approval .row-actions button { margin: 0; width: auto; }
.approval-table pre.out.cmd { max-height: 9em; background: transparent; padding: 0; font-size: .85em; }
.approval-table td { vertical-align: top; }
.approval-table th:first-child, .approval-table td:first-child { width: 1.6rem; }
.approval-table input[type=checkbox] { margin: 0; }
.approval-note { border-left: 4px solid #f0883e; background: rgba(240,136,62,.1); border-radius: 6px; padding: .45rem .8rem; margin-bottom: .6rem; }

/* Spie della libreria: arancione per il freno (approvazione sempre), verde per il lasciapassare
   (comando sicuro), gli stessi colori che job e check usano per "attenzione" e "tutto bene". */
.badge.appr-always { background: rgba(240,136,62,.22); color: #f0883e; box-shadow: inset 0 0 0 1px rgba(240,136,62,.5); }
.badge.appr-never { background: rgba(63,185,80,.18); color: #3fb950; box-shadow: inset 0 0 0 1px rgba(63,185,80,.45); }

/* Le tre opzioni dell'approvazione: una riga per scelta, con la spiegazione allineata sotto. */
.approval-choice label { margin-bottom: .5rem; }
.approval-choice small { display: block; margin-left: 1.85em; }
.approval-choice code { font-size: .9em; padding: 0 .25em; }

/* Interfacce web dei dispositivi: proxy (dietro il login) e tunnel (nessuna autenticazione).
   L'avviso e' rosso perche' e' la cosa che non si deve leggere di sfuggita. */
.svc-warn { border-left: 4px solid #f85149; background: rgba(248,81,73,.1); border-radius: 6px; padding: .45rem .8rem; margin: .5rem 0; font-size: .9em; }
.svc-intro { max-width: 70ch; }
.svc-table td { vertical-align: top; }
.svc-copy { display: inline-flex; gap: .3rem; align-items: center; }
.svc-copy input { margin: 0; width: 13rem; padding: .2rem .4rem; height: auto; font-size: .85em; }
.svc-copy button { white-space: nowrap; }
/* Il tunnel sparisce quando il servizio e' di gruppo: al suo posto resta la spiegazione. */
#tunnel-box[hidden], #tunnel-group-note[hidden] { display: none !important; }
