/* myPBX – stile dell'interfaccia.
   Unico elemento forte: il pannello linee, scuro come il frontale di un centralino, con le spie.
   Tutto il resto è sobrio: tabelle, moduli, testo. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(fonts/barlow-400.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(fonts/barlow-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(fonts/barlow-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url(fonts/barlow-sc-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-sc-600.woff2) format("woff2"); }

:root {
  --fondo: #e8ecf0;
  --superficie: #ffffff;
  --superficie-2: #f3f5f8;
  --inchiostro: #17222d;
  --tenue: #586676;
  --filo: #cfd6de;
  --primario: #1d5c87;
  --primario-forte: #154766;
  --su-primario: #ffffff;
  --pericolo: #b3343f;
  --ok: #23774f;
  --allarme-fondo: #fbeaea;
  --avviso-fondo: #fdf3dc;
  --ok-fondo: #e3f3ea;
  --focus: #2b7fc0;

  /* Il frontale del pannello linee resta scuro anche nel tema chiaro. */
  --frontale: #1a2733;
  --frontale-presa: #213140;
  --frontale-filo: #2f4252;
  --frontale-testo: #e4ebf1;
  --frontale-tenue: #8fa2b4;
  --spia-verde: #34c27f;
  --spia-ambra: #f2ac1f;
  --spia-rossa: #e2525c;
  --spia-spenta: #3a4b5b;

  --grafico-in: #1d5c87;
  --grafico-out: #6aa8d3;
  --grafico-perse: #d9534f;

  --testo: "Barlow", system-ui, sans-serif;
  --stretto: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --raggio: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #0e141a; --superficie: #161f28; --superficie-2: #1b2631; --inchiostro: #e1e8ee; --tenue: #93a2b1;
    --filo: #2a3743; --primario: #5ea3d5; --primario-forte: #8cc0e6; --su-primario: #0b1620; --pericolo: #ef7680;
    --ok: #5dcf98; --allarme-fondo: #3a1d22; --avviso-fondo: #362b12; --ok-fondo: #15322a; --focus: #7dbcec;
    --frontale: #0b1218; --frontale-presa: #121c25; --frontale-filo: #22313e;
    --grafico-in: #5ea3d5; --grafico-out: #2f6c99; --grafico-perse: #ef7680;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #0e141a; --superficie: #161f28; --superficie-2: #1b2631; --inchiostro: #e1e8ee; --tenue: #93a2b1;
  --filo: #2a3743; --primario: #5ea3d5; --primario-forte: #8cc0e6; --su-primario: #0b1620; --pericolo: #ef7680;
  --ok: #5dcf98; --allarme-fondo: #3a1d22; --avviso-fondo: #362b12; --ok-fondo: #15322a; --focus: #7dbcec;
  --frontale: #0b1218; --frontale-presa: #121c25; --frontale-filo: #22313e;
  --grafico-in: #5ea3d5; --grafico-out: #2f6c99; --grafico-perse: #ef7680;
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--inchiostro);
  font: 400 1rem/1.5 var(--testo); font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--stretto); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--primario); text-underline-offset: .15em; }
a:hover { color: var(--primario-forte); }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--superficie-2); padding: .1em .35em; border-radius: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tenue { color: var(--tenue); }
/* Nome del chiamante su una riga, numero sotto. */
.chiamante { display: block; font-weight: 500; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.a-capo { word-break: break-all; }

/* ---------- Struttura ---------- */

.guscio { display: grid; grid-template-columns: 15rem 1fr; min-height: 100vh; }
.lato {
  background: var(--superficie); border-right: 1px solid var(--filo);
  padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.principale { padding: 2rem clamp(1rem, 3vw, 2.75rem) 4rem; max-width: 76rem; min-width: 0; }

.marchio {
  display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--inchiostro);
  font: 600 1.35rem/1 var(--stretto); margin-bottom: 1.5rem;
}
.marchio-spia {
  width: .8rem; height: .8rem; border-radius: 50%; background: var(--spia-verde);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spia-verde) 25%, transparent);
}
.menu-apri { display: none; }
.menu-gruppo { color: var(--tenue); font-size: .82rem; margin: 1.1rem .6rem .3rem; }
.lato ul { list-style: none; margin: 0; padding: 0; }
.lato li a {
  display: flex; align-items: center; justify-content: space-between;
  padding: .38rem .6rem; border-radius: var(--raggio); color: var(--inchiostro); text-decoration: none;
}
.lato li a:hover { background: var(--superficie-2); }
.lato li a[aria-current="page"] { background: var(--primario); color: var(--su-primario); font-weight: 500; }
.pallino { width: .5rem; height: .5rem; border-radius: 50%; background: var(--spia-ambra); }
.menu-utente {
  margin-top: 1.5rem; padding: .9rem .6rem 0; border-top: 1px solid var(--filo);
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
}
.menu-utente a { color: var(--inchiostro); font-weight: 500; text-decoration: none; }
.menu-utente a[aria-current="page"] { color: var(--primario); }

.testata { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.testata h1 { margin: 0; flex: 1 1 auto; }
.testata-nota { flex-basis: 100%; color: var(--tenue); margin: 0; }
.briciole { flex-basis: 100%; margin: 0; font-size: .95rem; }
.introduzione { color: var(--tenue); max-width: 62ch; margin-top: -.5rem; }

.quadro { background: var(--superficie); border: 1px solid var(--filo); border-radius: 6px; padding: 1.25rem 1.4rem; margin-bottom: 1.5rem; }
.quadro-testa { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 1rem; margin-bottom: .75rem; }
.quadro-testa h2 { margin: 0; }
.colonne { display: grid; grid-template-columns: minmax(16rem, 2fr) 3fr; gap: 1.5rem; }
.colonne > .quadro { margin-bottom: 1.5rem; }
.riquadro { background: var(--superficie); border: 1px solid var(--filo); border-radius: 6px; padding: 1.25rem 1.4rem; margin-bottom: 1.5rem; }
.vuoto { color: var(--tenue); padding: .5rem 0; }

/* ---------- Pannello linee ---------- */

#pannello-linee {
  background: var(--frontale); border-color: var(--frontale); color: var(--frontale-testo);
  background-image: radial-gradient(circle at 1px 1px, var(--frontale-filo) 1px, transparent 0);
  background-size: 14px 14px;
}
#pannello-linee a:not(.presa) { color: #9fd0f5; }
#pannello-linee .aggiornato, #pannello-linee .vuoto { color: var(--frontale-tenue); margin: 0; }
.fila-titolo { font-size: .95rem; font-weight: 500; color: var(--frontale-tenue); margin: 1rem 0 .5rem; }
.fila { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; }

.presa {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "spia numero" "nome nome" "stato stato";
  align-items: center; column-gap: .55rem;
  padding: .7rem .8rem .65rem; border-radius: 5px; text-decoration: none; color: var(--frontale-testo);
  background: var(--frontale-presa); border: 1px solid var(--frontale-filo);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), inset 0 -2px 0 rgb(0 0 0 / .25);
}
.presa:hover { border-color: var(--frontale-tenue); color: var(--frontale-testo); }
.presa .spia { grid-area: spia; }
.presa-numero { grid-area: numero; font: 600 1.45rem/1.1 var(--stretto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presa-nome { grid-area: nome; font-size: .9rem; margin-top: .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presa-stato { grid-area: stato; font-size: .8rem; color: var(--frontale-tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presa[data-spia="disattivo"] { opacity: .45; }

.spia {
  --c: var(--spia-spenta);
  display: inline-block; width: .95rem; height: .95rem; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff) 0 18%, var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000) 100%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .35);
}
[data-spia="libero"] .spia   { --c: var(--spia-verde); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--spia-verde) 55%, transparent); }
[data-spia="occupato"] .spia { --c: var(--spia-ambra); box-shadow: 0 0 10px 2px color-mix(in srgb, var(--spia-ambra) 60%, transparent); }
[data-spia="squilla"] .spia  { --c: var(--spia-ambra); animation: lampeggio .9s steps(2, jump-none) infinite; }
[data-spia="guasto"] .spia   { --c: var(--spia-rossa); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--spia-rossa) 55%, transparent); }
@keyframes lampeggio {
  from { box-shadow: 0 0 12px 3px color-mix(in srgb, var(--spia-ambra) 70%, transparent); }
  to   { --c: var(--spia-spenta); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  [data-spia="squilla"] .spia { animation: none; outline: 2px dashed var(--spia-ambra); outline-offset: 2px; }
}

.legenda { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; list-style: none; padding: 0; margin: 1.1rem 0 0; font-size: .85rem; }
.legenda li { display: flex; align-items: center; gap: .4rem; }
#pannello-linee .legenda { color: var(--frontale-tenue); }
.legenda .spia { width: .7rem; height: .7rem; }
.legenda-grafico { margin: 0; color: var(--tenue); }
.campione { width: .8rem; height: .8rem; border-radius: 2px; display: inline-block; }
.campione.c-in { background: var(--grafico-in); }
.campione.c-out { background: var(--grafico-out); }
.campione.c-perse { background: var(--grafico-perse); }

/* ---------- Contatori e grafico ---------- */

.contatori { width: 100%; border-collapse: collapse; }
.contatori th, .contatori td { padding: .55rem .25rem; border-bottom: 1px solid var(--filo); text-align: right; }
.contatori thead th { font-weight: 500; color: var(--tenue); font-size: .9rem; }
.contatori tbody th { text-align: left; font-weight: 500; }
.contatori tbody th a { color: var(--inchiostro); text-decoration: none; }
.contatori tr:last-child > * { border-bottom: 0; }
.cifra { font: 600 1.7rem/1 var(--stretto); color: var(--inchiostro); text-decoration: none; }
.cifra.perse { color: var(--pericolo); }
.cifra:hover { text-decoration: underline; }
.conteggio { font: 500 .95rem var(--stretto); color: var(--tenue); background: var(--superficie-2); border-radius: 99px; padding: .05rem .55rem; vertical-align: middle; }

.grafico { width: 100%; height: auto; display: block; }
.grafico .asse { stroke: var(--filo); }
.grafico .c-in { fill: var(--grafico-in); }
.grafico .c-out { fill: var(--grafico-out); }
.grafico .c-perse { fill: var(--grafico-perse); }
.grafico .etichetta { fill: var(--tenue); font: 500 10px var(--stretto); text-anchor: middle; }
.grafico .etichetta.festivo { fill: var(--inchiostro); }

/* ---------- Tabelle ---------- */

.scorre { overflow-x: auto; margin-bottom: 1.25rem; }
.tabella { width: 100%; border-collapse: collapse; background: var(--superficie); font-size: .95rem; }
.scorre > .tabella { border: 1px solid var(--filo); border-radius: 6px; }
.quadro .scorre > .tabella, .quadro .tabella { border: 0; }
.tabella th, .tabella td { padding: .55rem .8rem; border-bottom: 1px solid var(--filo); text-align: left; vertical-align: middle; }
.tabella thead th { font-weight: 500; color: var(--tenue); font-size: .88rem; background: var(--superficie-2); white-space: nowrap; }
.tabella tbody tr:last-child td { border-bottom: 0; }
.tabella tbody tr:hover { background: var(--superficie-2); }
.tabella .num { text-align: right; white-space: nowrap; }
.tabella .num-sx { white-space: nowrap; }
.tabella .riga-vuota td { color: var(--tenue); }
.tabella audio { height: 2rem; max-width: 14rem; display: block; }
.riga-allarme td { background: var(--allarme-fondo); }
.numero { font: 600 1.05rem var(--stretto); }
.esito { font-size: .85rem; font-weight: 500; padding: .1rem .5rem; border-radius: 99px; white-space: nowrap; }
.esito-ok { background: var(--ok-fondo); color: var(--ok); }
.esito-perso { background: var(--allarme-fondo); color: var(--pericolo); }
.azioni-riga { display: flex; gap: 1rem; justify-content: flex-end; }
.azioni-riga form { margin: 0; }

.pagine { display: flex; gap: 1.25rem; align-items: center; justify-content: center; }

/* ---------- Moduli ---------- */

.modulo { max-width: 34rem; }
.modulo.largo { max-width: 52rem; }
.modulo.riquadro { max-width: none; }
fieldset { border: 0; border-top: 1px solid var(--filo); margin: 0 0 1.25rem; padding: 1rem 0 0; }
legend { font: 600 1.1rem var(--stretto); padding-right: .75rem; }
.griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1.25rem; }
.campo { margin-bottom: 1rem; display: flex; flex-direction: column; }
.campo label { font-weight: 500; margin-bottom: .3rem; }
.aiuto { color: var(--tenue); font-size: .87rem; margin: .3rem 0 0; }
.errore-campo { color: var(--pericolo); font-size: .87rem; font-weight: 500; margin: .3rem 0 0; }

input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="file"]), select {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--filo); border-radius: var(--raggio);
  background: var(--superficie); min-height: 2.5rem;
}
input:not([type="checkbox"]):not([type="file"]):focus, select:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 30%, transparent); outline-offset: 0; }
.con-errore input, .con-errore select { border-color: var(--pericolo); }
input[type="file"] { padding: .4rem 0; }
input.mono { font-size: .92rem; }
.campo-spunta { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .1rem .55rem; }
.campo-spunta label { margin: 0; font-weight: 400; }
.campo-spunta .aiuto { flex-basis: 100%; margin: 0 0 0 1.65rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primario); margin: 0; }
.con-azione { display: flex; gap: .5rem; }

.avanzate { margin: 0 0 1.25rem; }
.avanzate summary { cursor: pointer; color: var(--primario); margin-bottom: .75rem; }

.azioni { display: flex; align-items: center; gap: 1.25rem; margin-top: .5rem; }

.bottone {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.1rem; min-height: 2.5rem; border-radius: var(--raggio); border: 1px solid var(--primario);
  background: var(--primario); color: var(--su-primario); font-weight: 500; text-decoration: none; cursor: pointer;
}
.bottone:hover { background: var(--primario-forte); border-color: var(--primario-forte); color: var(--su-primario); }
.bottone.secondario { background: transparent; color: var(--primario); }
.bottone.secondario:hover { background: var(--superficie-2); }
.bottone.pericolo { background: transparent; color: var(--pericolo); border-color: var(--pericolo); }
.bottone.pericolo:hover { background: var(--allarme-fondo); }
.bottone.piccolo { padding: .3rem .75rem; min-height: 2rem; font-size: .92rem; }
.link { background: none; border: 0; padding: 0; color: var(--primario); text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }
.link.pericolo { color: var(--pericolo); }

.zona-pericolo { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--filo); }

.filtri { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; margin-bottom: .5rem; }
.filtri .campo { min-width: 9rem; flex: 0 1 11rem; }
.filtri .bottone { margin-bottom: 1rem; }

/* Tasti dell'IVR: richiamano la tastiera del telefono. */
.tasti { border-collapse: collapse; margin-bottom: 1rem; width: 100%; max-width: 34rem; }
.tasti th, .tasti td { padding: .25rem .5rem .25rem 0; text-align: left; }
.tasti thead th { color: var(--tenue); font-weight: 500; font-size: .88rem; }
.tasto {
  display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem;
  border-radius: 50%; border: 1px solid var(--filo); background: var(--superficie-2);
  font: 600 1.15rem var(--stretto);
}

/* ---------- Avvisi ---------- */

.avviso { padding: .75rem 1rem; border-radius: var(--raggio); margin-bottom: 1rem; border-left: 4px solid; }
.avviso-ok { background: var(--ok-fondo); border-color: var(--ok); }
.avviso-errore { background: var(--allarme-fondo); border-color: var(--pericolo); }
.avviso-avviso { background: var(--avviso-fondo); border-color: var(--spia-ambra); }
.sospeso {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .6rem .6rem .6rem 1rem; margin-bottom: 1.25rem; border-radius: var(--raggio);
  background: var(--avviso-fondo); border: 1px solid color-mix(in srgb, var(--spia-ambra) 50%, transparent);
}

/* ---------- Pagine specifiche ---------- */

.applica { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.applica p, .applica form { margin: 0; }
.passi { padding-left: 1.25rem; }
.passi li { margin-bottom: .35rem; }
.file-conf { background: var(--superficie); border: 1px solid var(--filo); border-radius: var(--raggio); margin-bottom: .5rem; }
.file-conf summary { padding: .65rem 1rem; cursor: pointer; }
.file-conf pre { margin: 0; padding: 1rem; border-top: 1px solid var(--filo); overflow-x: auto; font: .82rem/1.5 var(--mono); background: var(--superficie-2); max-height: 32rem; }
.chiave { font-size: 1.15rem; letter-spacing: .08em; background: var(--superficie-2); padding: .5rem .75rem; border-radius: var(--raggio); display: inline-block; margin: .5rem 0; }
.dati { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0 0 1rem; }
.dati dt { color: var(--tenue); }
.dati dd { margin: 0; }

/* Accesso */
.pagina-accesso { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.accesso { width: 100%; max-width: 24rem; }
.accesso .modulo { background: var(--superficie); border: 1px solid var(--filo); border-radius: 6px; padding: 1.5rem; }
.accesso h1 { font-size: 1.5rem; }
.accesso label { display: block; font-weight: 500; margin: .9rem 0 .3rem; }
.accesso .bottone { width: 100%; margin-top: 1.25rem; }
.accesso .marchio { justify-content: center; }

/* ---------- Schermi stretti ---------- */

@media (max-width: 60rem) {
  .colonne { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 48rem) {
  .guscio { grid-template-columns: 1fr; }
  .lato { position: static; height: auto; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--filo); }
  .lato .marchio { margin: 0; }
  .lato { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .menu-apri { display: inline-flex; background: none; border: 1px solid var(--filo); border-radius: var(--raggio); padding: .35rem .8rem; cursor: pointer; }
  .menu-voci { display: none; flex-basis: 100%; }
  .menu-voci.aperto { display: block; }
  .principale { padding: 1.25rem 1rem 3rem; }
  .quadro, .riquadro { padding: 1rem; }
  .fila { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
  h1 { font-size: 1.6rem; }
}
