:root {
  --bg: #07090d; --card: #10141d; --card2: #161b26; --line: #1f2635; --fg: #eef1f6; --muted: #8b94a7; --subtle: #5c6578;
  --accent: #ff9900; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --blue: #38bdf8;
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); overflow-x: hidden; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); min-height: 100vh;
  padding: 0 0 calc(24px + var(--safe-b)); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
b { font-weight: 650; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(7, 9, 13, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; font-size: 20px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: #111; }
.logo svg { width: 22px; height: 22px; fill: #111; stroke: none; }
.iconbtn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--card2); color: var(--fg); cursor: pointer; }

/* One column never wider than the screen: a long site name is cut with "…" instead of widening the page */
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card { display: block; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.site-main a { display: block; min-width: 0; overflow: hidden; }
.list li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
a.card:active { transform: scale(.985); background: var(--card2); }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 4px 0; font-weight: 750; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.center a { color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.alert { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .35); color: #fecaca; border-radius: 12px; padding: 10px 12px; }
.warn-text { color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-bottom: 6px; }
.stats > div { background: var(--card2); border-radius: 14px; padding: 12px; }
.stats b { display: block; font-size: clamp(18px, 5.4vw, 22px); letter-spacing: -.02em; white-space: nowrap; }
.stats span { font-size: 12px; color: var(--muted); }

details { border-top: 1px solid var(--line); }
details:first-of-type { margin-top: 6px; }
summary { list-style: none; cursor: pointer; padding: 14px 2px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: -4px 4px 0 auto; transition: transform .2s; }
details[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.services summary .muted { font-weight: 400; }

.bars { list-style: none; display: grid; gap: 12px; padding-bottom: 12px; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--card2); margin: 6px 0 3px; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.bar em { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--muted); border-radius: 1px; }

.list { list-style: none; padding-bottom: 8px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li > :last-child { text-align: right; }
.list.compact li { padding: 8px 2px; }
.list.compact { margin-top: 8px; }

.server .name { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server .row + .row { margin-top: 4px; }
.server .bottom { margin-top: 12px; align-items: flex-end; }
.server .cpu b, .server .price b { display: block; font-size: 20px; }
.server .price { text-align: right; }
.spark { flex: 1; height: 34px; max-width: 150px; }
.spark polyline { fill: none; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--card2); white-space: nowrap; }
.state i { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.state.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.state.warn i { background: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card2); color: var(--fg); font: inherit; font-weight: 650; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .4); }
.btn:disabled { opacity: .45; }
.actions { display: grid; gap: 10px; }

.login { display: grid; gap: 14px; margin-top: 10vh; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input[type=password], input[name=code] { font: inherit; font-size: 18px; color: var(--fg); background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; width: 100%; }
input[name=code] { letter-spacing: .3em; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg { display: inline-flex; background: var(--card2); border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--line); color: var(--fg); }
figure { margin-top: 8px; }
figcaption { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
figcaption b { color: var(--fg); }
.chart { height: 120px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .area { fill: rgba(56, 189, 248, .14); stroke: none; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.chart .peak { fill: none; stroke: rgba(255, 153, 0, .55); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .label { position: absolute; left: 4px; top: 2px; font-size: 12px; font-weight: 500; line-height: 1; color: var(--muted); background: rgba(16, 20, 29, .75); padding: 2px 5px; border-radius: 5px; pointer-events: none; }
.seg.ranges { display: flex; width: 100%; margin: 0 0 12px; }
.seg.ranges button { flex: 1; padding: 8px 2px; white-space: nowrap; }
.chart.empty::after { content: 'Nessun dato'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--subtle); font-size: 13px; }

.job[hidden] { display: none; }
.job { margin-top: 14px; padding: 12px; background: var(--card2); border-radius: 14px; display: flex; gap: 12px; }
.job ol { list-style: none; display: grid; gap: 4px; font-size: 14px; }
.job ol li:last-child { font-weight: 650; }
.job.done .spinner { display: none; }
.spinner { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog.sheet { margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92vh; border: 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--fg); padding: 0; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .6); }
dialog.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-body { padding: 10px 16px calc(16px + var(--safe-b)); display: grid; gap: 12px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 4px; }
.sheet h2 { font-size: 20px; }
.sizes { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.size { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card2); border: 2px solid transparent; color: var(--fg); font-size: 15px; cursor: pointer; }
.size input { accent-color: var(--accent); width: 20px; height: 20px; }
.size > span { display: grid; }
.size .right { margin-left: auto; text-align: right; }
.size:has(input:checked:not(:disabled)) { border-color: var(--accent); }
.size.current { opacity: .6; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

@media (min-width: 700px) {
  main { padding-top: 22px; }
  dialog.sheet { margin: auto; border-radius: 22px; }
}

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.meter { display: grid; grid-template-columns: 1fr auto; font-size: 13px; color: var(--muted); }
.meter b { color: var(--fg); }
.meter i { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--card2); margin-top: 4px; overflow: hidden; }
.meter em { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.meter.warn em { background: var(--warn); }
.meter.bad em { background: var(--bad); }
.meter.bad b { color: #fca5a5; }

.group { margin: 14px 2px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.sites { list-style: none; }
.site { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--line); }
.sites .site:first-child { border-top: 0; }
.site .dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--subtle); }
.site.up .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(34, 197, 94, .16); }
.site.down .dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(239, 68, 68, .2); }
.site.unsure .dot { background: var(--warn); }
.site-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.site-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-main .aliases { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-side { flex: none; display: flex; align-items: center; gap: 8px; }
.site-side .next { min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.iconbtn.sm { width: 38px; height: 38px; border-radius: 11px; }
.iconbtn.sm svg { width: 18px; height: 18px; }
.iconbtn.spin svg { animation: spin .8s linear infinite; }
.bad-text { color: #fca5a5; }

.state.bad i { background: var(--bad); box-shadow: 0 0 0 3px rgba(239, 68, 68, .2); }
.actions.two { grid-template-columns: 1fr 1fr; }
.chart.tall { height: 150px; }
.chart .miss { fill: rgba(239, 68, 68, .75); }
.chart .miss-soft { fill: rgba(245, 158, 11, .6); }
.strip-head { margin: 10px 0 6px; }
.strip { display: flex; gap: 3px; }
.strip i, .legend i { flex: 1; height: 28px; border-radius: 4px; background: var(--card2); }
.strip i.up, .legend i.up { background: var(--ok); }
.strip i.partial, .legend i.partial { background: var(--warn); }
.strip i.down, .legend i.down { background: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.log { list-style: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.log li { display: grid; grid-template-columns: auto 44px 1fr; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); align-items: baseline; }
.log li:first-child { border-top: 0; }
.log .t { color: var(--muted); }
.log .c { font-weight: 650; }
.log .m { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li.ok .c { color: var(--ok); }
.log li.warn .c, .log li.warn .m { color: var(--warn); }
.log li.bad .c, .log li.bad .m { color: #fca5a5; }
.site-main a.stretch { color: inherit; }
/* The whole row opens the site's page; the check button stays on top of it */
.site { position: relative; }
.site a.stretch::after { content: ''; position: absolute; inset: 0; }
.site-side { position: relative; z-index: 1; }
