/* Backoffice: sidebar fissa e contenuto a tutta larghezza, tabelle dense. */

.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; padding: 16px 12px;
  background: var(--surface); border-right: 1px solid var(--border); }
.sidebar .brand { display: flex; gap: 10px; align-items: center; font-weight: 760; font-stretch: 88%; font-size: 16px; color: var(--text); padding: 4px 8px; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--muted); padding: 7px 10px; border-radius: var(--radius-sm); }
.sidebar nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sidebar nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.side-foot .who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.shell main { max-width: none; margin: 0; padding: 20px 28px 48px; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0; border: 0; flex-direction: row; align-items: center; }
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 200px; }
table.dense td, table.dense th { padding: 6px 10px; }
.results { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; max-height: 240px; overflow: auto; }
.results li { padding: 4px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.results code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 0 0; color: var(--muted); font-size: 13px; }

details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); }
details.card[open] > summary::before { content: "–"; }
details.card[open] > summary { margin-bottom: 12px; }

.toolbar.bulk { padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-2); opacity: .6; }
.toolbar.bulk.active { opacity: 1; background: var(--accent-soft); }
tr.selected td { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; overflow-x: auto; padding-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 26px; font-size: 11px; }
.bar i { display: block; width: 16px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar small, .bar span { color: var(--muted); }
.bar small { margin-top: 4px; }
td.payload { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
pre.export { max-height: 320px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); font-size: 12px; }
.product { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; }
.product .thumb.big { height: 180px; }
@media (max-width: 700px) { .product { grid-template-columns: 1fr; } }
.bar i.seg-block { background: var(--warn); border-radius: 0; }
.bar i.seg-err { background: var(--bad); border-radius: 4px 4px 0 0; }
.bar i.seg-muted { background: var(--border); }
.bar.pair .pair-cols { display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.bar.pair .pair-cols i { width: 9px; }
.secret { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--warn-soft); }
.secret code { font-size: 13px; word-break: break-all; }
tr.muted td { color: var(--faint); }
/* barre impilate (dashboard del catalogo) */
.bar .stack-col { display: flex; flex-direction: column-reverse; width: 16px; }
.bar .stack-col i { width: 100%; border-radius: 0; }
.bar .stack-col i:last-child { border-radius: 4px 4px 0 0; }
.c0 { background: var(--accent) !important; } .c1 { background: #059669 !important; } .c2 { background: #d97706 !important; }
.c3 { background: #7c3aed !important; } .c4 { background: #94a3b8 !important; } .c5 { background: #cc0c39 !important; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; background: var(--dot); }
.bars.dense { gap: 2px; overflow: hidden; }
.bars.dense .bar { flex: 1; min-width: 0; }
.bars.dense .bar .stack-col { width: 100%; max-width: 18px; }
.bars.dense .bar span, .bars.dense .bar small { white-space: nowrap; min-height: 14px; }
.bars.dense .bar:hover .stack-col { opacity: .75; }

/* dashboard live */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .dash-cols { grid-template-columns: minmax(0, 1fr); } }
.dash-cols h3, .dash-rows h3, .dash-full h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 4px; }
.page-head .live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.page-head .live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: livepulse 2s ease-in-out infinite; }
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .page-head .live i { animation: none; } }
.alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--gap); }
.alert { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid var(--border); background: var(--surface); }
.alert.ok { color: var(--good); background: var(--good-soft); border-color: transparent; }
.alert.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.alert.ko { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.alert.info { color: var(--text); }
.kpis.people { margin-bottom: var(--gap); }
.kpis a.kpi { color: inherit; text-decoration: none; }
.kpis a.kpi:hover { background: var(--surface-2); }
.kpis.inner { margin: 8px 0 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.inner.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .kpis.inner { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi .hint { font-size: 12px; }
.statusbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 4px 0 6px; }
.statusbar i { display: block; height: 100%; }
.statusbar i.active { background: var(--good); } .statusbar i.pending { background: var(--warn); }
.statusbar i.error { background: var(--bad); } .statusbar i.muted { background: var(--faint); }
.legend .st::before { background: var(--faint); }
.legend .st.active::before { background: var(--good); } .legend .st.pending::before { background: var(--warn); }
.legend .st.error::before { background: var(--bad); }
.bars.dense.mini { height: 90px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed li > a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
.delta { font-weight: 600; font-size: 12px; } .delta.down { color: var(--good); } .delta.up { color: var(--bad); } .delta.new { color: var(--muted); font-weight: 400; }
.queue-mix { font-size: 13px; color: var(--muted); }
.queue-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 4px 0 12px; font-size: 13px; }
.queue-now b { font-size: 20px; }

/* frequenza dei controlli */
details.schedule { margin-bottom: var(--gap); }
details.schedule summary { cursor: pointer; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.schedule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 16px; margin-top: 10px; align-items: end; }

/* categorie */
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree li { padding: 5px 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
ul.tree li:first-child { border-top: 0; }
ul.tree .node-name { font-weight: 500; }
ul.tree .node-actions { margin-left: auto; display: inline-flex; gap: 8px; font-size: 13px; }
ul.tree li.muted .node-name { color: var(--faint); text-decoration: line-through; }
p.crumbs { font-size: 14px; margin: 6px 0 10px; }
.categories-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }

.import-progress { margin-top: 10px; }

/* workers */
.workers-card, .hosts-card, .tokens-card, .levels-card { margin-bottom: var(--gap); }
.workers-card .card-head { padding: 12px 16px 0; margin-bottom: 8px; }
td.actions { white-space: nowrap; }
td.actions button + button { margin-left: 4px; }
.hidden { display: none !important; }
.card-foot { padding: 8px 16px 12px; border-top: 1px solid var(--border); }
/* schede della pagina */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 var(--gap); overflow-x: auto; }
.tabs button { height: 36px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  color: var(--muted); font-weight: 550; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); background: none; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.group-tools { justify-content: space-between; }
.group-tools label.row input[type="checkbox"] { width: auto; height: auto; }
/* budget modificabile sul posto */
form.budget-field { display: inline-flex; align-items: center; gap: 4px; }
form.budget-field input { width: 84px; height: 28px; padding: 0 8px; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
form.budget-field input::placeholder { color: var(--faint); }
form.budget-field .unit { font-size: 12px; color: var(--faint); }
form.budget-field button { height: 28px; padding: 0 9px; }
form.budget-field.dirty input { border-color: var(--accent); }
form.budget-field.bad input { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
/* uso rispetto al budget */
.meter-wrap { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.meter { display: inline-block; width: 64px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.meter.high i { background: var(--warn); }
.meter.full i { background: var(--bad); }
.meter-text { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lvl { margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 11px; line-height: 18px; background: var(--surface-2); color: var(--muted); }
/* i tre livelli */
ol.levels { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; counter-reset: none; }
ol.levels li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); position: relative; }
ol.levels li + li::before { content: "›"; position: absolute; left: -9px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 18px; }
ol.levels b { font-size: 13.5px; }
ol.levels span { font-size: 12.5px; color: var(--muted); }
.levels-note { margin: 10px 0 0; }
@media (max-width: 760px) { ol.levels { grid-template-columns: 1fr; } ol.levels li + li::before { display: none; } }
dl.budget-levels { margin: 0; display: flex; flex-direction: column; gap: 8px; }
dl.budget-levels > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: center; }
dl.budget-levels dt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
dl.budget-levels dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13.5px; }
/* host con i loro worker */
.host-group { margin-bottom: var(--gap); }
.host-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px 2px; }
.host-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; flex: 1; min-width: 220px; }
.host-name { font-weight: 680; font-size: 15px; }
.host-budget { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.host-group.offline .host-name { color: var(--faint); }
.host-services { margin: 0; padding: 0 16px 10px; font-size: 12.5px; }
.host-error { margin: 0; padding: 0 16px 10px; }
.host-empty { padding: 4px 16px 14px; margin: 0; }
.host-body { padding: 4px 16px 16px; background: var(--surface-2); border-top: 1px solid var(--border); }
.host-body h3 { margin: 12px 0 6px; }
.host-body .service { min-width: 0; }
ul.containers { margin: 6px 0 0; padding-left: 18px; }
.host-group .table-wrap { border-top: 1px solid var(--border); }
button.ghost.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.grid.fields { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.warn-text { color: var(--warn); }
/* Categorie: proposte di mappatura e selettore con ricerca */
.review-bulk { gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.review-table td { vertical-align: top; }
.review-table td .hint { font-size: 12px; }
.review-actions { white-space: nowrap; }
.review-actions > * + * { margin-left: 8px; }
.picker { display: inline-block; position: relative; }
.picker-open { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.picker-hits { position: absolute; top: 100%; left: 0; z-index: 20; list-style: none; margin: 4px 0 0; padding: 4px 0; min-width: 320px; max-width: 520px; max-height: 300px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.picker-hits:empty { display: none; }
.picker-hits li { padding: 4px 10px; white-space: normal; }
.picker-hits li button.link { text-align: left; }
.review-actions .picker-hits { left: auto; right: 0; }
/* Grafici a linee (andamento dei fallimenti) */
.linechart svg { width: 100%; height: 190px; display: block; overflow: visible; }
.linechart .grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.linechart .axis { font-size: 10px; fill: var(--muted); }
.linechart .ln { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ln0 { --dot: var(--accent); stroke: var(--accent); fill: var(--accent); }
.ln1 { --dot: #059669; stroke: #059669; fill: #059669; }
.ln2 { --dot: #d97706; stroke: #d97706; fill: #d97706; }
.ln3 { --dot: #7c3aed; stroke: #7c3aed; fill: #7c3aed; }
.ln4 { --dot: #cc0c39; stroke: #cc0c39; fill: #cc0c39; }
.ln5 { --dot: #0891b2; stroke: #0891b2; fill: #0891b2; }
.ln6 { --dot: #64748b; stroke: #64748b; fill: #64748b; }
.ln7 { --dot: #ca8a04; stroke: #ca8a04; fill: #ca8a04; }
.linechart path.ln { fill: none; }
.linechart .threshold { stroke: #cc0c39; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.linechart .threshold-label { fill: #cc0c39; }
.areachart path.area { fill-opacity: .55; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
/* passaggio del mouse: colonna per orario con guida e punti (charts::hover_columns) */
.linechart .col .hit { fill: transparent; stroke: none; }
.linechart .col .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0; }
.linechart .col circle { r: 2.2px; stroke: var(--surface); stroke-width: 0; vector-effect: non-scaling-stroke; }
.linechart .col:hover .guide { opacity: 1; }
.linechart .col:hover circle { r: 4.5px; stroke-width: 1.5; opacity: 1; }
.areachart .col circle { opacity: 0; }
/* barre: quella sotto il mouse si evidenzia */
.bar:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 4px; }
.statusbar i:hover { filter: brightness(1.15); }
.legend a { color: var(--muted); }
.legend a::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; background: var(--dot); }
/* barre di ripartizione con le tinte dei grafici */
.statusbar i.k0 { background: var(--accent); } .statusbar i.k1 { background: #059669; } .statusbar i.k2 { background: #d97706; }
.statusbar i.k3 { background: #7c3aed; } .statusbar i.k4 { background: #94a3b8; } .statusbar i.k5 { background: #cc0c39; }
.legend .st.k0::before { background: var(--accent); } .legend .st.k1::before { background: #059669; } .legend .st.k2::before { background: #d97706; }
.legend .st.k3::before { background: #7c3aed; } .legend .st.k4::before { background: #94a3b8; } .legend .st.k5::before { background: #cc0c39; }
/* stato del catalogo: riquadri con percentuale e ripartizione */
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.health-tile h3 { margin: 0 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.health-tile .big { font-size: 26px; font-weight: 700; line-height: 1.2; }
.health-tile .big small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
/* dashboard: card a coppie su righe allineate */
.dash-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; margin-bottom: var(--gap); }
.dash-rows > .card { margin: 0; }
@media (max-width: 900px) { .dash-rows { grid-template-columns: 1fr; } }
