/* Pannello interno di gestione clienti. Non è la UI del prodotto: aspetto da
   strumento — denso, scuro, numeri leggibili. */
:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e242c;
  --line: #2a313b;
  --ink: #e7edf3;
  --ink-soft: #9aa7b4;
  --accent: #14ae5c;
  --warn: #e0a83a;
  --danger: #e5564b;
  --blue: #4a90d9;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
b { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 500; letter-spacing: .2px; }
.brand .mark {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  background: var(--accent); color: #06240f; border-radius: 6px; font-weight: 700; margin-right: 6px;
  vertical-align: -5px;
}
.brand .sep { color: var(--ink-soft); margin: 0 6px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.whoami { color: var(--ink-soft); font-size: 13px; }
/* La "A" a destra riporta nel gestionale (fuori dal pannello interno). */
.torna-app {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--accent); color: #06240f; border-radius: 6px;
  font-weight: 700; text-decoration: none; font-size: 14px;
  transition: filter .12s ease;
}
.torna-app:hover, .torna-app:focus-visible { filter: brightness(1.12); outline: none; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.totali { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.totali .kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-width: 110px;
}
.totali .kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.totali .kpi .l { color: var(--ink-soft); font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
#cerca, .dettaglio textarea, .dettaglio input[type="text"] {
  flex: 1; min-width: 200px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); padding: 8px 12px; font-size: 14px;
  font-family: inherit;
}
.dettaglio textarea { width: 100%; resize: vertical; }
#cerca:focus, .dettaglio textarea:focus, .dettaglio input[type="text"]:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.filtri { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.filtri button {
  background: transparent; border: 0; color: var(--ink-soft); padding: 5px 10px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.filtri button.on { background: var(--panel-2); color: var(--ink); }
.ghost {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px;
}
.ghost:hover { color: var(--ink); }

.tabella-wrap { border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-soft); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
.impresa .nome { font-weight: 600; }
.impresa .email { color: var(--ink-soft); font-size: 12px; }

select.piano {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 4px 6px; font-size: 13px; cursor: pointer;
}
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.ok { background: rgba(20,174,92,.15); color: #4cd18a; }
.badge.sospesa { background: rgba(229,86,75,.15); color: #f0837a; }
.badge.pausa { background: rgba(224,168,58,.15); color: var(--warn); }
.badge.mini { font-size: 11px; padding: 1px 6px; margin-left: 6px; }

.bar { position: relative; width: 90px; height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.bar.warn > i { background: var(--warn); }
.bar.full > i { background: var(--danger); }
.bar-txt { color: var(--ink-soft); font-size: 11px; }

td .apri { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
td .apri:hover { color: var(--ink); border-color: var(--ink-soft); }

.vuoto { color: var(--ink-soft); padding: 24px; text-align: center; }

/* Dettaglio */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; }
.dettaglio {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--panel); border-left: 1px solid var(--line); z-index: 21;
  overflow-y: auto; box-shadow: -20px 0 60px rgba(0,0,0,.4);
}
.dettaglio-inner { padding: 22px; }
.dettaglio h2 { margin: 0 0 2px; font-size: 19px; }
.dettaglio .sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 13px; word-break: break-all; }
.dettaglio .chiudi { position: absolute; top: 14px; right: 14px; background: transparent; border: 0; color: var(--ink-soft); font-size: 22px; cursor: pointer; }
.gruppo { margin-bottom: 20px; }
.gruppo > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); margin: 0 0 8px; }
.riga2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; }
.uso { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.uso .n { flex: 1; color: var(--ink-soft); }
.uso .q { font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }

.azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-block; background: var(--accent); color: #06240f; border: 0;
  border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; text-decoration: none; font-size: 14px;
}
.btn.sec { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: rgba(229,86,75,.15); color: #f0837a; border: 1px solid rgba(229,86,75,.3); }
.btn:disabled { opacity: .5; cursor: default; }

.mini-tab { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-tab td { padding: 4px 0; border-bottom: 1px solid var(--line); white-space: normal; }
.mini-tab td:last-child { text-align: right; color: var(--ink-soft); }

.blocco { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 40; }
.blocco-box { text-align: center; max-width: 360px; padding: 30px; }
.blocco-box h1 { font-size: 20px; margin: 0 0 8px; }
.blocco-box p { color: var(--ink-soft); margin: 0 0 20px; }

.conferma-box {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0,0,0,.55);
}
.conferma-inner {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.conferma-inner p { margin: 0 0 18px; }
.conferma-azioni { display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 18px; border-radius: 10px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.err { border-color: rgba(229,86,75,.5); }

@media (max-width: 640px) {
  .riga2 { grid-template-columns: 1fr; }
}
