/* IT Monitor - stile della dashboard */
:root {
  --bg: #f4f6f9; --card: #fff; --text: #1f2937; --muted: #6b7280; --border: #e5e7eb;
  --primary: #1d4ed8; --primary-dark: #1e40af; --top: #111827;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --danger: #b91c1c; --danger-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe; --neutral-bg: #f3f4f6;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 12px; }
.mt { margin-top: 20px; }
code, pre, .code { font-family: Consolas, "Cascadia Mono", monospace; }
pre { background: var(--neutral-bg); padding: 10px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { float: right; }
.pre { white-space: pre-wrap; }

/* Barra superiore */
.topbar { display: flex; align-items: center; gap: 24px; background: var(--top); color: #fff; padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { color: #d1d5db; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: #1f2937; text-decoration: none; color: #fff; }
.topbar nav a.active { background: #374151; color: #fff; }
.topbar .count { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.topbar .user { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.topbar .user a { color: #fff; }
.topbar .user .muted { color: #9ca3af; }

main { max-width: 1400px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; padding: 16px; font-size: 12px; }

/* Card e griglie */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card-highlight { border-color: var(--primary); box-shadow: 0 0 0 3px var(--info-bg); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0 0 12px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); }
a.kpi:hover { text-decoration: none; border-color: var(--primary); }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-ok .kpi-value { color: var(--ok); }
.kpi-danger { border-color: #fca5a5; background: #fff7f7; } .kpi-danger .kpi-value { color: var(--danger); }
.kpi-warning { border-color: #fcd34d; background: #fffbeb; } .kpi-warning .kpi-value { color: var(--warn); }

/* Tabelle */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); padding: 8px 10px; }
.table td { border-bottom: 1px solid var(--border); padding: 9px 10px; vertical-align: middle; }
.table.compact td { padding: 6px 10px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #f9fafb; }
.row-disabled td { opacity: .55; }
.row-muted td { color: var(--muted); }
details summary { cursor: pointer; }

/* Badge, stato, barre */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-on { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.dot-off { background: #9ca3af; }
.bar { position: relative; background: var(--neutral-bg); border-radius: 4px; height: 18px; min-width: 90px; overflow: hidden; }
.bar-fill { height: 100%; }
.bar-ok { background: #86efac; } .bar-warning { background: #fcd34d; } .bar-danger { background: #fca5a5; }
.bar-label { position: absolute; inset: 0; font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }
.disk { margin-bottom: 12px; }
.disk-head { margin-bottom: 4px; }

/* Proprietà */
.props { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

/* Schede */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Grafico */
.chart-box { position: relative; height: 300px; }
.chart-empty { position: absolute; top: 45%; width: 100%; text-align: center; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; background: #fff; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 12px; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--primary); color: #fff; }

/* Form */
input:not([type]), input[type=text], input[type=search], input[type=password], input[type=email], input[type=number],
input[type=url], input[type=date], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--text); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info-bg); border-color: var(--primary); }
textarea { width: 100%; resize: vertical; margin-bottom: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label input, label select { color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; align-items: end; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex-direction: column; }
.inline { display: inline; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit input { width: 120px; }
.input-unit span { color: var(--muted); font-size: 12px; }
.has-error input { border-color: var(--danger); }
.error { color: var(--danger); font-size: 12px; }
.code-search { display: flex; gap: 8px; }
.code-search input, .code-input { font-family: Consolas, monospace; font-size: 20px; letter-spacing: .15em; width: 200px; text-align: center; }
h1 .code { color: var(--primary); letter-spacing: .08em; }
.copy-row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.copy-row code { font-size: 18px; background: var(--neutral-bg); padding: 6px 12px; border-radius: 6px; word-break: break-all; }
.steps { padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 4px; }

/* Pulsanti */
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: var(--text); cursor: pointer; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-small { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; }
button.link { background: none; border: 0; color: #d1d5db; cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: #fff; text-decoration: underline; }

/* Messaggi */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: #86efac; color: var(--ok); }
.flash-error { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }
.flash-warning { background: var(--warn-bg); border-color: #fcd34d; color: var(--warn); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { justify-content: center; }

.contact { text-align: right; }

@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px; justify-content: space-between; }
  .topbar nav { order: 3; flex-basis: 100%; }
  main { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .props { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}

/* ======================================================================
   Mappa di rete (stile glass)
   ====================================================================== */
.netmap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.netmap:fullscreen { border-radius: 0; display: flex; flex-direction: column; }
.netmap:fullscreen .nm-viewport { flex: 1; height: auto; }
.nm-toolbar { display: flex; gap: 6px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.nm-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.nm-legend { margin-left: auto; display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.nm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.nm-lg { display: inline-block; width: 24px; height: 0; border-top: 3px solid #64748b; }
.nm-lg-wifi { border-top-style: dashed; border-color: #7c3aed; }
.nm-lg-fiber { border-color: #f97316; border-top-width: 4px; }
.nm-lg-vpn { border-top-style: dotted; border-color: #0891b2; }

.nm-viewport {
  position: relative; height: 640px; overflow: hidden; cursor: grab; touch-action: none; user-select: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(96, 165, 250, .35), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(167, 139, 250, .30), transparent 42%),
    radial-gradient(circle at 50% 95%, rgba(52, 211, 153, .25), transparent 45%),
    linear-gradient(135deg, #eef2ff 0%, #f0f9ff 50%, #f5f3ff 100%);
}
.nm-viewport::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(100, 116, 139, .25) 1px, transparent 1px);
  background-size: 24px 24px;
}
.nm-viewport.is-panning { cursor: grabbing; }
.nm-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.nm-links { position: absolute; left: 0; top: 0; overflow: visible; }
.nm-nodes { position: absolute; left: 0; top: 0; }

.nm-link .nm-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.nm-link .nm-line { stroke: #64748b; stroke-width: 2.5; fill: none; stroke-linecap: round; filter: drop-shadow(0 1px 1px rgba(15, 23, 42, .15)); }
.nm-link:hover .nm-line { stroke-width: 4; }
.nm-l-wifi .nm-line { stroke: #7c3aed; stroke-dasharray: 8 6; }
.nm-l-fiber .nm-line { stroke: #f97316; stroke-width: 3.5; }
.nm-l-vpn .nm-line { stroke: #0891b2; stroke-dasharray: 2 6; }
.nm-l-other .nm-line { stroke: #94a3b8; stroke-dasharray: 12 4 2 4; }
.nm-link text { font-size: 11px; fill: #334155; text-anchor: middle; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 4px; }

.nm-node { position: absolute; width: 110px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.netmap[data-editable="1"] .nm-node { cursor: move; }
.is-link-mode .nm-node { cursor: crosshair; }

/* Icona glass */
.nm-glass {
  --tint: 59, 130, 246;
  position: relative; width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: rgb(var(--tint));
  background: linear-gradient(145deg, rgba(255, 255, 255, .75), rgba(var(--tint), .18));
  border: 1px solid rgba(255, 255, 255, .85);
  box-shadow: 0 8px 22px rgba(var(--tint), .28), 0 2px 4px rgba(15, 23, 42, .08), inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -8px 16px rgba(var(--tint), .12);
  backdrop-filter: blur(10px) saturate(160%); -webkit-backdrop-filter: blur(10px) saturate(160%);
  transition: transform .15s, box-shadow .15s;
}
.nm-glass::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 4px; height: 45%;
  border-radius: 14px 14px 40% 40%; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0));
}
.nm-glass svg { width: 34px; height: 34px; position: relative; filter: drop-shadow(0 1px 1px rgba(255, 255, 255, .8)); }
.nm-node:hover .nm-glass { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 28px rgba(var(--tint), .38), inset 0 1px 0 rgba(255, 255, 255, .9); }
.nm-node.is-linking .nm-glass { outline: 3px solid rgba(var(--tint), .6); outline-offset: 3px; }

.nm-t-pc { --tint: 37, 99, 235; } .nm-t-laptop { --tint: 14, 165, 233; } .nm-t-server { --tint: 79, 70, 229; }
.nm-t-printer { --tint: 13, 148, 136; } .nm-t-switch { --tint: 22, 163, 74; } .nm-t-hub { --tint: 101, 163, 13; }
.nm-t-router { --tint: 234, 88, 12; } .nm-t-firewall { --tint: 220, 38, 38; } .nm-t-access_point { --tint: 124, 58, 237; }
.nm-t-nas { --tint: 71, 85, 105; } .nm-t-modem { --tint: 217, 119, 6; } .nm-t-phone { --tint: 219, 39, 119; }
.nm-t-camera { --tint: 82, 82, 91; } .nm-t-other { --tint: 100, 116, 139; }
.nm-node.is-offline .nm-glass { filter: grayscale(.85); opacity: .7; }

.nm-status { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: #9ca3af; }
.is-online .nm-status { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.nm-badge { position: absolute; right: -6px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #f59e0b; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; border: 2px solid #fff; }
.nm-badge.is-critical { background: #dc2626; }
.nm-label { margin-top: 6px; font-weight: 600; font-size: 12px; color: #0f172a; text-align: center; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(255, 255, 255, .7); padding: 0 6px; border-radius: 6px; backdrop-filter: blur(4px); }
.nm-sub { font-size: 11px; color: #475569; background: rgba(255, 255, 255, .6); padding: 0 5px; border-radius: 5px; margin-top: 1px; }

.nm-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(15, 23, 42, .85); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 13px; }
.nm-hint:empty { display: none; }
.nm-empty { position: absolute; top: 45%; width: 100%; text-align: center; }
.nm-toast { position: fixed; right: 20px; bottom: 20px; background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.nm-toast-error { background: var(--danger); }

/* Finestra di dettaglio */
.nm-dialog {
  border: 1px solid rgba(255, 255, 255, .7); border-radius: 16px; padding: 0; width: min(560px, 94vw); max-height: 88vh;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(16px); box-shadow: 0 24px 60px rgba(15, 23, 42, .3); color: var(--text);
}
.nm-dialog.is-wide { width: min(900px, 96vw); }
.nm-dialog::backdrop { background: rgba(15, 23, 42, .35); backdrop-filter: blur(3px); }
.nm-dialog-body { padding: 20px 22px; }
.nm-dlg-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; position: relative; }
.nm-dlg-head h2 { margin: 0; display: flex; gap: 8px; align-items: center; }
.nm-dlg-head p { margin: 2px 0 0; }
.nm-glass.nm-mini { width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0; }
.nm-glass.nm-mini svg { width: 28px; height: 28px; }
.nm-x { position: absolute; right: -6px; top: -8px; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.nm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.nm-tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.nm-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nm-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.nm-cols h3 { font-size: 13px; margin: 0 0 6px; }
.nm-cols h3 + .small, .nm-cols .bar + .small { margin: 8px 0 2px; }
.nm-alerts { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 4px; }
.nm-scroll { max-height: 46vh; overflow: auto; margin-top: 8px; }
.nm-sw-filter { width: 100%; }
.nm-dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.nm-loc { display: flex; gap: 6px; flex-wrap: wrap; }
.nm-loc input { width: 180px; padding: 4px 8px; }
.nm-form-actions { display: flex; gap: 8px; }
@media (max-width: 760px) { .nm-cols { grid-template-columns: 1fr; } .nm-viewport { height: 520px; } .nm-legend { margin-left: 0; } }

/* Licenze */
.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.device-picks { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.device-picks legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.key-cell { white-space: nowrap; }
.key-mask { font-family: Consolas, monospace; margin-right: 6px; user-select: all; }
.copy-inline { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
