/* La scheda «Statistiche» della pagina «API v3» (assets/js/apistats.js).
   Il sito non ha un tema scuro: solo i colori chiari. */
.ad-page {
  --as-surface: #ffffff;
  --as-ink: #14161a;
  --as-ink-2: #52514e;
  --as-muted: #898781;
  --as-grid: #e1e0d9;
  --as-base: #c3c2b7;
  --as-ok: #2a78d6;
  --as-c4: #ec835a;
  --as-c5: #d03b3b;
  --as-p50: #2a78d6;
  --as-p95: #eb6834;
}

/* Schede Documentazione / Statistiche */
.ad-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e3e5e8; margin: 0 0 18px; }
.ad-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px 9px; font: 700 14px/1 inherit; color: #6c757d; cursor: pointer; margin-bottom: -1px; }
.ad-tab:hover { color: var(--as-ink); }
.ad-tab[aria-selected="true"] { color: var(--as-ink); border-bottom-color: var(--as-ink); }
.ad-tab:focus-visible { outline: 2px solid #4c8bf5; outline-offset: 2px; }

.as-pan { max-width: 1400px; }
.as-pan.as-carica #as-corpo { opacity: .5; transition: opacity .15s; }
.as-intro { font-size: 13px; color: var(--as-ink-2); max-width: 900px; margin: 0 0 14px; line-height: 1.5; }

/* Filtri: una riga sopra tutto */
.as-filtri { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.as-filtri select { width: auto; max-width: 240px; min-width: 140px; }
.as-range, .as-seg { display: inline-flex; background: #eceef1; border-radius: 8px; padding: 2px; }
.as-range button, .as-seg button { border: 0; background: none; padding: 6px 12px; font-size: 13px; font-weight: 600; color: #535c6b; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.as-range button:hover, .as-seg button:hover { color: var(--as-ink); }
.as-range button[aria-pressed="true"], .as-seg button[aria-pressed="true"] { background: var(--as-surface); color: var(--as-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.as-range button:focus-visible, .as-seg button:focus-visible { outline: 2px solid #4c8bf5; outline-offset: -2px; }
.as-seg button { padding: 4px 10px; font-size: 12px; }
.as-statoriga { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; margin: 10px 0 16px; min-height: 18px; }
#as-stato.ko { color: #b02a37; font-weight: 700; }
.as-filtri-attivi { font-size: 12.5px; color: var(--as-ink); font-weight: 600; }

/* Riquadri */
.as-kpi { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.as-tile { background: var(--as-surface); border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); border-top: 3px solid transparent; min-width: 0; }
.as-tile.c4 { border-top-color: var(--as-c4); }
.as-tile.c5 { border-top-color: var(--as-c5); }
.as-tile-l { font-size: 12px; color: var(--as-ink-2); font-weight: 600; }
.as-tile-v { font-size: 26px; font-weight: 700; color: var(--as-ink); margin-top: 4px; line-height: 1.15; }
.as-tile-n { font-size: 12px; color: var(--as-muted); margin-top: 4px; }

/* Schede dei grafici e delle tabelle */
.as-griglia { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.as-griglia-tab { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.as-card { background: var(--as-surface); border-radius: 8px; padding: 14px 16px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); min-width: 0; margin-bottom: 16px; }
.as-griglia .as-card { margin-bottom: 0; }
.as-card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.as-card-h h3 { font-size: 15px; font-weight: 800; margin: 0; color: var(--as-ink); }
.as-legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--as-ink-2); margin-bottom: 4px; }
.as-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.as-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.as-key.ok { background: var(--as-ok); }
.as-key.c4 { background: var(--as-c4); }
.as-key.c5 { background: var(--as-c5); }
.as-key.linea { width: 14px; height: 2px; border-radius: 1px; }
.as-key.linea.p50 { background: var(--as-p50); }
.as-key.linea.p95 { background: var(--as-p95); }
.as-grafico { width: 100%; min-height: 220px; }
.as-grafico svg { display: block; }
.as-grid { stroke: var(--as-grid); stroke-width: 1; shape-rendering: crispEdges; }
.as-base { stroke: var(--as-base); stroke-width: 1; shape-rendering: crispEdges; }
.as-ax { font-size: 11px; fill: var(--as-muted); font-variant-numeric: tabular-nums; }
.as-lab { font-size: 11.5px; fill: var(--as-ink-2); font-weight: 600; }
.as-dot { stroke: var(--as-surface); stroke-width: 2; }
.as-cross { stroke: var(--as-base); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.as-hit { fill: transparent; cursor: crosshair; outline: none; }
.as-hit.on, .as-hit:focus { fill: rgba(20, 22, 26, .05); }
.as-vuoto { font-size: 13px; color: var(--as-muted); padding: 18px 4px; }

/* Tooltip */
.as-tip { position: fixed; z-index: 1000; background: #1e2228; color: #f0efec; border-radius: 6px; padding: 8px 10px; font-size: 12px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.18); max-width: 300px; }
.as-tip-t { color: #c3c2b7; margin-bottom: 4px; }
.as-tip-r { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.as-tip-r strong { font-variant-numeric: tabular-nums; min-width: 44px; }
.as-tip-l { color: #c3c2b7; }

/* Tabelle */
.as-scroll { overflow-x: auto; }
.as-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.as-table th { text-align: left; font-size: 11.5px; color: #6c757d; border-bottom: 1px solid #e3e5e8; padding: 5px 8px; white-space: nowrap; font-weight: 600; }
.as-table td { border-bottom: 1px solid #f0f1f3; padding: 6px 8px; vertical-align: middle; }
.as-table .ad-m { width: 52px; font-size: 10px; padding: 4px 0; }
.as-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.as-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.as-path { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-nowrap { white-space: nowrap; }
.as-sub { font-size: 11px; color: var(--as-muted); margin-top: 1px; word-break: break-all; }
.as-click { cursor: pointer; }
.as-click:hover td { background: #f7f8fa; }
.as-click:focus { outline: 2px solid #4c8bf5; outline-offset: -2px; }
.as-barra { position: relative; min-width: 90px; }
.as-barra span:last-child { position: relative; }
.as-bar { position: absolute; right: 8px; top: 50%; height: 4px; margin-top: 8px; background: var(--as-ok); opacity: .35; border-radius: 2px; max-width: calc(100% - 16px); }
.as-c4 { color: #a8481f; font-weight: 600; }
.as-c5 { color: #b02a37; font-weight: 700; }
.as-forte { font-weight: 700; }
.as-stato { display: inline-block; min-width: 38px; text-align: center; padding: 2px 6px; border-radius: 10px; font-weight: 700; font-size: 11.5px; }
.as-stato.c4 { background: #fdeee6; color: #a8481f; }
.as-stato.c5 { background: #fdecee; color: #b02a37; }
.as-link { background: none; border: 0; color: #2f7dd1; font-size: 12.5px; padding: 8px 0 0; cursor: pointer; }
.as-link:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .as-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .as-griglia, .as-griglia-tab { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ad-page { padding-left: 16px; padding-right: 16px; }
  .as-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .as-tile { padding: 10px 12px; }
  .as-tile-v { font-size: 21px; }
  .as-filtri select { flex: 1 1 100%; max-width: none; }
  .as-card { padding: 12px 10px 10px; }
  .as-path { max-width: 200px; }
  /* Rotte: via la colonna Max; errori: una scheda per riga invece della tabella */
  .as-largo .as-table th:nth-child(7), .as-largo .as-table td:nth-child(7) { display: none; }
  .as-err thead { display: none; }
  .as-err, .as-err tbody { display: block; }
  .as-err tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid #f0f1f3; }
  .as-err td { border: 0; padding: 0; }
  .as-err td:nth-child(1) { order: 1; font-weight: 600; }
  .as-err td:nth-child(2) { order: 2; }
  .as-err td:nth-child(4) { order: 3; }
  .as-err td:nth-child(5) { order: 4; }
  .as-err td:nth-child(7) { order: 5; margin-left: auto; }
  .as-err td:nth-child(3) { order: 6; flex: 1 1 100%; max-width: none; white-space: normal; word-break: break-all; }
  .as-err td:nth-child(6) { order: 7; flex: 1 1 100%; }
}
