:root { color-scheme: light dark; --accent: #2563eb; --border: #8885; --bar: #8881; }
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; min-height: 100vh; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; background: var(--bar); border-bottom: 1px solid var(--border); position: sticky; top: 0; backdrop-filter: blur(6px); }
.brand { font-weight: 700; font-size: 1.1rem; color: inherit; text-decoration: none; }
.actions { display: flex; align-items: center; gap: .5rem; }
.actions form { margin: 0; display: block; }
.username { font-weight: 600; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: .4rem; background: transparent; color: inherit; cursor: pointer; text-decoration: none; }
.icon-btn:hover, .icon-btn[aria-current="page"] { background: var(--border); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Contenuto */
main { padding: 1.5rem 1rem; margin: 0 auto; }
main.narrow { max-width: 26rem; margin-top: 2rem; }
main.wide { max-width: 64rem; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
.hint { opacity: .75; font-weight: 400; font-size: .85rem; }
form { display: grid; gap: 1rem; margin-top: 1rem; }
.settings-form { max-width: 34rem; }
label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
input, select { width: 100%; min-width: 0; font: inherit; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: .4rem; background: transparent; color: inherit; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; font-weight: 600; padding: .65rem 1rem; border: 0; border-radius: .4rem; background: var(--accent); color: #fff; cursor: pointer; }
button.icon-btn { padding: 0; background: transparent; color: inherit; }
.alert, .notice { border-radius: .4rem; padding: .6rem .9rem; margin: 1rem 0; }
.alert { background: #dc262620; border: 1px solid #dc262680; }
.notice { background: #16a34a20; border: 1px solid #16a34a80; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.empty { border: 1px dashed var(--border); border-radius: .6rem; padding: 2rem 1rem; text-align: center; margin-top: 1rem; }
.empty p { margin: .25rem 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.btn { display: inline-block; font-weight: 600; padding: .65rem 1rem; border-radius: .4rem; background: var(--accent); color: #fff; text-decoration: none; }
.btn.secondary, button.secondary { background: transparent; color: inherit; border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--border); border-radius: .6rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .8rem; vertical-align: top; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; opacity: .75; background: var(--bar); }
.row-actions { white-space: nowrap; }
.row-actions > * { display: inline-grid; vertical-align: middle; }
.row-actions form { margin: 0; }
.icon-btn.danger { color: #dc2626; }
.icon-btn.danger:hover { background: #dc262626; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.badge.on { background: #16a34a30; color: #15803d; }
.badge.off { background: #8883; }
@media (prefers-color-scheme: dark) { .badge.on { color: #4ade80; } .icon-btn.danger { color: #f87171; } }

.settings-form fieldset { border: 1px solid var(--border); border-radius: .6rem; padding: 1rem; margin: 0; display: grid; gap: 1rem; }
.settings-form legend { font-weight: 700; padding: 0 .4rem; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem; gap: 1rem; } /* porta: spazio per 6 cifre */
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
label.check input { width: 1.1rem; height: 1.1rem; padding: 0; }
.form-actions { display: flex; gap: .75rem; align-items: center; }
.test-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.test-result { flex: 1 1 14rem; font-size: .9rem; overflow-wrap: anywhere; white-space: pre-line; }
.test-result.ok { color: #15803d; } .test-result.fail { color: #dc2626; }
@media (prefers-color-scheme: dark) { .test-result.ok { color: #4ade80; } .test-result.fail { color: #f87171; } }

code { font-family: ui-monospace, monospace; background: var(--bar); padding: .1rem .35rem; border-radius: .25rem; }
