/* Pannello di CentralinoVoip.click: stesso linguaggio dell'app
   (nero, testo caldo, verde per ciò che è attivo). I numeri di telefono
   sono in JetBrains Mono: sono il materiale di cui è fatto un centralino. */

@font-face { font-family: Barlow; src: url(fonts/Barlow-Regular.ttf); font-weight: 400; }
@font-face { font-family: Barlow; src: url(fonts/Barlow-Medium.ttf); font-weight: 500; }
@font-face { font-family: Barlow; src: url(fonts/Barlow-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: JBMono; src: url(fonts/JetBrainsMono-Variable.ttf); font-weight: 100 800; }

:root {
  --bg: #000000;
  --surface: #141415;
  --raise: #1b1b1c;
  --line: #232324;
  --line-soft: #19191a;
  --text: #f2f2f0;
  --soft: #bdbdbb;
  --muted: #8a8a88;
  --dim: #5e5e5c;
  --green: #3ddc84;
  --green-ink: #062a15;
  --red: #e23b2e;
  --amber: #f2b33d;
  --sans: Barlow, system-ui, sans-serif;
  --mono: JBMono, ui-monospace, monospace;
  --accent-text: #3ddc84;
  --amber-text: #f2b33d;
  --red-text: #ff7a70;
  --line-hover: #3a3a3b;
  --row-hover: #0d0d0e;
  --pressed: #262627;
  --on-text: #000000;
  color-scheme: dark;
  --rail: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ guscio */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); padding: 22px 14px 18px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 10px 22px; font-weight: 600; font-size: 17px; }
.brand svg { width: 26px; height: 26px; color: var(--accent-text); }
.tenant-switch {
  width: 100%; min-width: 0; text-align: left; background: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; display: grid; gap: 2px;
}
.tenant-switch:hover { border-color: var(--line-hover); }
.tenant-name { font-weight: 600; font-size: 17px; line-height: 1.2; }
.tenant-domain { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-menu {
  margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  max-height: 320px; overflow: auto; padding: 6px;
}
.tenant-menu button {
  display: grid; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px;
  border-radius: 8px; cursor: pointer;
}
.tenant-menu button:hover, .tenant-menu button[aria-selected="true"] { background: var(--raise); }
.tenant-menu small { font: 11px var(--mono); color: var(--muted); }
.nav { display: grid; gap: 1px; margin-top: 18px; }
.nav a {
  text-decoration: none; color: var(--soft); padding: 8px 12px; border-radius: 8px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.nav a:hover { color: var(--text); background: var(--line-soft); }
.nav a[aria-current="page"] { color: var(--text); background: var(--raise); }
.nav a .count { font: 12px var(--mono); color: var(--dim); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 12px; }
.rail-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0 12px; font-size: 13px; color: var(--muted); }
.rail-foot a, .rail-foot .link { white-space: nowrap; }
.rail-foot a { text-decoration: none; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; }
.link:hover, .rail-foot a:hover { color: var(--text); }

/* tutta la larghezza dello schermo: le tabelle si allargano, i moduli restano leggibili nei riquadri */
main { padding: 40px 56px 80px; width: 100%; min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 18px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px 22px; display: grid; gap: 18px; background: var(--surface); min-width: 0; }
.card > h2 { margin: 0; font-size: 17px; }
.cards-foot { display: flex; gap: 10px; margin-top: 22px; }
main:focus, main:focus-visible { outline: none; }

/* ------------------------------------------------------------ testate */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.head h1 { font-weight: 600; font-size: 30px; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
.head p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
h2 { font-weight: 600; font-size: 19px; margin: 44px 0 14px; }

/* ------------------------------------------------------------ pulsanti */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 18px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap;
  font-weight: 500;
}
.btn:hover { border-color: var(--line-hover); }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: #000; }
.btn.primary { background: var(--green); color: #000; border-color: var(--green); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red-text); background: none; }
.btn.ghost { background: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------ tabelle */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 13px; color: var(--muted);
  padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover td { background: var(--row-hover); }
td.num, th.num { white-space: nowrap; }
td .sub { display: block; font-size: 13px; color: var(--muted); }
.right { text-align: right; }
.empty { padding: 48px 0; color: var(--muted); }
.empty p { margin: 0 0 16px; max-width: 52ch; }

/* stato */
.state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.state.on { color: var(--text); }
.state.on::before { background: var(--green); box-shadow: 0 0 0 3px rgba(61,220,132,.15); }
.state.warn::before { background: var(--amber); }
.state.off::before { background: var(--red); }
.tag { font-size: 13px; color: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; margin-right: 4px; }

/* ------------------------------------------------------------ riepilogo */
.facts { display: flex; flex-wrap: wrap; gap: 10px 36px; color: var(--soft); font-size: 16px; }
.facts b { font-family: var(--mono); font-weight: 500; color: var(--text); margin-right: 6px; }

/* ------------------------------------------------------------ percorso chiamata */
.flows { display: grid; gap: 14px; }
.flow {
  display: grid; grid-template-columns: 220px 1fr; gap: 0 28px; align-items: start;
  padding: 20px 0; border-top: 1px solid var(--line-soft);
}
.flow:first-child { border-top: 0; }
.flow-did .num { font-size: 21px; display: block; line-height: 1.2; }
.flow-did .label { color: var(--muted); font-size: 14px; }
.path { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0; min-width: 0; }
.flow > .path { overflow-x: auto; }
.step {
  position: relative; padding: 6px 14px 6px 0; margin-right: 34px; min-width: 0;
}
.step + .step::before, .branch-row .step:first-of-type::before {
  content: ""; position: absolute; left: -34px; top: 19px; width: 26px; height: 1px; background: var(--dim);
}
.step + .step::after, .branch-row .step:first-of-type::after {
  content: ""; position: absolute; left: -13px; top: 15px; border: 4px solid transparent; border-left: 6px solid var(--dim);
}
.step .kind { font-size: 13px; color: var(--muted); display: block; }
.step .what { font-weight: 500; }
.step .who { display: block; font: 13px var(--mono); color: var(--soft); }
.branches { display: grid; gap: 10px; margin-left: 0; }
.branch-row { display: flex; align-items: flex-start; }
.branch-row > .when {
  font-size: 13px; color: var(--accent-text); width: 74px; padding-top: 6px; flex: none; margin-right: 34px;
}
.branch-row > .when.closed { color: var(--amber-text); }
.branch-row .step:first-of-type::before { left: -34px; }
.flow-loop { color: var(--amber-text); font-size: 13px; }

/* ------------------------------------------------------------ pannello laterale */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface);
  border-left: 1px solid var(--line); z-index: 11; transform: translateX(100%);
  transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer:not(.open) { visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
.drawer.open { transform: none; }
.drawer header { padding: 24px 28px 8px; }
.drawer header h3 { margin: 0; font-weight: 600; font-size: 22px; }
.drawer header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.drawer form { flex: 1; overflow: auto; padding: 12px 28px 24px; display: grid; gap: 18px; align-content: start; }
.drawer footer { padding: 16px 28px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.drawer footer .spacer { flex: 1; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* campi */
.field { display: grid; gap: 6px; }
details.more { border-top: 1px solid var(--line); padding-top: 14px; }
details.more > summary { cursor: pointer; color: var(--accent-text); font-weight: 500; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; display: inline-block; width: 18px; }
details.more[open] > summary::before { content: "–"; }
details.more .more-body { display: grid; gap: 18px; margin-top: 18px; }
.field > label, .field > .label { font-size: 14px; color: var(--soft); }
.field small { color: var(--muted); font-size: 13px; }
input:not([type]), input[type=search], input[type=text], input[type=number], input[type=email], input[type=password], input[type=time], input[type=date], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: none; }
input.num { font-family: var(--mono); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--soft); transition: transform .15s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(16px); background: #000; }
.switch span small { display: block; }
.secret { display: flex; gap: 8px; }
.secret input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-family: var(--mono); font-size: 14px; }
.chips input { display: none; }
.chips label:has(input:checked) { border-color: var(--green); color: var(--accent-text); background: rgba(61,220,132,.07); }
.rows { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .x { flex: none; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; font-size: 18px; line-height: 1; }
.row > .key { flex: 0 0 56px; text-align: center; }
.add { justify-self: start; background: none; border: 0; color: var(--accent-text); cursor: pointer; padding: 2px 0; }
.err { color: var(--red-text); font-size: 14px; }

/* ------------------------------------------------------------ storico */
.dir { display: inline-flex; width: 22px; color: var(--muted); }
.dir.in { color: var(--accent-text); }
.dir.out { color: var(--soft); }
.dir.miss { color: var(--red-text); }
.play { background: none; border: 1px solid var(--line); border-radius: 99px; width: 30px; height: 30px; cursor: pointer; color: var(--soft); }
.play:hover { color: var(--accent-text); border-color: var(--green); }
.filters { display: flex; gap: 6px; margin-bottom: 18px; }
.filters button { background: none; border: 1px solid var(--line); border-radius: 99px; padding: 5px 14px; cursor: pointer; color: var(--soft); }
.filters button[aria-pressed="true"] { border-color: var(--text); color: var(--text); }

/* ------------------------------------------------------------ accesso */
.login { max-width: 380px; margin: 14vh auto 0; display: grid; gap: 16px; }
.login h1 { font-weight: 600; font-size: 28px; margin: 0; }
.login p { color: var(--muted); margin: 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 500;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

/* ------------------------------------------------------------ telefono */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; }
  .nav .sep, .rail-foot { display: none; }
  main { padding: 28px 16px 64px; }
  .head { flex-direction: column; align-items: flex-start; }
  .head > div:first-child { flex: none; min-width: 0; }
  .head-actions { justify-content: flex-start; }
  .flow { grid-template-columns: 1fr; gap: 10px; }
  .shell, main { min-width: 0; overflow-x: hidden; }
  .path, .branch-row { flex-direction: column; }
  .step { margin-right: 0; padding-left: 14px; border-left: 1px solid var(--line); margin-left: 4px; }
  .step + .step::before, .step + .step::after, .branch-row .step:first-of-type::before, .branch-row .step:first-of-type::after { display: none; }
  .branch-row > .when { width: auto; margin: 8px 0 2px; padding: 0; }
  .branches { margin-left: 18px; }
  .facts { flex-direction: column; }
  table { display: block; overflow-x: auto; }
  .tenant-switch { width: 100%; min-width: 0; }
  .hide-sm { display: none; }
  td, th { padding-left: 6px; padding-right: 6px; }
}

/* provisioning */
.provbox { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 28px; padding: 18px 0 26px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.provbox .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.provbox code { display: block; font-size: 14px; color: var(--text); word-break: break-all; margin-bottom: 6px; }
.provbox small { color: var(--muted); font-size: 13px; }
/* indirizzi e password senza spazi: vanno a capo dove serve, altrimenti sul telefono uscivano dallo schermo */
.provbox .num { overflow-wrap: anywhere; }
@media (max-width: 860px) { .provbox { grid-template-columns: minmax(0, 1fr); } }

/* tasti */
.keyrow {
  display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft);
  grid-template-columns: 116px 64px 1fr 28px;
  grid-template-areas: "exp pos type x" "val val lab lab";
}
.keyrow .kexp { grid-area: exp; } .keyrow .kpos { grid-area: pos; } .keyrow .ktype { grid-area: type; }
.keyrow .kval { grid-area: val; min-width: 0; } .keyrow .klab { grid-area: lab; min-width: 0; }
.keyrow .x { grid-area: x; }
.keyrow > * { min-width: 0; }
textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical; font-size: 13px; }
.drawer { width: min(560px, 100vw); }
.drawer header .link { margin-top: 10px; color: var(--accent-text); }
.cfg { max-height: 320px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font: 12px/1.5 var(--mono); color: var(--soft); white-space: pre; margin: 10px 0 0; }

/* filtri e sfondo */
.flow-filters { display: block; margin-top: 8px; font-size: 13px; color: var(--amber-text); text-decoration: none; }
.flow-filters:hover { text-decoration: underline; }
.wall { display: flex; gap: 18px; align-items: flex-start; }
.wall-preview { width: 200px; aspect-ratio: 5 / 3; border: 1px solid var(--line); border-radius: 10px; background: var(--surface) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; flex: none; }
.wall-actions { display: grid; gap: 8px; justify-items: start; }
.wall-actions small { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ utenti */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
/* il testo prende lo spazio che avanza: i pulsanti restano su una riga finché ci stanno */
.head > div:first-child { flex: 1 1 0; min-width: 260px; }
.invite { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; }
.invite p { margin: 0; color: var(--muted); font-size: 14px; }
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite code { font-size: 12px; word-break: break-all; color: var(--soft); }
body.tenant-user .tenant-switch { cursor: default; }
body.tenant-user .tenant-switch:hover { border-color: var(--line); }
#certBox small { display: block; margin-top: 4px; }

/* messaggi vocali */
.sheet { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; margin-bottom: 22px; background: var(--surface); max-width: 640px; }
.sheet textarea { width: 100%; }
.rec { display: flex; align-items: center; gap: 14px; }
.rec .num { font-size: 20px; }
.btn.primary.danger { background: var(--red); border-color: var(--red); color: #fff; }
.sheet.inline { max-width: none; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: end; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--soft); padding-bottom: 10px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; }
.sheet.secret { border-color: var(--green); }
.sheet.secret code { font-size: 14px; word-break: break-all; color: var(--accent-text); }
@media (max-width: 860px) { .sheet.inline { grid-template-columns: 1fr; } }
.imp { overflow: auto; padding: 0 28px; display: grid; gap: 8px; }
.imp h4 { margin: 14px 0 0; font-weight: 500; color: var(--soft); }
.imp td { padding: 8px 6px; font-size: 14px; }
.warn-text { color: var(--amber-text); }
.sub.warn-text { color: var(--amber-text); }

/* controllo del sistema */
.sys-summary { font-size: 20px; font-weight: 600; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sys-summary.ok { color: var(--accent-text); }
.sys-summary.warn { color: var(--amber-text); }
.sys-summary.bad { color: var(--red-text); }
.sys-summary .muted { font-size: 14px; font-weight: 400; }
.checklist { display: grid; border-top: 1px solid var(--line); }
.check { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: start; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.check .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; background: var(--dim); }
.check.ok .dot { background: var(--green); }
.check.warn .dot { background: var(--amber); }
.check.bad .dot { background: var(--red); }
.check b { font-weight: 500; display: block; }
.check span { color: var(--muted); font-size: 14px; }
.check .verdict { font-size: 13px; white-space: nowrap; }
.check.bad .verdict { color: var(--red-text); }
.check.warn .verdict { color: var(--amber-text); }
.switch-line { display: inline-flex; gap: 10px; align-items: center; white-space: nowrap; cursor: pointer; }
.switch-line input { width: 18px; height: 18px; accent-color: var(--green); }
.checks { display: grid; gap: 4px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.tag.bad { color: var(--red-text); border-color: var(--red); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.filters input[type=search] { flex: 1 1 240px; }
.filters label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
table.audit .chg { font-size: 14px; line-height: 1.5; }
table.audit tr.undone td { opacity: .55; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0 0 22px; }
.kpis > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 4px; }
.kpis .num { font-size: 26px; font-weight: 600; }
.kpis small { color: var(--muted); font-size: 13px; }
.stat { margin: 0 0 26px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
table.sortable th button { all: unset; cursor: pointer; font: inherit; color: inherit; }
table.sortable th button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
td.right, th.right { text-align: right; }
.hol-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hol-pick { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; margin-top: 8px; }
.hol-pick .checks label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.hol-pick .patron { display: grid; gap: 4px; font-size: 14px; }
.hol-pick .actions { display: flex; gap: 10px; }
.row .hol-name { font-size: 13px; align-self: center; white-space: nowrap; }
.filters select, .filters input[type=date] { width: auto; flex: 0 1 auto; min-width: 0; }
.rail { overflow-y: auto; }

/* ------------------------------------------------------------ tema chiaro */

/* ------------------------------------------------------------ flusso chiamate */
.fl-pick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 4px 0 14px; }
.fl-pick a {
  text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
  display: grid; white-space: nowrap; color: var(--soft);
}
.fl-pick a small { color: var(--muted); font-size: 12px; }
.fl-pick a[aria-selected="true"] { border-color: var(--green); color: var(--text); background: var(--surface); }
.fl-note { color: var(--muted); margin: 0 0 12px; }
.fl-canvas {
  overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px;
  margin-top: 10px;
}
.fl-tree { display: inline-block; min-width: 100%; }
.fl-sub-tree { display: flex; align-items: center; }
.fl-kids { display: flex; flex-direction: column; position: relative; padding-left: 22px; }
.fl-kids::before { content: ""; position: absolute; left: 0; top: 50%; width: 22px; border-top: 2px solid var(--line-hover); }
.fl-kid { position: relative; display: flex; align-items: center; padding: 7px 0 7px 22px; }
.fl-kid::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--line-hover); }
.fl-kid:first-child::before { top: 50%; }
.fl-kid:last-child::before { bottom: 50%; }
.fl-kid:only-child::before { display: none; }
.fl-kid::after { content: ""; position: absolute; left: 0; top: 50%; width: 22px; border-top: 2px solid var(--line-hover); }
.fl-edge {
  position: relative; z-index: 1; flex: none; margin-right: 10px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line-hover); background: var(--bg); color: var(--soft); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.fl-edge.warn { color: var(--amber-text); }
.fl-edge:hover { border-color: var(--text); color: var(--text); }
.fl-edge::after { content: ""; position: absolute; right: -11px; top: 50%; width: 10px; border-top: 2px solid var(--line-hover); }
.fl-card {
  flex: none; width: 214px; text-align: left; display: grid; gap: 2px; padding: 11px 14px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
div.fl-card { cursor: default; }
button.fl-card:hover { border-color: var(--line-hover); background: var(--raise); }
.fl-card.k-did { width: 224px; border-color: var(--green); }
.fl-card.k-did .fl-name { font-size: 19px; }
.fl-card.k-missing { border-color: var(--red); }
.fl-card.k-hangup { width: auto; }
.fl-card.flash { animation: flflash 1.2s ease-out; }
@keyframes flflash { 0% { box-shadow: 0 0 0 4px var(--green); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .fl-card.flash { animation: none; outline: 2px solid var(--green); } }
.fl-kind { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.fl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.fl-dot.k-did, .fl-dot.k-ext, .fl-dot.k-group, .fl-dot.k-toggle.on { background: var(--green); }
.fl-dot.k-tc, .fl-dot.k-toggle.off { background: var(--amber); }
.fl-dot.k-ivr { background: var(--text); }
.fl-dot.k-hangup, .fl-dot.k-missing { background: var(--red); }
.fl-name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.fl-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.fl-empty {
  flex: none; border: 1.5px dashed var(--line-hover); background: none; border-radius: 12px; padding: 10px 14px;
  color: var(--muted); cursor: pointer; text-align: left; max-width: 236px;
}
.fl-empty b { color: var(--accent-text); font-weight: 600; margin-right: 4px; }
.fl-empty:hover { border-color: var(--green); color: var(--text); }
.fl-ref {
  flex: none; border: 1px dashed var(--line-hover); background: none; border-radius: 10px; padding: 7px 12px;
  color: var(--soft); font-size: 13px; cursor: pointer;
}
.fl-ref:hover { color: var(--text); border-color: var(--text); }
.fl-create { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.fl-create .label { color: var(--muted); font-size: 14px; }
.fl-create-btns { display: flex; flex-wrap: wrap; gap: 6px; }
/* telefono: lo schema diventa verticale, rami rientrati sotto il blocco */
@media (max-width: 720px) {
  .fl-canvas { padding: 16px 12px; background-image: none; }
  .fl-tree { display: block; }
  .fl-sub-tree { flex-direction: column; align-items: stretch; }
  .fl-kids { padding-left: 0; margin-left: 12px; border-left: 2px solid var(--line-hover); }
  .fl-kids::before, .fl-kid::before, .fl-edge::after { display: none; }
  .fl-kid { flex-direction: column; align-items: flex-start; padding: 12px 0 0 14px; }
  .fl-kid::after { left: 0; top: 25px; width: 12px; }
  .fl-edge { margin: 0 0 6px; }
  .fl-card, .fl-card.k-did, .fl-empty { width: 100%; max-width: none; }
  .fl-kid > .fl-sub-tree { align-self: stretch; }
}

:root[data-theme="light"] {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --raise: #ededea;
  --line: #dcdcd7;
  --line-soft: #e8e8e4;
  --text: #171716;
  --soft: #3f3f3c;
  --muted: #6a6a66;
  --dim: #9b9b97;
  --green: #2fc06f;
  --green-ink: #062a15;
  --red: #d8382b;
  --amber: #d99a1e;
  --accent-text: #137a42;
  --amber-text: #8f5f00;
  --red-text: #b8281d;
  --line-hover: #b9b9b4;
  --row-hover: #efefeb;
  --pressed: #e2e2de;
  --on-text: #ffffff;
  color-scheme: light;
}
input[type=checkbox], input[type=radio] { accent-color: var(--green); }
