:root {
    --bg: #0b1220;
    --panel: #121b2e;
    --panel-2: #172238;
    --border: #23314d;
    --text: #e6ebf5;
    --muted: #8a97b1;
    --armed: #f5a524;
    --off: #64748b;
    --ok: #22c55e;
    --alarm: #ef4444;
    --accent: #3b82f6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 50% -200px, #16233f 0%, var(--bg) 60%) fixed, var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: rgba(11, 18, 32, .85);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: auto; flex: none; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.topbar-right { display: flex; align-items: center; gap: 24px; }
.clock { text-align: right; font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; }
.clock-date { font-size: 12px; color: var(--muted); font-weight: 400; text-transform: capitalize; }
.link { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.link-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.link.down .link-dot { background: var(--alarm); box-shadow: 0 0 8px var(--alarm); }

/* MQTT status (admin) */
.mqtt-dot { border-radius: 50%; background: var(--off); flex: none; }
.mqtt-status {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 16px;
    border-left: 4px solid var(--off);
}
.mqtt-status .mqtt-dot { width: 14px; height: 14px; }
.mqtt-status-title { font-weight: 700; font-size: 16px; }
.mqtt-status-detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mqtt-status .btn { margin-left: auto; }
.mqtt-status[data-stato="connesso"] { border-left-color: var(--ok); }
.mqtt-status[data-stato="connesso"] .mqtt-dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.mqtt-status[data-stato="connesso"] .mqtt-status-title { color: var(--ok); }
.mqtt-status[data-stato="errore"] { border-left-color: var(--alarm); }
.mqtt-status[data-stato="errore"] .mqtt-dot { background: var(--alarm); box-shadow: 0 0 8px var(--alarm); }
.mqtt-status[data-stato="errore"] .mqtt-status-title { color: var(--alarm); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--panel-2)); }
.btn svg { width: 18px; height: 18px; flex: none; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.admin-main { min-width: 0; }
.sidenav {
    position: sticky; top: 90px;
    display: flex; flex-direction: column; gap: 2px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
}
.sidenav a {
    color: var(--text);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
}
.sidenav a.sub { padding-left: 28px; font-weight: 500; color: var(--muted); position: relative; }
.sidenav a.sub::before { content: ""; position: absolute; left: 14px; top: 50%; width: 6px; height: 1px; background: var(--border); }
.sidenav .nav-group { padding: 10px 12px; font-size: 14px; font-weight: 600; color: var(--text); }
.sidenav a:hover { background: var(--panel-2); color: var(--text); }
.sidenav a.active { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.page-title { margin: 0 0 6px; font-size: 26px; }
.page-sub { margin: 0 0 20px; color: var(--muted); }
.flash {
    margin: 0 0 18px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--panel));
    font-size: 14px;
}
.flash-err {
    border-color: color-mix(in srgb, var(--alarm) 55%, var(--border));
    background: color-mix(in srgb, var(--alarm) 12%, var(--panel));
}
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.admin-grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 16px; }
.admin-card, .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}
.admin-card h3 { margin: 0 0 6px; font-size: 17px; }
.admin-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.link-card { color: inherit; text-decoration: none; transition: border-color .15s; }
.link-card:hover { border-color: var(--accent); }
.panel-title { margin: 0 0 6px; font-size: 16px; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.hint a { color: var(--accent); }
code { font-family: Consolas, "SFMono-Regular", monospace; font-size: .92em; color: #c7d2fe; }
pre.code {
    margin: 0;
    background: #0a101c;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    overflow: auto;
    max-height: 320px;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 13px;
    color: #c7d2fe;
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 240px; }
.field.w-sm { flex: 0 0 140px; }
.field > span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type="text"], input[type="number"], input[type="password"], input[type="tel"], textarea, select {
    width: 100%;
    background: #0a101c;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.panel > .form-actions { margin-top: 16px; }
button.btn { cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f6fe0; }
.btn-danger { color: #fca5a5; }
.btn-danger:hover { border-color: var(--alarm); background: color-mix(in srgb, var(--alarm) 18%, var(--panel-2)); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-wa { color: #4ade80; text-decoration: none; }
.btn-wa:hover { border-color: #25d366; background: color-mix(in srgb, #25d366 18%, var(--panel-2)); }
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.grid-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.grid-table th {
    text-align: left;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    padding: 0 8px 10px;
    border-bottom: 1px solid var(--border);
}
.grid-table td { padding: 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); vertical-align: middle; }
.grid-table tr:last-child td { border-bottom: none; }
.grid-table tr.row-off td > * { opacity: .45; }
.grid-table tr.row-off td > .row-toggle { opacity: 1; border-color: var(--accent); }
.grid-table .center { text-align: center; }
.grid-table .muted { color: var(--muted); padding: 20px; }
.nowrap { white-space: nowrap; }
.code-cell { font-weight: 700; color: var(--muted); letter-spacing: 1px; font-size: 13px; white-space: nowrap; }
input.w-xs { min-width: 70px; }
input.w-sm { min-width: 90px; }
input.w-md { min-width: 100px; }
.grid-table select { min-width: 124px; }

/* Overall status */
.status {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 22px 26px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 6px solid var(--off);
}
.status-icon {
    width: 64px; height: 64px; flex: none;
    border-radius: 50%;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--off) 18%, transparent);
    color: var(--off);
}
.status-icon svg { width: 34px; height: 34px; }
.status-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.status-title { font-size: 28px; font-weight: 800; letter-spacing: .5px; margin: 2px 0; }
.status-detail { color: var(--muted); font-size: 14px; }
.status-btn { margin-left: auto; flex: none; }
.status-btn[hidden] { display: none; }
.status-btn:disabled { opacity: .6; cursor: wait; }
.status.is-armed { border-left-color: var(--armed); }
.status.is-armed .status-icon { color: var(--armed); background: color-mix(in srgb, var(--armed) 18%, transparent); }
.status.is-armed .status-title { color: var(--armed); }
.status.is-alarm {
    border-left-color: var(--alarm);
    background: linear-gradient(90deg, color-mix(in srgb, var(--alarm) 22%, var(--panel)), var(--panel));
    animation: alarm-glow 1.2s ease-in-out infinite;
}
.status.is-alarm .status-icon { color: #fff; background: var(--alarm); }
.status.is-alarm .status-title { color: var(--alarm); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 16px; }
.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
    border-top: 3px solid var(--accent);
}
.stat-value { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat-armed { border-top-color: var(--armed); }
.stat-off { border-top-color: var(--off); }
.stat-open { border-top-color: var(--alarm); }
.stat-alarm { border-top-color: var(--alarm); }
.stat-alarm.active .stat-value { color: var(--alarm); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 12px; }
.section-head h2 { margin: 0; font-size: 16px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.updated { font-size: 12px; color: var(--muted); }

/* Zone cards */
.zones { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.zone {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    position: relative;
    overflow: hidden;
}
.zone::before {
    content: "";
    position: absolute; inset: 0 auto 0 0;
    width: 4px;
    background: var(--off);
}
.zone.armed::before { background: var(--armed); }
.zone.alarm { border-color: var(--alarm); animation: alarm-glow 1.2s ease-in-out infinite; }
.zone.alarm::before { background: var(--alarm); }

.zone-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.zone-head > div:first-child { min-width: 0; }

/* Zone pictures: green when closed (LOW), red when open (HIGH) */
.zone-art {
    width: 72px; height: 72px; flex: none;
    border-radius: 14px;
    display: grid; place-items: center;
    background: #0a101c;
    border: 1px solid var(--border);
    color: var(--ok);
    transition: color .5s, border-color .5s, background .5s;
}
.zone-art svg { width: 56px; height: 56px; overflow: visible; }
.zone-art.is-open { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 45%, var(--border)); background: color-mix(in srgb, var(--alarm) 8%, #0a101c); }
.zone.alarm .zone-art { border-color: var(--alarm); box-shadow: 0 0 14px color-mix(in srgb, var(--alarm) 55%, transparent); }
.art-line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.art-gap { fill: #03060c; }
.art-leaf, .art-sash { transform-box: fill-box; transition: transform .9s cubic-bezier(.3, 1.3, .5, 1); }
.art-leaf { transform-origin: left center; }
.art-leaf rect, .art-sash rect { fill: color-mix(in srgb, currentColor 30%, #0e1626); stroke: currentColor; stroke-width: 2.5; }
.art-leaf circle { fill: currentColor; }
.art-sash path { stroke: currentColor; stroke-width: 2; }
.art-sash-l { transform-origin: left center; }
.art-sash-r { transform-origin: right center; }
.is-open .art-leaf { transform: scaleX(.32) skewY(-16deg); }
.is-open .art-sash-l { transform: scaleX(.3) skewY(-12deg); }
.is-open .art-sash-r { transform: scaleX(.3) skewY(12deg); }
.art-room { fill: currentColor; opacity: .16; transition: opacity .5s; }
.is-open .art-room { opacity: .3; }
.art-sensor { fill: currentColor; }
.art-wave { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; opacity: .2; }
.is-open .art-wave { animation: art-wave 1.5s ease-out infinite; }
.is-open .art-wave:nth-of-type(2) { animation-delay: .25s; }
.is-open .art-wave:nth-of-type(3) { animation-delay: .5s; }
@keyframes art-wave { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
.art-person { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; opacity: 0; transition: opacity .5s; }
.is-open .art-person { opacity: 1; }

/* Camera zones: state of the IVS rule on the camera (also in Configurazione > Ingressi). */
.zone-ivs { margin-top: 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.zone-ivs::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.ivs-stato { font-size: 12px; margin-top: 4px; }
.ivs-attiva { color: var(--armed); }
.ivs-spenta, .ivs-ignoto { color: var(--muted); }
.ivs-errore { color: var(--alarm); }

/* IVS rule editor: the shape drawn over the camera's snapshot (admin/ivs_regola.php) */
.ivs-editor-campi { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-bottom: 14px; }
.ivs-canvas { position: relative; background: #000; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; min-height: 200px; user-select: none; }
.ivs-canvas img { display: block; width: 100%; height: auto; pointer-events: none; }
.ivs-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; --tratto: 20; }
.ivs-forma { fill: color-mix(in srgb, var(--armed) 22%, transparent); stroke: var(--armed); stroke-width: var(--tratto); stroke-linejoin: round; }
polyline.ivs-forma { fill: none; stroke-width: calc(var(--tratto) * 1.5); }
.ivs-altra { fill: rgba(255, 255, 255, .06); stroke: rgba(255, 255, 255, .55); stroke-width: var(--tratto); stroke-dasharray: calc(var(--tratto) * 4) calc(var(--tratto) * 3); }
polyline.ivs-altra { fill: none; }
.ivs-punto { fill: #fff; stroke: var(--armed); stroke-width: var(--tratto); cursor: move; }
.ivs-primo { fill: var(--armed); }
.ivs-errore-foto { position: absolute; left: 12px; top: 12px; color: var(--muted); font-size: 13px; pointer-events: none; }
.zone-icon {
    width: 44px; height: 44px; flex: none;
    border-radius: 12px;
    display: grid; place-items: center;
    background: #0e1626;
    border: 1px solid var(--border);
    color: var(--muted);
}
.zone-icon svg { width: 24px; height: 24px; }
.zone-code { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; font-weight: 600; }
.zone-name { font-size: 17px; font-weight: 700; }

.zone-states { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.state {
    border-radius: 10px;
    padding: 10px 12px;
    background: #0e1626;
    border: 1px solid var(--border);
}
.state-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 4px; }
.state-value { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.state.armed .state-value { color: var(--armed); }
.state.off .state-value { color: var(--off); }
.state.ok .state-value { color: var(--ok); }
.state.open .state-value { color: var(--alarm); }
.state.alarm { background: color-mix(in srgb, var(--alarm) 18%, #0e1626); border-color: var(--alarm); }
.state.alarm .state-value { color: #fff; }

/* Output cards */
.outputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.output {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.output::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--off); }
.output.on { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.output.on::before { background: var(--accent); }
.output.on .zone-icon { color: var(--accent); }
.output-body { flex: 1; min-width: 0; }
.output-body .zone-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.output-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.output-state { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--off); white-space: nowrap; }
.output.on .output-state { color: var(--accent); }
.output-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.output-btn:disabled { opacity: .6; cursor: wait; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-armed { background: var(--armed); box-shadow: 0 0 8px var(--armed); }
.dot-off { background: var(--off); }
.dot-on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot-open { background: var(--alarm); box-shadow: 0 0 8px var(--alarm); }
.dot-ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-alarm { background: var(--alarm); box-shadow: 0 0 10px var(--alarm); animation: blink .8s steps(2, start) infinite; }

.empty { color: var(--muted); padding: 32px; text-align: center; border: 1px dashed var(--border); border-radius: 16px; grid-column: 1 / -1; }

.legend { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 28px; color: var(--muted); font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.push-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 24px; }
.push-box[hidden], .push-box .btn[hidden] { display: none; }
.push-box .hint { margin: 0; flex: 1 1 260px; }

.powered { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 16px 32px; color: var(--muted); font-size: 12px; }
.powered img { height: 30px; width: auto; }

@keyframes alarm-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 24px 2px rgba(239, 68, 68, .45); }
}
@keyframes blink { to { visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
    .zone.alarm, .status.is-alarm, .dot-alarm, .is-open .art-wave { animation: none; }
    .art-leaf, .art-sash { transition: none; }
}

@media (max-width: 760px) {
    /* The bar wraps instead of making the page wider than the phone (fixed notices would end up off screen). */
    .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
    .link { display: none; }
    .topbar-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
    .clock { font-size: 16px; }
    .btn span { display: none; }
    .btn { padding: 9px; }
    .admin-layout { grid-template-columns: 1fr; gap: 16px; }
    .sidenav { position: static; flex-direction: row; overflow-x: auto; }
    .sidenav a { white-space: nowrap; }
    .sidenav a.sub { padding-left: 12px; }
    .sidenav a.sub::before { display: none; }
    .sidenav .nav-group { display: none; }
    .form-actions .btn span, .grid-table .btn span { display: inline; }
    button.btn { padding: 9px 14px; }
    button.btn-sm { padding: 6px 10px; }
    .wrap { padding: 16px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .outputs { grid-template-columns: 1fr; }
    .status { padding: 18px; gap: 14px; flex-wrap: wrap; }
    .status-btn { margin-left: 0; width: 100%; justify-content: center; }
    .status-icon { width: 52px; height: 52px; }
    .status-title { font-size: 22px; }
}

/* Voice commands */
.voice-btn.listening { border-color: var(--alarm); background: color-mix(in srgb, var(--alarm) 20%, var(--panel-2)); animation: voice-pulse 1.2s ease-in-out infinite; }
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--alarm) 25%, transparent); } }
.voice-panel {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    width: min(520px, calc(100% - 32px));
    background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 14px; padding: 14px 16px; z-index: 20;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.voice-heard { color: var(--muted); font-size: 13px; font-style: italic; }
.voice-heard:empty { display: none; }
.voice-reply { font-weight: 600; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .voice-btn.listening { animation: none; } }

/* Scheduled commands */
.section-head[hidden], .schedules[hidden] { display: none; }
.schedules { display: flex; flex-direction: column; gap: 10px; }
.schedule {
    display: flex; align-items: center; gap: 16px;
    background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 14px; padding: 12px 16px;
}
.schedule-time { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 140px; }
.schedule-body { flex: 1; min-width: 0; }
.schedule-body .output-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
    .schedule { flex-wrap: wrap; gap: 6px 12px; }
    .schedule-time { min-width: 0; }
    .schedule-body { flex-basis: 100%; order: 3; }
    .schedule .btn { margin-left: auto; }
}

/* Camera events (dashboard) */
.section-tools { display: flex; align-items: center; gap: 12px; }
.cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.cam {
    background: var(--panel);
    border: 1px solid color-mix(in srgb, var(--armed) 55%, var(--border));
    border-radius: 16px;
    overflow: hidden;
}
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #03060c; cursor: zoom-in; }
.cam-view img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cam-view img:not([src]) { visibility: hidden; }
.cam-view:fullscreen { cursor: zoom-out; aspect-ratio: auto; }
.cam-badge {
    position: absolute; top: 10px; left: 10px;
    padding: 3px 8px; border-radius: 6px;
    background: var(--alarm); color: #fff;
    font-size: 11px; font-weight: 700; letter-spacing: 1px;
}
.cam-badge.foto { background: var(--panel-2); border: 1px solid var(--border); }
.cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.cam-info { padding: 12px 16px 14px; }
.cam-zones { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.cam-zones span { display: flex; align-items: center; gap: 6px; }
.cam-azioni { display: flex; justify-content: flex-end; margin-top: 10px; }
/* Camera buttons on the input cards and their viewer */
.zone-tools { display: flex; gap: 6px; margin-top: 8px; }
.cam-btn {
    width: 34px; height: 30px;
    display: grid; place-items: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0e1626;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    transition: border-color .15s, background .15s;
}
.cam-btn svg { width: 18px; height: 18px; }
.cam-btn:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, #0e1626); }
.cam-btn:disabled { opacity: .3; cursor: not-allowed; }
.viewer {
    position: fixed; inset: 0; z-index: 30;
    display: grid; place-items: center;
    padding: 16px;
    background: rgba(3, 6, 12, .82);
}
.viewer-box { width: min(960px, 100%); box-shadow: 0 16px 48px rgba(0, 0, 0, .6); }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.viewer-actions { display: flex; gap: 8px; flex: none; }
.cam-preview { display: block; max-width: 100%; border-radius: 10px; background: #03060c; }
#cam-anteprima { margin-top: 16px; }
.muted-cell { color: var(--muted); font-size: 13px; min-width: 120px; }
.grid-table.compact { min-width: 0; }

/* Login */
.logout-form { margin: 0; }
.login-wrap { max-width: 440px; padding-top: 48px; }
.login-icon {
    width: 56px; height: 56px; margin-bottom: 14px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.login-icon svg { width: 28px; height: 28px; }
.login-btn { justify-content: center; width: 100%; padding: 12px 14px; }
input.otp-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.login-alt { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14px; }
.login-alt a, .link-btn { color: var(--accent); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
.login-alt a:hover, .link-btn:hover { text-decoration: underline; }

/* Card time rules (admin) */
.orari-cell { min-width: 180px; font-size: 13px; }
.orari-cell .btn { margin-top: 6px; }

/* Alarm clip archive */
.nav-badge {
    min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-grid; place-items: center;
    border-radius: 10px; background: var(--alarm); color: #fff;
    font-size: 12px; font-weight: 700; font-style: normal;
}
.clip-giorno { margin: 24px 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.clips { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.clip { border-color: var(--border); }
.clip.nuovo { border-color: var(--alarm); }
button.cam-view { display: block; width: 100%; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
button.cam-view:disabled { cursor: default; }
.clip-durata {
    position: absolute; right: 10px; bottom: 10px;
    padding: 2px 7px; border-radius: 6px;
    background: rgba(3, 6, 12, .75);
    font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.clip-info { display: flex; align-items: flex-start; gap: 10px; }
.clip-testo { flex: 1; min-width: 0; }
.clip-elimina { flex: none; padding: 6px 8px; }
.clip-elimina svg { width: 16px; height: 16px; display: block; }
.clip-player { background: #03060c; }
.clip-player video, .clip-player img { display: block; width: 100%; max-height: 75vh; background: #03060c; }
/* Registro */
.registro { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.registro .dot { vertical-align: middle; margin-right: 4px; animation: none; }
.registro-filtro { margin: 0; }
.registro-filtro select { padding: 6px 10px; font-size: 13px; }
.registro-pagine { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
/* New-clip notice on the dashboard */
.avviso {
    position: fixed; right: 16px; top: 84px; z-index: 25;
    width: min(380px, calc(100% - 32px));
    display: flex; align-items: center; gap: 12px;
    background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--alarm);
    border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
@media (max-width: 760px) {
    .avviso { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; }
}
.avviso-testo { flex: 1; min-width: 0; }
.avviso-titolo { font-weight: 700; }
.avviso-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.avviso-chiudi { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px; }
