:root {
    --bg: #08101c;
    --surface: #0d1828;
    --surface-2: #111f32;
    --surface-3: #17283e;
    --border: rgba(255,255,255,.09);
    --text: #eff6ff;
    --muted: #8ea2ba;
    --accent: #45a6ff;
    --cyan: #39d4da;
    --ok: #39d98a;
    --warn: #f2c94c;
    --alarm: #ff5d68;
    --shadow: 0 18px 55px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
.monitor-app { min-height: 100vh; }
.app-loading-shell, .startup-loader { min-height: 100vh; display:flex; align-items:center; justify-content:center; gap:14px; background:var(--bg); color:var(--muted); }
.startup-ring, .pulse-ring { width:26px; height:26px; border-radius:50%; border:3px solid rgba(255,255,255,.14); border-top-color:var(--accent); animation:spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand-mark { display:grid; place-items:center; width:56px; height:56px; border-radius:16px; background:linear-gradient(145deg,#5fc2ff,#197ae8); color:white; font-weight:800; letter-spacing:-.04em; box-shadow:0 10px 32px rgba(28,133,238,.25); }
.brand-mark.small { width:42px; height:42px; border-radius:12px; font-size:.92rem; }
.brand-kicker, .eyebrow { color:#6ec7ff; letter-spacing:.16em; font-size:.69rem; font-weight:800; }

/* Login */
.login-screen { position:relative; min-height:100vh; display:grid; place-items:center; padding:32px; overflow:hidden; background:radial-gradient(circle at 18% 15%, rgba(33,129,230,.19), transparent 32%), radial-gradient(circle at 88% 82%, rgba(57,212,218,.09), transparent 34%), #08101c; }
.login-background-grid { position:absolute; inset:0; opacity:.12; background-image:linear-gradient(rgba(255,255,255,.1) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.1) 1px,transparent 1px); background-size:48px 48px; mask-image:linear-gradient(to bottom,black,transparent 80%); }
.login-card { position:relative; width:min(480px,100%); padding:38px; background:rgba(13,24,40,.92); border:1px solid var(--border); border-radius:26px; box-shadow:var(--shadow); backdrop-filter:blur(18px); }
.brand-block { display:flex; align-items:center; gap:16px; }
.brand-block h1 { margin:3px 0 0; font-size:1.65rem; letter-spacing:-.03em; }
.login-intro { color:var(--muted); margin:26px 0 22px; line-height:1.55; }
.login-form { display:grid; gap:16px; }
.login-form label { display:grid; gap:8px; }
.login-form label span { color:#b8c7d9; font-size:.8rem; font-weight:700; }
.login-form input { width:100%; color:var(--text); background:#091522; border:1px solid rgba(255,255,255,.11); border-radius:12px; padding:13px 14px; outline:none; transition:.2s; }
.login-form input:focus { border-color:rgba(69,166,255,.7); box-shadow:0 0 0 3px rgba(69,166,255,.12); }
.login-form button, .dashboard-error-card button { margin-top:8px; border:0; border-radius:12px; padding:14px 16px; display:flex; align-items:center; justify-content:space-between; gap:10px; background:linear-gradient(135deg,#258df0,#46b0ff); color:white; font-weight:800; cursor:pointer; box-shadow:0 12px 28px rgba(37,141,240,.2); }
.login-form button:disabled { opacity:.65; cursor:wait; }
.spinner-mini { width:15px; height:15px; border:2px solid rgba(255,255,255,.4); border-top-color:white; border-radius:50%; animation:spin .7s linear infinite; }
.form-alert { margin-bottom:16px; color:#ffd7da; background:rgba(255,93,104,.12); border:1px solid rgba(255,93,104,.26); padding:12px 14px; border-radius:11px; font-size:.88rem; }
.login-footnote { color:#60758d; font-size:.75rem; text-align:center; margin-top:24px; }

/* Dashboard */
.dashboard-page { min-height:100vh; background:#08101c; }
.topbar { height:76px; display:flex; align-items:center; justify-content:space-between; gap:24px; padding:0 28px; background:#0a1524; border-bottom:1px solid var(--border); }
.topbar-brand { display:flex; align-items:center; gap:13px; min-width:260px; }
.topbar-title { font-size:1rem; font-weight:750; margin-top:2px; }
.topbar-meta { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.device-chip { display:flex; flex-direction:column; padding:7px 12px; min-width:104px; background:rgba(255,255,255,.035); border:1px solid var(--border); border-radius:10px; }
.device-chip span { color:var(--muted); font-size:.62rem; text-transform:uppercase; letter-spacing:.08em; }
.device-chip strong { font-size:.82rem; margin-top:2px; }
.connection-badge { display:flex; align-items:center; gap:8px; border-radius:999px; padding:9px 13px; font-size:.72rem; font-weight:850; letter-spacing:.05em; border:1px solid var(--border); }
.connection-badge.online { color:#8cf2bd; background:rgba(57,217,138,.09); }
.connection-badge.delayed { color:#ffe387; background:rgba(242,201,76,.09); }
.connection-badge.offline { color:#ff9ba2; background:rgba(255,93,104,.09); }
.status-dot { width:8px; height:8px; border-radius:50%; background:currentColor; box-shadow:0 0 12px currentColor; }
.logout-button { border:1px solid var(--border); background:transparent; color:#9eb0c4; border-radius:10px; padding:9px 12px; cursor:pointer; }
.dashboard-grid { display:grid; grid-template-columns:minmax(360px, 38%) minmax(0,62%); gap:16px; padding:16px; height:calc(100vh - 76px); }
.telemetry-panel, .map-panel { min-height:0; background:var(--surface); border:1px solid var(--border); border-radius:18px; box-shadow:0 12px 35px rgba(0,0,0,.16); }
.telemetry-panel { padding:22px; overflow:auto; }
.panel-heading, .map-header { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.panel-heading h1, .map-header h2 { margin:3px 0 0; font-size:1.27rem; letter-spacing:-.02em; }
.last-update { text-align:right; }
.last-update span { display:block; color:var(--muted); font-size:.67rem; text-transform:uppercase; letter-spacing:.07em; }
.last-update strong { display:block; font-size:.78rem; margin-top:4px; font-weight:700; color:#c9d7e8; }
.temperature-hero { margin:18px 0 14px; border-radius:16px; padding:20px; border:1px solid var(--border); background:linear-gradient(145deg,#122238,#0e1a2c); position:relative; overflow:hidden; }
.temperature-hero::after { content:""; position:absolute; width:180px; height:180px; border-radius:50%; right:-70px; top:-90px; background:currentColor; opacity:.08; }
.temperature-hero.ok { color:var(--ok); }
.temperature-hero.alarm { color:var(--alarm); }
.temperature-hero.neutral { color:var(--accent); }
.temperature-label { color:#b9cadc; font-size:.78rem; font-weight:700; }
.temperature-value { color:var(--text); font-size:3.15rem; line-height:1; font-weight:800; letter-spacing:-.055em; margin:9px 0; }
.temperature-value span { color:currentColor; font-size:1.25rem; margin-left:7px; letter-spacing:0; }
.temperature-range { color:var(--muted); font-size:.72rem; }
.metric-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.metric-card { min-height:70px; display:flex; align-items:center; gap:11px; padding:12px; border-radius:13px; background:var(--surface-2); border:1px solid rgba(255,255,255,.065); }
.metric-icon { flex:0 0 36px; width:36px; height:36px; display:grid; place-items:center; border-radius:10px; background:#152a43; color:#6bc3ff; font-size:.59rem; font-weight:850; letter-spacing:.02em; }
.metric-card.ok .metric-icon { color:var(--ok); background:rgba(57,217,138,.11); }
.metric-card.warn .metric-icon { color:var(--warn); background:rgba(242,201,76,.11); }
.metric-card.alarm .metric-icon { color:var(--alarm); background:rgba(255,93,104,.11); }
.metric-copy { min-width:0; }
.metric-copy span { display:block; color:var(--muted); font-size:.67rem; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.metric-copy strong { display:block; color:var(--text); font-size:1rem; white-space:nowrap; }
.metric-copy small { color:#8fa6be; font-size:.65rem; font-weight:700; margin-left:4px; }
.gps-summary { margin-top:12px; display:grid; gap:9px; padding:13px; border-radius:13px; background:#091522; border:1px solid rgba(255,255,255,.06); }
.gps-summary div { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.gps-summary span { color:var(--muted); font-size:.68rem; }
.gps-summary strong { color:#cbd9e8; font-size:.72rem; font-weight:700; text-align:right; }
.map-panel { display:grid; grid-template-rows:auto minmax(0,1fr) auto; overflow:hidden; }
.map-header { padding:20px 22px 16px; }
.map-legend { display:flex; flex-wrap:wrap; gap:13px; align-items:center; color:var(--muted); font-size:.68rem; }
.map-legend span { display:flex; align-items:center; gap:6px; }
.legend-line { width:22px; height:4px; border-radius:99px; background:#258df0; }
.legend-dot { width:9px; height:9px; border-radius:50%; background:#39d4da; box-shadow:0 0 0 4px rgba(57,212,218,.14); }
.transport-map { width:100%; height:100%; min-height:420px; background:#0a1421; z-index:0; }
.map-footer { padding:13px 20px; display:grid; grid-template-columns:1.4fr .8fr 1fr; gap:16px; border-top:1px solid var(--border); background:#0b1726; }
.map-footer div { min-width:0; }
.map-footer span { display:block; color:var(--muted); font-size:.62rem; text-transform:uppercase; letter-spacing:.06em; }
.map-footer strong { display:block; margin-top:4px; color:#dbe7f4; font-size:.75rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.text-ok { color:var(--ok)!important; }
.text-warn { color:var(--warn)!important; }
.last-position-marker-wrap { background:transparent!important; border:0!important; }
.last-position-marker { width:34px; height:34px; border-radius:50%; display:grid; place-items:center; background:rgba(57,212,218,.18); animation:pulseMarker 1.8s ease-out infinite; }
.last-position-core { width:13px; height:13px; border-radius:50%; background:#39d4da; border:3px solid white; box-shadow:0 2px 10px rgba(0,0,0,.35); }
@keyframes pulseMarker { 0%,100%{box-shadow:0 0 0 0 rgba(57,212,218,.28)} 50%{box-shadow:0 0 0 14px rgba(57,212,218,0)} }
.leaflet-container { font-family:inherit; background:#0a1421; }
.leaflet-control-zoom a { background:#0d1b2c!important; color:#eaf4ff!important; border-color:rgba(255,255,255,.08)!important; }
.dashboard-loading, .dashboard-error-shell { min-height:100vh; display:flex; align-items:center; justify-content:center; gap:14px; background:var(--bg); color:var(--muted); }
.dashboard-error-card { width:min(470px,calc(100% - 32px)); padding:30px; text-align:center; background:var(--surface); border:1px solid var(--border); border-radius:20px; box-shadow:var(--shadow); }
.dashboard-error-card .error-symbol { width:48px; height:48px; margin:0 auto 14px; display:grid; place-items:center; border-radius:50%; color:#ff9ba2; background:rgba(255,93,104,.11); font-size:1.4rem; font-weight:900; }
.dashboard-error-card h1 { font-size:1.35rem; }
.dashboard-error-card p { color:var(--muted); }
.dashboard-error-card button { width:100%; justify-content:center; }
#blazor-error-ui { display:none; position:fixed; bottom:0; left:0; right:0; z-index:2000; background:#541b22; color:white; padding:10px 15px; }
.not-found { padding:40px; }
@media(max-width:1050px){ .dashboard-grid{grid-template-columns:1fr;height:auto}.map-panel{min-height:650px}.topbar{height:auto;min-height:76px;padding:14px 18px}.dashboard-grid{min-height:calc(100vh - 76px)} }
@media(max-width:700px){ .topbar{align-items:flex-start}.topbar-meta{display:none}.dashboard-grid{padding:8px;gap:8px}.telemetry-panel{padding:16px}.metric-grid{grid-template-columns:1fr 1fr}.map-header{display:block}.map-legend{margin-top:12px}.map-footer{grid-template-columns:1fr}.login-screen{padding:16px}.login-card{padding:26px 22px}.temperature-value{font-size:2.7rem} }

/* Storico temperature */
.temperature-chart-panel { margin:0 16px 16px; padding:22px; background:var(--surface); border:1px solid var(--border); border-radius:18px; box-shadow:0 12px 35px rgba(0,0,0,.16); }
.temperature-chart-header { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:18px; }
.temperature-chart-header h2 { margin:3px 0 0; font-size:1.27rem; letter-spacing:-.02em; }
.temperature-chart-legend { display:flex; flex-wrap:wrap; gap:16px; color:var(--muted); font-size:.72rem; }
.temperature-chart-legend span { display:flex; align-items:center; gap:7px; }
.chart-dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
.chart-dot.ble { background:#39d4da; box-shadow:0 0 10px rgba(57,212,218,.35); }
.chart-dot.pt100 { background:#f2a94c; box-shadow:0 0 10px rgba(242,169,76,.25); }
.chart-line.limit { width:22px; border-top:2px dashed rgba(255,93,104,.75); }
.temperature-chart-wrap { width:100%; height:330px; border-radius:14px; background:#091522; border:1px solid rgba(255,255,255,.06); overflow:hidden; }
.temperature-chart { width:100%; height:100%; display:block; overflow:visible; }
.chart-grid-line { stroke:rgba(255,255,255,.08); stroke-width:1; vector-effect:non-scaling-stroke; }
.chart-limit-line { stroke:rgba(255,93,104,.62); stroke-width:1.5; stroke-dasharray:7 7; vector-effect:non-scaling-stroke; }
.chart-series { fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; vector-effect:non-scaling-stroke; }
.chart-series-ble { stroke:#39d4da; }
.chart-series-pt100 { stroke:#f2a94c; }
.chart-axis-label, .chart-time-label { fill:#8298b0; font-size:13px; font-family:Inter,ui-sans-serif,system-ui,sans-serif; }
.temperature-chart-empty { height:220px; display:grid; place-items:center; border-radius:14px; color:var(--muted); background:#091522; border:1px solid rgba(255,255,255,.06); }
@media(max-width:700px){ .temperature-chart-panel{margin:0 8px 8px;padding:16px}.temperature-chart-header{display:block}.temperature-chart-legend{margin-top:12px}.temperature-chart-wrap{height:280px} }


/* Etichette grafico temperature */
.chart-labels {
    position: relative;
    height: 34px;
    margin-top: 0;
    overflow: visible;
}

.chart-y-labels {
    position: absolute;
    left: 0;
    top: -294px;
    height: 238px;
    width: 62px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 12px;
    line-height: 1;
    color: #8fa6bd;
    pointer-events: none;
}

.chart-x-labels {
    position: absolute;
    left: 70px;
    right: 25px;
    top: 9px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    line-height: 1;
    color: #8fa6bd;
    white-space: nowrap;
}

.temperature-chart-wrap {
    overflow: visible;
    margin-bottom: 38px;
}

@media(max-width:700px) {
    .chart-x-labels {
        left: 54px;
        right: 12px;
        font-size: 10px;
    }

    .chart-y-labels {
        font-size: 10px;
        width: 48px;
    }
}

/* Download report CSV */
.report-download-button {
    border: 1px solid rgba(69,166,255,.35);
    background: rgba(69,166,255,.08);
    color: #a8d8ff;
    border-radius: 10px;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 750;
    white-space: nowrap;
    transition: .18s ease;
}
.report-download-button:hover:not(:disabled) {
    background: rgba(69,166,255,.15);
    border-color: rgba(69,166,255,.55);
    color: #d8efff;
}
.report-download-button:disabled {
    opacity: .55;
    cursor: wait;
}

