:root{--border:214.3 31.8% 91.4%;--background:0 0% 100%;--foreground:222.2 84% 4.9%;--muted:210 40% 96.1%;--muted-foreground:215.4 16.3% 46.9%;--accent:210 40% 96.1%;--accent-foreground:222.2 47.4% 11.2%;--radius:0.75rem;}*{margin:0;padding:0;box-sizing:border-box;}body{background-color:hsl(var(--background));color:hsl(var(--foreground));font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}.flex{display:flex;}.flex-col{flex-direction:column;}.flex-1{flex:1 1 0%;min-width:0;width:100%;max-width:100%;}.items-center{align-items:center;}.justify-center{justify-content:center;}.h-screen{height:100vh;}.h-full{height:100%;}.h-16{height:4rem;}.h-4{height:1rem;}.h-5{height:1.25rem;}.h-6{height:1.5rem;}.h-20{height:5rem;}.h-px{height:1px;}.w-64{width:16rem;}.w-16{width:4rem;}.w-4{width:1rem;}.w-5{width:1.25rem;}.w-20{width:5rem;}.w-11{width:2.75rem;}.overflow-hidden{overflow:hidden;}.overflow-auto{overflow:auto;}.shrink-0{flex-shrink:0;}.relative{position:relative;}.inline-flex{display:inline-flex;}.cursor-pointer{cursor:pointer;}.gap-2{gap:0.5rem;}.gap-3{gap:0.75rem;}.gap-4{gap:1rem;}.space-y-1 > * + *{margin-top:0.25rem;}.space-y-2 > * + *{margin-top:0.5rem;}.space-y-4 > * + *{margin-top:1rem;}.space-x-1 > * + *{margin-left:0.25rem;}.p-2{padding:0.5rem;}.p-4{padding:1rem;}.px-3{padding-left:0.75rem;padding-right:0.75rem;}.px-4{padding-left:1rem;padding-right:1rem;}.px-6{padding-left:1.5rem;padding-right:1.5rem;}.py-2{padding-top:0.5rem;padding-bottom:0.5rem;}.pt-0{padding-top:0;}.mb-2{margin-bottom:0.5rem;}.mb-3{margin-bottom:0.75rem;}.mb-4{margin-bottom:1rem;}.mt-2{margin-top:0.5rem;}.mt-4{margin-top:1rem;}.pt-4{padding-top:1rem;}.ml-1{margin-left:0.25rem;}.-ml-1{margin-left:-0.25rem;}.mt-2{margin-top:0.5rem;}.border-r{border-right:1px solid hsl(var(--border));}.border-b{border-bottom:1px solid hsl(var(--border));}.border-border{border-color:hsl(var(--border));}.border{border-width:1px;border-style:solid;}.w-full{width:100%;}.h-10{height:2.5rem;}.px-6{padding-left:1.5rem;padding-right:1.5rem;}.rounded-lg{border-radius:calc(var(--radius) - 2px);}.rounded-md{border-radius:calc(var(--radius) - 4px);}.rounded-xl{border-radius:var(--radius);}.rounded-full{border-radius:9999px;}.bg-muted{background-color:hsl(var(--muted));}.bg-gray-300{background-color:#d1d5db;}.bg-gray-500{background-color:#6b7280;}.bg-yellow-400{background-color:#facc15;}.bg-blue-500{background-color:#3b82f6;}.bg-border{background-color:hsl(var(--border));}.bg-background{background-color:hsl(var(--background));}.bg-foreground{background-color:hsl(var(--foreground));}.bg-foreground\/90{background-color:hsl(var(--foreground) / 0.9);}.text-background{color:hsl(var(--background));}.ring-offset-background{--tw-ring-offset-color:hsl(var(--background));}.bg-muted\/50{background-color:hsl(var(--background));border:1px solid hsl(var(--border));box-shadow:0 1px 2px 0 rgba(0,0,0,0.05);}.text-sm{font-size:0.875rem;line-height:1.25rem;letter-spacing:-0.01em;}.text-lg{font-size:1.125rem;line-height:1.75rem;font-weight:600;letter-spacing:-0.02em;}.font-medium{font-weight:500;}.font-semibold{font-weight:600;letter-spacing:-0.01em;}.text-muted-foreground{color:hsl(var(--muted-foreground));}.text-white{color:#ffffff;}.text-red-500{color:#ef4444;}.text-green-500{color:#22c55e;}.text-green-600{color:#16a34a;}.text-blue-500{color:#3b82f6;}h2,h3,h4{margin:0;padding:0;}h2{font-size:1.125rem;font-weight:600;line-height:1.75rem;letter-spacing:-0.02em;}h3{font-size:1rem;font-weight:600;line-height:1.5rem;letter-spacing:-0.01em;}h4{font-size:0.875rem;font-weight:600;line-height:1.25rem;letter-spacing:-0.01em;}strong{font-weight:600;}a{color:hsl(var(--muted-foreground));text-decoration:none;transition:color 0.15s ease;}a:hover{color:hsl(var(--foreground));}svg{display:inline-block;vertical-align:middle;}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(0.4,0,0.2,1);transition-duration:150ms;}.duration-300{transition-duration:300ms;}.hover\:bg-muted:hover{background-color:hsl(var(--muted));cursor:pointer;}.hover\:text-foreground:hover{color:hsl(var(--foreground));}.hover\:bg-blue-600:hover{background-color:#2563eb;cursor:pointer;}.hover\:bg-gray-600:hover{background-color:#4b5563;cursor:pointer;}.shadow-lg{box-shadow:0 10px 15px -3px rgba(0,0,0,0.1),0 4px 6px -2px rgba(0,0,0,0.05);}.shadow-yellow-400\/50{box-shadow:0 0 20px rgba(250,204,21,0.5),0 0 40px rgba(250,204,21,0.3),0 0 60px rgba(250,204,21,0.2);}::-webkit-scrollbar{width:8px;height:8px;}::-webkit-scrollbar-track{background:hsl(var(--muted));}::-webkit-scrollbar-thumb{background:hsl(var(--border));border-radius:4px;}::-webkit-scrollbar-thumb:hover{background:hsl(var(--muted-foreground) / 0.5);}.sidebar-item{border-radius:calc(var(--radius) - 2px);transition:background-color 0.15s ease,color 0.15s ease;display:flex;align-items:center;position:relative;}.sidebar-item:hover{background-color:hsl(210 40% 92%);}.sidebar-item.bg-muted{background-color:hsl(var(--muted));color:hsl(var(--foreground));}.sidebar-item svg{flex-shrink:0;width:1rem;height:1rem;}.sidebar-item span{white-space:nowrap;}.sidebar-group{display:flex;flex-direction:column;}.sidebar-group-header{display:flex;align-items:center;justify-content:space-between;cursor:pointer;user-select:none;position:relative;color:hsl(var(--muted-foreground));}.sidebar-group-header:hover{background-color:hsl(210 40% 92%);}.sidebar-group-header.bg-muted{background-color:hsl(var(--muted));color:hsl(var(--foreground)) !important;}.sidebar-chevron{transition:transform 0.2s ease;width:1rem;height:1rem;flex-shrink:0;}.sidebar-chevron.expanded{transform:rotate(90deg);}.sidebar-submenu{max-height:0;overflow:hidden;transition:max-height 0.3s ease-out;}.sidebar-submenu.expanded{max-height:500px;}.sidebar-submenu-item{padding-left:2.5rem;}#sidebar.sidebar--collapsed #sidebar-brand-title{display:none!important;}#sidebar.sidebar--collapsed #sidebar-brand-row{justify-content:center;gap:0;padding-left:0.125rem;padding-right:0.125rem;}button{border:none;cursor:pointer;font-weight:500;border-radius:calc(var(--radius) - 2px);display:inline-flex;align-items:center;justify-content:center;transition:all 0.15s ease;outline:none;background-color:transparent;}.bg-transparent{background-color:transparent;}button:focus-visible{outline:2px solid hsl(221.2 83.2% 53.3%);outline-offset:2px;}button:disabled{pointer-events:none;opacity:0.5;}.bg-blue-500{background-color:hsl(var(--foreground));color:hsl(var(--background));}button.bg-blue-500:hover{background-color:hsl(var(--foreground) / 0.9);opacity:1;}button.bg-blue-500:active{background-color:hsl(var(--foreground) / 0.8);}.hover\:bg-blue-600:hover{background-color:hsl(var(--foreground) / 0.9);opacity:1;}#breadcrumb a{transition:color 0.15s ease;}.breadcrumb-list{display:flex;flex-wrap:wrap;align-items:center;list-style:none;}.breadcrumb-item{display:inline-flex;align-items:center;}.breadcrumb-link{transition:color 0.15s ease;}.breadcrumb-separator{margin:0 0.5rem;color:hsl(var(--muted-foreground));}.breadcrumb-page{font-weight:500;}.grid{display:grid;}.auto-rows-min{grid-auto-rows:min-content;}.md\:grid-cols-3{grid-template-columns:repeat(1,minmax(0,1fr));}@media (min-width:768px){.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr));}}.dashboard-view{display:flex;}.dashboard-view.hidden{display:none;}.page-view{display:none;flex:1;flex-direction:column;width:100%;max-width:100%;min-width:0;margin:0;padding:0;}.page-view.active{display:flex;}.section-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem;padding:0 !important;width:100% !important;max-width:100% !important;box-sizing:border-box;margin:0 !important;margin-left:0 !important;margin-right:0 !important;}.section-card{background-color:hsl(var(--background));border:1px solid hsl(var(--border));border-radius:0;padding:1.5rem;box-shadow:0 1px 2px 0 rgba(0,0,0,0.05);}.section-card h4{font-size:0.875rem;font-weight:500;color:hsl(var(--muted-foreground));margin-bottom:0.5rem;}.section-card .value{font-size:2rem;font-weight:600;line-height:1;}.chart-area{background-color:hsl(var(--background));border-left:1px solid hsl(var(--border));border-right:1px solid hsl(var(--border));border-top:1px solid hsl(var(--border));border-bottom:1px solid hsl(var(--border));border-radius:0;padding:1.5rem;margin:0 !important;margin-left:0 !important;margin-right:0 !important;min-height:300px;box-shadow:0 1px 2px 0 rgba(0,0,0,0.05);width:100% !important;max-width:100% !important;box-sizing:border-box;}#gps-map{width:100%;height:400px;border-radius:calc(var(--radius) - 2px);overflow:hidden;z-index:1;}.leaflet-container{background-color:hsl(var(--background));font-family:inherit;}.data-table-container{margin:0 !important;background-color:hsl(var(--background));border:1px solid hsl(var(--border));border-radius:0;padding:1.5rem;box-shadow:0 1px 2px 0 rgba(0,0,0,0.05);width:100% !important;max-width:100% !important;box-sizing:border-box;margin-left:0 !important;margin-right:0 !important;}table{width:100%;border-collapse:collapse;border-radius:calc(var(--radius) - 2px);overflow:hidden;}table th,table td{padding:0.75rem;text-align:left;border-bottom:1px solid hsl(var(--border));}table th{font-weight:500;font-size:0.875rem;color:hsl(var(--muted-foreground));text-transform:none;letter-spacing:normal;background-color:hsl(var(--muted) / 0.5);}table tbody tr:hover{background-color:hsl(var(--muted) / 0.5);transition:background-color 0.15s ease;}table tbody tr:last-child td{border-bottom:none;}input[type="text"],input[type="password"],input[type="file"]{border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;background-color:hsl(var(--background));padding:0.5rem 0.75rem;font-size:0.875rem;transition:border-color 0.15s ease,box-shadow 0.15s ease;}input[type="text"]:focus,input[type="password"]:focus,input[type="file"]:focus{border-color:hsl(221.2 83.2% 53.3%);box-shadow:0 0 0 2px hsla(221.2,83.2%,53.3%,0.2);}input[type="file"]{cursor:pointer;}input[type="file"]::file-selector-button{background-color:transparent;border:0;padding:0;margin-right:0.75rem;font-size:0.875rem;font-weight:500;cursor:pointer;}input[type="file"]::file-selector-button:hover{opacity:0.8;}.focus-visible\:outline-none:focus-visible{outline:none;}.focus-visible\:ring-2:focus-visible{outline:2px solid transparent;outline-offset:2px;box-shadow:0 0 0 2px hsl(221.2 83.2% 53.3% / 0.5);}.focus-visible\:ring-offset-2:focus-visible{outline-offset:2px;}.toggle-switch{position:relative;display:inline-flex;align-items:center;width:2.75rem;height:1.5rem;flex-shrink:0;cursor:pointer;}.toggle-switch input{position:absolute;opacity:0;width:0;height:0;pointer-events:none;}.toggle-slider{position:absolute;top:0;left:0;right:0;bottom:0;background-color:hsl(var(--border));border-radius:9999px;transition:background-color 0.2s cubic-bezier(0.4,0,0.2,1);}.toggle-slider:before{position:absolute;content:"";height:1.125rem;width:1.125rem;left:0.1875rem;top:50%;transform:translateY(-50%);background-color:hsl(var(--background));border-radius:50%;transition:transform 0.2s cubic-bezier(0.4,0,0.2,1);box-shadow:0 1px 2px 0 rgba(0,0,0,0.05),0 1px 3px 0 rgba(0,0,0,0.1);}.toggle-switch input:checked + .toggle-slider{background-color:hsl(var(--foreground));}.toggle-switch input:checked + .toggle-slider:before{transform:translate(1.4375rem,-50%);background-color:hsl(var(--background));}.toggle-switch input:focus-visible + .toggle-slider{outline:2px solid hsl(221.2 83.2% 53.3%);outline-offset:2px;}.toggle-switch:disabled{cursor:not-allowed;opacity:0.5;}#led-indicator{transition:all 0.3s cubic-bezier(0.4,0,0.2,1);}.min-h-\[200px\]{min-height:200px;}.aspect-video{aspect-ratio:16 / 9;}.tooltip{position:relative;z-index:50;}.tooltip-content{position:absolute;z-index:50;overflow:hidden;border-radius:calc(var(--radius) - 2px);background-color:hsl(var(--foreground));color:hsl(var(--background));padding:0.5rem 0.75rem;font-size:0.875rem;line-height:1.25rem;opacity:0;pointer-events:none;transition:opacity 0.15s ease;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1),0 2px 4px -1px rgba(0,0,0,0.06);white-space:nowrap;}.tooltip-content.show{opacity:1;pointer-events:auto;}.tooltip-content[data-side="right"]{left:100%;top:50%;transform:translateY(-50%);margin-left:0.5rem;}.tooltip-content[data-side="left"]{right:100%;top:50%;transform:translateY(-50%);margin-right:0.5rem;}.tooltip-content[data-side="top"]{bottom:100%;left:50%;transform:translateX(-50%);margin-bottom:0.5rem;}.tooltip-content[data-side="bottom"]{top:100%;left:50%;transform:translateX(-50%);margin-top:0.5rem;}.login-view{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;background-color:hsl(var(--muted) / 0.3);}.login-view.hidden{display:none;}.login-card{background-color:hsl(var(--background));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);padding:2rem;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1),0 2px 4px -1px rgba(0,0,0,0.06);width:100%;max-width:400px;}.login-card h1{font-size:1.5rem;font-weight:600;margin-bottom:0.5rem;text-align:center;}.login-card p{color:hsl(var(--muted-foreground));text-align:center;margin-bottom:1.5rem;font-size:0.875rem;}.login-form{display:flex;flex-direction:column;gap:1rem;}.login-form label{font-size:0.875rem;font-weight:500;color:hsl(var(--foreground));}.login-form input[type="text"],.login-form input[type="password"]{width:100%;padding:0.5rem 0.75rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.875rem;transition:border-color 0.15s ease,box-shadow 0.15s ease;}.login-form input[type="text"]:focus,.login-form input[type="password"]:focus{border-color:hsl(221.2 83.2% 53.3%);box-shadow:0 0 0 2px hsla(221.2,83.2%,53.3%,0.2);outline:none;}.login-error{color:hsl(var(--red-500));font-size:0.875rem;margin-top:0.5rem;text-align:center;}.login-error.hidden{display:none;}.main-content{display:none;width:100%;}.main-content.authenticated{display:flex;width:100%;}

/* === Main area (beside sidebar): denser layout, single scroll === */
#page-view,
#page-view.active,
#page-view.page-view {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}
#main-content > .flex.h-screen.overflow-hidden {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  padding-left: 0.5rem !important;
}
#page-content {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}
.app-main-column {
  background: hsl(var(--muted) / 0.18);
}
.app-content-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.625rem 0.75rem;
}
@media (min-width: 768px) {
  .app-content-scroll {
    padding: 0.625rem 0.875rem 1rem;
  }
}
#page-view.active,
#page-content,
#dashboard-view {
  padding: 0 !important;
}
header.flex.h-16 {
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
}
.section-cards {
  gap: 0.625rem !important;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
}
.section-card,
.chart-area,
.data-table-container {
  border-radius: var(--radius) !important;
  padding: 0.875rem 1rem !important;
  margin: 0 0 0.75rem 0 !important;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.section-card .value {
  font-size: clamp(1.25rem, 3vw, 1.75rem) !important;
}
.dashboard-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
  width: 100%;
}
@media (min-width: 768px) {
  .dashboard-cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
}
.dashboard-stat-card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.dashboard-stat-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
/* Titolo a sinistra può restringersi; badge polarità + stato restano visibili */
.dashboard-stat-card__head > div:first-child {
  flex: 1 1 0;
  min-width: 0;
}
.dashboard-stat-card__title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.dashboard-stat-card__head--port {
  align-items: flex-start;
}
.dashboard-stat-card__head-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.dashboard-port-card__identity {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  min-width: 0;
  flex: 1 1 0;
}
.dashboard-port-card__icon {
  width: auto;
  height: auto;
  align-self: stretch;
  min-height: 3.5rem;
  max-width: 2.85rem;
  object-fit: contain;
  opacity: 0.9;
  flex-shrink: 0;
}
.dashboard-port-card__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.14rem;
  flex: 1 1 auto;
}
.dashboard-port-card__name {
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}
.dashboard-port-card__status {
  font-size: 0.75rem;
  font-weight: 620;
  line-height: 1.25;
}
.dashboard-port-card__fault-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  opacity: 0.82;
  cursor: help;
  flex: 0 0 auto;
}
.dashboard-port-card__fault-help:hover,
.dashboard-port-card__fault-help:focus-visible {
  opacity: 1;
  background: hsl(var(--muted) / 0.45);
  outline: none;
}
.dashboard-port-card__label-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.dashboard-port-card__label-text {
  font-size: 0.72rem;
  line-height: 1.25;
  color: hsl(var(--muted-foreground));
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dashboard-port-card__label-text strong {
  color: #334155;
  font-weight: 650;
}
.dashboard-port-card__label-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: 0.45rem;
  flex-shrink: 0;
  cursor: pointer;
}
.dashboard-port-card__label-edit {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.05rem;
}
.dashboard-port-card__label-edit input {
  flex: 1 1 8rem;
  min-width: 0;
  height: 1.85rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.45rem;
  padding: 0 0.5rem;
  font-size: 0.78rem;
  box-sizing: border-box;
}
.dashboard-port-card__label-save,
.dashboard-port-card__label-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.85rem;
  min-height: 1.85rem;
  min-width: 4.5rem;
  padding: 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1;
  border-radius: 0.45rem;
  flex-shrink: 0;
  box-sizing: border-box;
  cursor: pointer;
  white-space: nowrap;
}
.dashboard-port-card__label-save {
  border: 1px solid hsl(var(--foreground));
  background: hsl(var(--foreground));
  color: hsl(var(--background));
}
.dashboard-port-card__label-cancel {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.dashboard-stat-card__body {
  min-height: 4.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#led-status-card.dashboard-stat-card__body {
  align-items: center;
  justify-content: center;
  min-height: 5rem;
}
.dashboard-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.dashboard-pill--ok {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 28%);
}
.dashboard-pill--info {
  background: hsl(239 84% 67% / 0.12);
  color: hsl(239 84% 38%);
}
.network-split-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .network-split-grid {
    grid-template-columns: 1fr 1.5fr;
    gap: 0.875rem;
  }
}

/* Sidebar: rail stretta quando compressa, versione piccola */
#sidebar.sidebar--collapsed {
  width: 2.5rem !important;
  min-width: 2.5rem !important;
  max-width: 2.5rem !important;
}
#sidebar.sidebar--collapsed .sidebar-item:not(.sidebar-group-header) {
  justify-content: center;
  gap: 0;
  padding-left: 0.125rem;
  padding-right: 0.125rem;
}
#sidebar.sidebar--collapsed .sidebar-group-header {
  justify-content: center;
  padding-left: 0.125rem;
  padding-right: 0.125rem;
}
#sidebar.sidebar--collapsed .sidebar-group-header .flex-1 {
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
  justify-content: center;
}
#sidebar.sidebar--collapsed .sidebar-group-header #system-chevron {
  display: none !important;
}
#sidebar.sidebar--collapsed .sidebar-submenu-item {
  padding-left: 0.125rem;
}
/* === Missing utility classes (used across pages) === */
.gap-6 { gap: 1rem; }
.p-1 { padding: 0.25rem; }
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); }
.rounded-sm { border-radius: calc(var(--radius) - 6px); }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }

/* === Select (stile semplice come immagine) === */
select {
  display: flex;
  height: 2.5rem;
  width: 100%;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  border: 1px solid hsl(220 13% 91%);
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}
select:hover {
  border-color: hsl(220 13% 85%);
}
select:focus {
  border-color: hsl(221.2 83.2% 53.3%);
  box-shadow: 0 0 0 2px hsl(221.2 83.2% 53.3% / 0.2);
}

/* === Chart container rounding === */
.chart-rounded {
  border-radius: calc(var(--radius) - 2px) !important;
  overflow: hidden !important;
  background: hsl(var(--background));
}
.chart-rounded svg {
  display: block;
}

/* === UI Consistency Fixes === */
/* Toggle: keep a small right padding so the knob doesn't touch the edge when ON */
.toggle-switch input:checked + .toggle-slider:before {
  transform: translate(1.25rem, -50%) !important; /* was too far right */
}

/* === Gradient background for cards with large value displays === */
.section-card:has(.value) {
  background: linear-gradient(to bottom, hsl(var(--background)), hsl(var(--muted))) !important;
}

/* === Loading Spinner === */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid hsl(var(--muted));
  border-top-color: hsl(var(--foreground));
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.loading-spinner-sm {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-6 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* #page-content: evitare contain:paint / will-change:contents — su WebKit possono bloccare il repaint dopo innerHTML e sembra “schermo vuoto”. */
#page-content {
  min-height: 0;
}

.section-card, .data-table-container, .chart-area {
  /* no CSS contain: on WebKit it can leave blank panels after SPA innerHTML */
}

/* Portal overrides */
:root {
  --red-500: 0 84% 60%;
}
.login-error {
  color: #dc2626 !important;
}
#page-view.active {
  display: flex !important;
  flex: 1 1 auto !important;
  min-height: 12rem !important;
}
#page-content {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-height: 8rem !important;
  color: var(--ui-text, #111827);
}
#page-content .data-table-container {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: #ffffff !important;
  border: 1px solid #d7dee8 !important;
  border-radius: 0.875rem !important;
  padding: 1rem !important;
  margin-bottom: 0.75rem !important;
}

/* ===== V1 Clean Enterprise refresh ===== */
:root {
  --radius: 0.875rem;
  --ui-page: #f3f6fa;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8fafc;
  --ui-border: #d7dee8;
  --ui-border-strong: #c7d0dc;
  --ui-text: #111827;
  --ui-muted: #64748b;
  --ui-primary: #2563eb;
  --ui-primary-soft: #dbeafe;
  --ui-success: #16a34a;
  --ui-warning: #d97706;
  --ui-danger: #dc2626;
  --ui-shadow: 0 8px 18px rgba(25, 38, 64, 0.08);
  --ui-shadow-soft: 0 2px 8px rgba(25, 38, 64, 0.06);
}
body {
  background: var(--ui-page) !important;
  color: var(--ui-text) !important;
  font-size: 14px;
  letter-spacing: -0.005em;
}
.app-main-column {
  background:
    radial-gradient(900px 420px at 80% -120px, rgba(37, 99, 235, 0.11), rgba(37, 99, 235, 0) 62%),
    linear-gradient(180deg, #f8fafc 0%, var(--ui-page) 100%) !important;
}
#sidebar {
  background: linear-gradient(180deg, #fbfdff 0%, #f5f8fc 100%) !important;
  border-right: 1px solid var(--ui-border) !important;
  box-shadow: 4px 0 18px rgba(30, 41, 59, 0.04);
}
#sidebar-brand-row {
  color: #0f172a;
  border: 0 !important;
  border-radius: 0 !important;
  margin: 0 0 0.5rem;
  background: transparent !important;
  box-shadow: none !important;
}
#sidebar-brand-row svg .cls-1,
#sidebar-brand-row svg .cls-2 {
  fill: #111827 !important;
}
.sidebar-brand-title {
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
}
.sidebar-item,
.sidebar-group-header {
  min-height: 2.25rem;
  color: #475569 !important;
  font-size: 0.8125rem !important;
  font-weight: 560 !important;
  border: 1px solid transparent;
}
.sidebar-item svg,
.sidebar-group-header svg {
  stroke-width: 1.75;
  color: #64748b;
}
.sidebar-item:hover,
.sidebar-group-header:hover {
  background: #f1f5f9 !important;
  border-color: #e2e8f0;
  color: #172033 !important;
}
.sidebar-item.bg-muted,
.sidebar-group-header.bg-muted {
  background: transparent !important;
  border-color: transparent !important;
  color: #334155 !important;
  font-weight: 760 !important;
  box-shadow: none !important;
}
.sidebar-item.bg-muted svg,
.sidebar-group-header.bg-muted svg {
  color: #334155 !important;
}
.sidebar-submenu {
  margin-left: 0.875rem;
  border-left: 1px solid #dbe3ee;
}
.sidebar-submenu-item {
  padding-left: 1rem !important;
  color: #64748b !important;
  font-size: 0.78rem !important;
}
header.flex.h-16 {
  height: 3.5rem !important;
  width: 100%;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9) !important;
  border-bottom: 1px solid var(--ui-border) !important;
  backdrop-filter: blur(8px);
}
header.flex.h-16 > .flex.items-center {
  min-width: 0;
}
#breadcrumb {
  color: #64748b !important;
  font-size: 0.8125rem !important;
}
#breadcrumb a:hover {
  color: #334155 !important;
}
#sidebar-toggle {
  color: #334155 !important;
  border: 1px solid transparent;
}
#sidebar-toggle:hover {
  background: #edf3fb !important;
  border-color: #dbe3ee;
}
.dashboard-readonly-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
}
.dashboard-readonly-control[hidden] {
  display: none !important;
}
.dashboard-readonly-control__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
body.dashboard-readonly-active .dashboard-readonly-control__label {
  color: #0f766e;
}
#dashboard-view.dashboard-read-only .dashboard-port-card__label-edit-btn,
#dashboard-view.dashboard-read-only .dashboard-port-card__label-edit {
  display: none !important;
}
#dashboard-view.dashboard-read-only button,
#dashboard-view.dashboard-read-only input,
#dashboard-view.dashboard-read-only select,
#dashboard-view.dashboard-read-only .toggle-switch {
  pointer-events: none !important;
  opacity: 0.58;
  cursor: not-allowed !important;
}
@media (max-width: 480px) {
  .dashboard-readonly-control__label {
    display: none;
  }
}
.app-content-scroll {
  padding: 0.35rem 0.45rem !important;
}
@media (min-width: 768px) {
  .app-content-scroll {
    padding: 0.45rem 0.55rem !important;
  }
}
#page-view h2, #page-view h3, #page-view h4,
#dashboard-view h2, #dashboard-view h3, #dashboard-view h4,
#page-content h2, #page-content h3, #page-content h4 {
  color: #475569;
  font-weight: 620 !important;
  letter-spacing: -0.01em;
}
#page-content,
#dashboard-view,
.dashboard-stat-card,
.section-card,
.data-table-container,
.chart-area,
table,
input,
select,
button {
  font-size: 0.8125rem !important;
  line-height: 1.25rem !important;
}
#page-content .text-lg,
#dashboard-view .text-lg {
  font-size: 0.875rem !important;
  line-height: 1.35rem !important;
}
#page-content .text-sm,
#dashboard-view .text-sm {
  font-size: 0.8125rem !important;
  line-height: 1.25rem !important;
}
#page-content .font-semibold,
#dashboard-view .font-semibold {
  font-weight: 620 !important;
}
#page-view .text-muted-foreground,
#dashboard-view .text-muted-foreground,
#page-content .text-muted-foreground,
#dashboard-view .dashboard-stat-card__body,
#page-content .line {
  color: var(--ui-muted) !important;
}
.dashboard-cards-grid,
.section-cards {
  gap: 0.35rem !important;
}
.dashboard-stat-card,
.section-card,
.data-table-container,
.chart-area {
  background: var(--ui-surface) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--ui-shadow) !important;
}
.dashboard-stat-card,
.section-card {
  min-height: 3.7rem !important;
  padding: 0.38rem 0.52rem !important;
}
.data-table-container,
.chart-area {
  padding: 0.45rem 0.55rem !important;
  margin-bottom: 0.35rem !important;
}
.dashboard-stat-card__head {
  margin-bottom: 0.25rem !important;
}
.dashboard-stat-card__body {
  min-height: 2.35rem !important;
}
#led-status-card.dashboard-stat-card__body {
  min-height: 2.75rem !important;
}
#led-indicator {
  width: 2.55rem !important;
  height: 2.55rem !important;
}
.dashboard-stat-card__title,
.section-card h4 {
  color: #475569 !important;
  font-size: 0.8125rem !important;
  font-weight: 620 !important;
  text-transform: none !important;
  letter-spacing: -0.005em;
}
.section-card .value {
  color: #334155;
  font-size: clamp(0.94rem, 1.4vw, 1.12rem) !important;
  font-weight: 680 !important;
  letter-spacing: -0.025em;
  line-height: 1.15 !important;
}
.dashboard-pill {
  border: 1px solid transparent;
  font-size: 0.65rem;
  font-weight: 700;
}
.dashboard-pill--ok {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: #bbf7d0;
}
.dashboard-pill--info {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-color: #dbe3ee;
}
.loading-spinner {
  border-color: #dbe4ef !important;
  border-top-color: #334155 !important;
}
input[type="text"],
input[type="password"],
input[type="file"],
select,
#page-content input[type="text"],
#page-content input[type="password"],
#page-content input[type="file"],
#page-content select {
  background: #ffffff !important;
  border-color: var(--ui-border-strong) !important;
  color: #111827 !important;
  font-weight: 450 !important;
  border-radius: 0.7rem !important;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
}
input:focus,
select:focus {
  border-color: #93b8ff !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14) !important;
}
button,
#page-content button,
#page-content .bg-foreground {
  border-radius: 0.7rem !important;
}
.bg-foreground,
#page-content .bg-foreground,
#page-content button.bg-foreground,
#page-content .bg-blue-500,
button.bg-blue-500 {
  background: #64748b !important;
  color: #ffffff !important;
  font-weight: 620 !important;
}
.bg-foreground:hover,
#page-content .bg-foreground:hover,
#page-content button.bg-foreground:hover,
#page-content .bg-blue-500:hover,
button.bg-blue-500:hover {
  background: #475569 !important;
}
.chart-rounded {
  border: 1px solid #d8e1ec !important;
  border-radius: 0.8rem !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.98)),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.08) 0, rgba(148, 163, 184, 0.08) 1px, transparent 1px, transparent 42px) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  /* Altezza da inline in app.js (UI_CHART_HEIGHT); niente height fissa qui */
  min-height: 10.5rem;
}
.chart-rounded svg {
  filter: none !important;
  width: 100%;
  height: auto;
  vertical-align: top;
}
table {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #ffffff;
}
table th,
table td {
  padding: 0.28rem 0.48rem !important;
  font-size: 0.8125rem;
}
table th,
#page-content table th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-weight: 650 !important;
  border-bottom-color: #dbe3ee !important;
}
table td,
#page-content table td {
  color: #1f2937 !important;
}
table tbody tr:hover,
#page-content table tbody tr:hover {
  background: #f6f9fd !important;
}
.login-view {
  background:
    radial-gradient(560px 300px at 50% 0%, rgba(37, 99, 235, 0.16), transparent 65%),
    var(--ui-page) !important;
}
.login-card {
  border-color: var(--ui-border) !important;
  border-radius: 1rem !important;
  box-shadow: 0 18px 38px rgba(25, 38, 64, 0.12) !important;
}
.login-logo {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 0.85rem;
}
.login-card h1 {
  color: #111827;
  font-size: 1.35rem !important;
  font-weight: 750 !important;
  letter-spacing: -0.035em;
}
.login-card p {
  color: var(--ui-muted) !important;
}
#led-indicator {
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.16), 0 8px 18px rgba(15, 23, 42, 0.08);
}
#gps-map {
  border: 1px solid #dbe3ee;
  box-shadow: var(--ui-shadow-soft);
  height: 400px !important;
}
.gps-details-block {
  margin: 0;
}
.gps-details-summary {
  cursor: pointer;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  user-select: none;
}
.gps-details-summary::-webkit-details-marker {
  display: none;
}
.gps-details-summary::before {
  content: '';
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid hsl(var(--muted-foreground));
  border-bottom: 2px solid hsl(var(--muted-foreground));
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.gps-details-block[open] > .gps-details-summary::before {
  transform: rotate(45deg);
}
.gps-details-body {
  margin-top: 0.75rem;
}
#page-content .space-y-4 > * + *,
#dashboard-view .space-y-4 > * + * {
  margin-top: 0.28rem !important;
}
#page-content .space-y-2 > * + *,
#dashboard-view .space-y-2 > * + * {
  margin-top: 0.2rem !important;
}
#page-content .mb-4,
#dashboard-view .mb-4 {
  margin-bottom: 0.28rem !important;
}
#page-content .mt-4,
#dashboard-view .mt-4 {
  margin-top: 0.28rem !important;
}
#page-content .mt-2,
#dashboard-view .mt-2 {
  margin-top: 0.16rem !important;
}
#page-content [style*="gap: 1.5rem"] {
  gap: 0.45rem !important;
}
#page-content [style*="margin-top: 1.5rem"] {
  margin-top: 0.45rem !important;
}
@media (max-width: 900px) {
  #main-content > .flex.h-screen.overflow-hidden { padding-left: 0 !important; }
  header.flex.h-16 { height: 3.25rem !important; padding: 0 0.6rem !important; }
  .app-content-scroll { padding: 0.35rem !important; }
  .dashboard-cards-grid,
  .section-cards,
  .network-split-grid { grid-template-columns: 1fr !important; gap: 0.3rem !important; }
  .dashboard-stat-card,
  .section-card,
  .data-table-container,
  .chart-area { padding: 0.4rem 0.45rem !important; }
  .chart-rounded { min-height: 9rem !important; }
  #gps-map { height: min(52vw, 440px) !important; min-height: 360px !important; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Outputs page: su schermi stretti usa <select> nativo; su desktop la griglia di pulsanti */
.outputs-port-select-wrap {
  display: none;
  width: 100%;
}
.outputs-port-select {
  width: 100%;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0 0.65rem;
  font-size: 0.9rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}
@media (max-width: 767px) {
  .outputs-port-select-wrap {
    display: block;
  }
  .outputs-schema-buttons {
    display: none !important;
  }
}
@media (min-width: 768px) {
  .outputs-port-select-wrap {
    display: none !important;
  }
  .outputs-schema-buttons {
    display: grid !important;
  }
}

/* ===== Shared UI layout helpers ===== */
.ui-stat-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}
.ui-chart-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.8rem;
}
.ui-chart-cell {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 0.45rem;
}
.ui-chart-label {
  margin-bottom: 0.3rem;
}
.ui-stat-value {
  font-size: 1.25rem;
  font-weight: 680;
  line-height: 1.15;
}
.log-panel {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  background-color: hsl(var(--muted));
  padding: 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.65rem;
  max-height: calc(100dvh - 18rem);
  overflow-y: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
.network-tab-bar button {
  min-height: 2.25rem;
}

/* PoE dashboard: pair polarity selectors (UI only) */
.poe-polarity-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  margin-bottom: 0.4rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  border-top: 1px solid var(--ui-border, #d7dee8);
  border-bottom: 1px solid var(--ui-border, #d7dee8);
}
.poe-polarity-toolbar__title {
  font-size: 0.75rem;
  font-weight: 650;
  color: #475569;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  margin-right: 0.1rem;
}
.poe-polarity-select {
  flex: 1 1 5.25rem;
  min-width: 4.5rem;
  max-width: 6.75rem;
  min-height: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--ui-border-strong, #c7d0dc);
  border-radius: 0.55rem;
  background: #fff;
  color: #111827;
}
.poe-polarity-btn {
  flex: 0 0 auto;
  min-height: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 650;
  border-radius: 0.55rem;
  border: 1px solid var(--ui-border-strong, #c7d0dc);
  background: #fff;
  color: #334155;
  cursor: pointer;
}
.poe-polarity-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.poe-polarity-btn--apply {
  background: #64748b;
  border-color: #64748b;
  color: #fff;
}
.poe-polarity-btn--apply:not(:disabled):hover {
  background: #475569;
  border-color: #475569;
}
.poe-pol-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.poe-pol-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.14rem 0.28rem;
  border-radius: 0.35rem;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}
.poe-pol-chip--off {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #dbe3ee;
}
.poe-pol-chip__n {
  opacity: 0.82;
  font-weight: 600;
}
.poe-pol-chip__s {
  font-size: 0.68rem;
  font-weight: 800;
}

/* Confirm modal */
body.ui-modal-open {
  overflow: hidden;
}
.ui-modal-root {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50000;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.ui-modal-root--open {
  display: flex;
}
.ui-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
}
.ui-modal-panel {
  position: relative;
  z-index: 1;
  width: min(24rem, 100%);
  max-height: min(85vh, 32rem);
  overflow: auto;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  padding: 1.15rem 1.2rem 1rem;
}
.ui-modal-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.65rem;
  color: hsl(var(--foreground));
}
.ui-modal-body {
  font-size: 0.875rem;
  line-height: 1.55;
  color: hsl(var(--muted-foreground));
  white-space: pre-line;
  margin-bottom: 1rem;
}
.ui-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.ui-modal-btn {
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border-radius: 0.55rem;
  font-size: 0.8125rem;
  font-weight: 650;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
}
.ui-modal-btn--confirm {
  background: #64748b;
  border-color: #64748b;
  color: #fff;
}
.ui-modal-btn--confirm.ui-modal-btn--danger {
  background: #dc2626;
  border-color: #dc2626;
}
.ui-modal-btn--confirm:hover {
  filter: brightness(0.95);
}
.ui-modal-btn--cancel:hover {
  background: hsl(var(--muted));
}

/* Safety: hidden login must win over any display rule */
.login-view.hidden {
  display: none !important;
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(15, 23, 42, 0.42);
  -webkit-tap-highlight-color: transparent;
}
#sidebar-backdrop.visible {
  display: block;
}

/* Phone + tablet (iPad): overlay drawer sidebar, full-width content */
@media (max-width: 1194px) {
  .h-screen,
  #main-content,
  #main-content > .flex.h-screen.overflow-hidden {
    height: 100dvh;
    min-height: -webkit-fill-available;
  }
  html.login-active,
  html.login-active body {
    overflow: hidden;
    overflow-x: clip;
    max-width: 100%;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
  }
  html.login-active #main-content {
    display: none !important;
    visibility: hidden !important;
    position: fixed !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    clip: rect(0, 0, 0, 0);
  }
  .login-view {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding:
      max(1rem, env(safe-area-inset-top))
      max(1rem, env(safe-area-inset-right))
      max(1rem, env(safe-area-inset-bottom))
      max(1rem, env(safe-area-inset-left));
    z-index: 400;
    box-sizing: border-box;
  }
  .login-card {
    width: min(22.5rem, 100%) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    padding: clamp(1.25rem, 5vw, 2rem) !important;
  }
  .login-form,
  .login-form > div {
    min-width: 0;
    max-width: 100%;
  }
  .login-form input[type="text"],
  .login-form input[type="password"],
  .login-form button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .login-card h1 {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  #main-content > .flex.h-screen.overflow-hidden,
  .app-main-column {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  #sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 300;
    width: min(18rem, 86vw) !important;
    min-width: 0 !important;
    max-width: 86vw !important;
    transform: translateX(-105%);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: none;
  }
  #sidebar.sidebar--mobile-open {
    transform: translateX(0);
    box-shadow: 10px 0 28px rgba(15, 23, 42, 0.16);
  }
  #sidebar.sidebar--collapsed {
    width: min(18rem, 86vw) !important;
    min-width: 0 !important;
    max-width: 86vw !important;
    transform: translateX(-105%);
  }
  #sidebar.sidebar--collapsed .sidebar-item span,
  #sidebar.sidebar--collapsed .sidebar-group-header span,
  #sidebar.sidebar--collapsed #sidebar-brand-title,
  #sidebar.sidebar--collapsed .sidebar-submenu {
    display: block !important;
  }
  #sidebar.sidebar--collapsed .sidebar-item,
  #sidebar.sidebar--collapsed .sidebar-group-header {
    justify-content: flex-start !important;
    min-height: 2.75rem;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  #sidebar.sidebar--collapsed #sidebar-brand-row {
    justify-content: flex-start !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  header.flex.h-16 {
    padding-left: max(0.5rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.5rem, env(safe-area-inset-right)) !important;
  }
  #breadcrumb {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .breadcrumb-list {
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .app-content-scroll {
    padding-left: max(0.35rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.35rem, env(safe-area-inset-right)) !important;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
  }
  .login-form input[type="text"],
  .login-form input[type="password"],
  #page-content input[type="text"],
  #page-content input[type="password"],
  #page-content select,
  .outputs-port-select {
    font-size: 16px !important;
  }
  .sidebar-item,
  .sidebar-group-header,
  .sidebar-submenu-item,
  #sidebar-toggle {
    min-height: 2.75rem;
  }
}

@media (max-width: 767px) {
  html {
    -webkit-text-size-adjust: 100%;
  }
  .poe-polarity-toolbar {
    gap: 0.3rem;
  }
  .poe-polarity-select {
    flex: 1 1 calc(50% - 2.5rem);
    max-width: none;
    min-height: 2.75rem;
    height: 2.75rem;
    font-size: 16px !important;
  }
  .poe-polarity-btn {
    min-height: 2.75rem;
    height: 2.75rem;
    flex: 1 1 calc(50% - 0.2rem);
  }
  table {
    -webkit-overflow-scrolling: touch;
  }

  /* --- Pagine: layout comuni --- */
  .ui-inline-field-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .ui-inline-field-row > button,
  .ui-inline-field-row > .bg-foreground,
  #wifi-save-btn,
  #eth-save-btn,
  #save-password-btn,
  #reset-output-config-btn,
  #reboot-btn,
  #check-updates-btn,
  #install-update-btn,
  #upgrade-upload-btn {
    width: 100%;
    min-height: 2.75rem;
  }
  .ui-stat-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
  }
  .ui-chart-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.45rem !important;
    margin-top: 0.55rem !important;
  }
  #page-content [style*="grid-template-columns: repeat(4"],
  #page-content [style*="grid-template-columns: repeat(2, minmax(0, 1fr))"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  #page-content [style*="grid-template-columns: repeat(2, minmax(0, 1fr)); gap:0.65rem"] {
    grid-template-columns: 1fr !important;
  }
  #dashboard-view .dashboard-cards-grid,
  #power-input-grid,
  #poe-temp-grid,
  #ter-temp-grid {
    grid-template-columns: 1fr !important;
  }
  .section-card .value,
  .ui-stat-value {
    font-size: clamp(1rem, 4.5vw, 1.35rem) !important;
    word-break: break-word;
  }
  .section-cards {
    grid-template-columns: 1fr !important;
  }

  /* --- Network --- */
  .network-tab-bar {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 2.75rem;
    height: auto !important;
    padding: 0.2rem !important;
  }
  .network-tab-bar button {
    flex: 1 1 0;
    min-height: 2.5rem;
    padding: 0.5rem 0.65rem !important;
  }
  .network-split-grid {
    gap: 0.45rem !important;
  }
  #wifi-config .flex.gap-2.items-center,
  #ethernet-config .flex.gap-2.items-center,
  #wifi-status .flex.gap-2.items-center,
  #ethernet-status .flex.gap-2.items-center {
    flex-wrap: wrap;
  }
  #wifi-config input,
  #ethernet-config input,
  #wifi-config select,
  #ethernet-config select {
    width: 100% !important;
    min-height: 2.75rem;
  }

  /* --- Log --- */
  .log-filters {
    padding: 0.65rem !important;
    gap: 0.55rem !important;
  }
  .log-filters > .flex.items-center {
    flex-direction: column;
    align-items: flex-start !important;
    width: 100%;
  }
  .log-panel {
    max-height: calc(100dvh - 17rem) !important;
    min-height: 12rem;
    font-size: 0.75rem !important;
    line-height: 1.45 !important;
    padding: 0.55rem !important;
    border-radius: 0.65rem !important;
    -webkit-overflow-scrolling: touch;
  }
  .log-toolbar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 0.55rem !important;
    gap: 0.45rem !important;
    background: rgba(248, 250, 252, 0.96) !important;
    backdrop-filter: blur(6px);
    border: 1px solid var(--ui-border);
    border-radius: 0.65rem;
  }
  .log-toolbar button {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.75rem;
  }
  #log-max-lines {
    width: 100% !important;
    min-height: 2.75rem;
  }
  .log-category-badge {
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
  }

  /* --- Outputs --- */
  .outputs-port-select-wrap {
    margin-bottom: 0.35rem;
  }
  #outputs-schema.outputs-schema-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.35rem !important;
  }
  .ui-chart-cell {
    padding: 0.4rem !important;
  }
  #page-content details summary {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
  }

  /* --- Dashboard cards --- */
  .dashboard-stat-card__head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.35rem !important;
  }
  .dashboard-stat-card__head--port {
    flex-direction: row;
    align-items: flex-start !important;
    flex-wrap: wrap;
  }
  .dashboard-stat-card__head-badges,
  .dashboard-stat-card__head > div:last-child {
    width: 100%;
    justify-content: flex-start;
  }
  .dashboard-pill {
    font-size: 0.62rem !important;
  }

  /* --- System / tabelle --- */
  #page-content table,
  #dashboard-view table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #page-content table thead,
  #page-content table tbody,
  #page-content table tr {
    width: max-content;
    min-width: 100%;
  }
  #page-content table th,
  #page-content table td {
    white-space: nowrap;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #gps-map {
    height: min(52vw, 440px) !important;
    min-height: 360px !important;
  }
  #led-management-content table td .inline-flex {
    flex-wrap: wrap;
  }

  /* --- Upgrade / azioni --- */
  #page-content .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  #page-content button.bg-foreground,
  #page-content .bg-blue-500 {
    min-height: 2.75rem;
  }
  input[type="file"] {
    min-height: 2.75rem;
  }

  /* --- Breadcrumb System --- */
  .breadcrumb-separator {
    margin: 0 0.25rem;
  }
  .breadcrumb-link,
  .breadcrumb-page {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
  }
}
