/* LeakFinder Cloud - tema "Notte" (pannello admin)
   Un solo file per tutto il pannello: colori e misure sono variabili, cosi'
   cambiare l'accento o l'arrotondamento e' una riga. */

:root {
  --bg: #08090b;
  --shell: #0e1013;
  --shell-line: #1e2127;
  --core: #121418;
  --tile: #181b20;
  --tile-hover: #1e2228;
  --line: #23262d;
  --line-strong: #2c3038;
  --text: #eceef1;
  --muted: #9ba3af;
  --accent: #34d399;
  --accent-ink: #04130d;
  --ok: #6ee7b7;
  --warn: #fbbf24;
  --bad: #fca5a5;
  --info: #7dd3fc;
  --r-shell: 30px;
  --r-core: 24px;
  --r-tile: 18px;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ok); text-decoration: none; }
a:hover { color: #a7f3d0; }
:focus-visible { outline: 2px solid var(--ok); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.93em; }
code { background: var(--tile); padding: 2px 6px; border-radius: 6px; }
strong { font-weight: 600; }
ul, ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
li { margin: 4px 0; }
li strong { color: var(--text); }

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100dvh;
}

/* ------------------------------------------------------------ navigazione */
.nav-wrap { position: sticky; top: 14px; z-index: 30; display: flex; justify-content: center; }

.nav-pill {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
  padding: 6px;
  border-radius: 999px;
  background: rgba(18, 20, 24, 0.86);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

.nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 14px 0 10px; color: var(--text); font-weight: 500; }
.nav-brand:hover { color: var(--text); }
.nav-brand img { height: 22px; width: auto; display: block; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  transition: background 0.5s var(--spring), color 0.5s var(--spring);
}
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-link.is-active { color: #ffffff; background: var(--line); }

.nav-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }

.lang { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.lang button {
  min-width: 40px; min-height: 36px; border: none; border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.lang button.active { background: var(--line); color: #ffffff; }

.user { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px 0 6px;
  border: none; border-radius: 999px; background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
.user-btn:hover { background: rgba(255, 255, 255, 0.05); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}
.user-role { color: var(--muted); font-size: 12px; display: block; line-height: 1.1; }
.user-name { display: block; line-height: 1.2; font-weight: 500; text-align: left; }

.menu {
  position: absolute; right: 0; top: calc(100% + 12px); min-width: 210px; padding: 8px;
  border-radius: 20px; background: var(--core); border: 1px solid var(--line-strong);
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.9);
  opacity: 0; transform: translateY(-8px) scale(0.98); pointer-events: none;
  transition: opacity 0.4s var(--spring), transform 0.4s var(--spring);
}
.menu.show { opacity: 1; transform: none; pointer-events: auto; }
.menu a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--text); }
.menu a:hover { background: var(--tile); color: var(--text); }
.menu a.is-danger { color: var(--bad); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ------------------------------------------------------------ intestazione di pagina */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head h1 { font-size: clamp(32px, 4vw, 44px); font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; }
.head p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { display: inline-flex; }

/* ------------------------------------------------------------ riquadri (doppia cornice) */
.bezel { padding: 6px; border-radius: var(--r-shell); background: var(--shell); border: 1px solid var(--shell-line); }
.core {
  height: 100%;
  border-radius: var(--r-core);
  background: var(--core);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 26px;
}
.core.flush { padding: 8px; }
.core h2 { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.core h2 i { color: var(--muted); margin-right: 6px; }
.core h3 { font-size: 15px; font-weight: 600; margin-top: 18px; }
.core-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 20px; }
.grid.narrow { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; }
.span-all { grid-column: 1 / -1; }
@media (min-width: 900px) { .grid.side { grid-template-columns: minmax(min(280px, 100%), 1fr) 2fr; } }
.stack { display: flex; flex-direction: column; gap: 20px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (min-width: 960px) { .span-2 { grid-column: span 2; } }

/* ------------------------------------------------------------ numeri */
.stat-label { color: var(--muted); }
.stat-value { font-size: 52px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-note { color: var(--muted); font-size: 14px; }
.hero-value { font-size: clamp(64px, 9vw, 96px); font-weight: 300; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; }

/* ------------------------------------------------------------ tessere ed elenchi */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.tile { display: block; border-radius: var(--r-tile); background: var(--tile); padding: 18px; color: var(--text); transition: background 0.5s var(--spring), transform 0.5s var(--spring); }
a.tile:hover { background: var(--tile-hover); color: var(--text); transform: translateY(-2px); }
.tile .big { font-size: 28px; font-weight: 300; margin-top: 12px; }
.tile .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 10px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 13px; color: var(--muted); }
.triple div div { color: var(--text); font-size: 15px; }

.note { margin-top: 18px; padding: 14px 16px; border-radius: var(--r-tile); background: var(--tile); color: var(--muted); white-space: pre-wrap; }
.callout { margin-top: 18px; padding: 14px 16px; border-radius: var(--r-tile); background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.22); color: var(--text); }
.callout.warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.28); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty i { font-size: 36px; color: var(--line-strong); }

/* ------------------------------------------------------------ grafici
   Colori delle serie verificati per daltonismo e contrasto sul fondo scuro
   (Android #1fae84, iOS #7c83f0). Il testo resta sempre nei colori del testo:
   l'identita' la porta il quadratino accanto, mai il colore della scritta. */
:root { --p-android: #1fae84; --p-ios: #7c83f0; --p-other: #6b7280; }
.p-android { background: var(--p-android); }
.p-ios { background: var(--p-ios); }
.p-other { background: var(--p-other); }

.share { display: flex; gap: 2px; height: 14px; }
.share-seg { min-width: 4px; border-radius: 4px; }

.legend { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 48px; align-items: baseline; gap: 10px; margin: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; align-self: center; }
.legend-value { font-size: 28px; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.cols { display: flex; align-items: flex-end; gap: 6px; height: 170px; }
.col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px; outline-offset: 2px; }
.col-stack { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); }
.col-seg { width: 100%; max-width: 24px; min-height: 3px; border-radius: 4px 4px 0 0; }
.col-seg + .col-seg { border-radius: 0; }
.col-label { margin-top: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.col:hover .col-seg, .col:focus-visible .col-seg { filter: brightness(1.18); }
.col-tip {
  position: absolute; bottom: calc(100% - 24px); left: 50%; z-index: 5; transform: translate(-50%, 4px);
  display: flex; flex-direction: column; gap: 4px; min-width: 132px; padding: 10px 12px;
  border-radius: 12px; background: var(--bg); border: 1px solid var(--line-strong); font-size: 13px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--spring), transform 0.3s var(--spring);
}
.col-tip span { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.col-tip b { margin-left: auto; color: var(--text); font-weight: 600; }
.col:hover .col-tip, .col:focus-visible .col-tip { opacity: 1; transform: translate(-50%, 0); }
.col:first-child .col-tip { left: 0; transform: translate(0, 4px); }
.col:first-child:hover .col-tip, .col:first-child:focus-visible .col-tip { transform: none; }
.col:last-child .col-tip { left: auto; right: 0; transform: translate(0, 4px); }
.col:last-child:hover .col-tip, .col:last-child:focus-visible .col-tip { transform: none; }

/* ------------------------------------------------------------ pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: transform 0.5s var(--spring), background 0.5s var(--spring), border-color 0.5s var(--spring);
}
.btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); border-color: #3a3f48; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #5ee0b0; color: var(--accent-ink); border-color: transparent; }
.btn-danger { border-color: #5a2a2a; color: var(--bad); }
.btn-danger:hover { background: rgba(252, 165, 165, 0.08); color: var(--bad); border-color: #7a3535; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* pulsante principale con freccia annidata */
.btn-arrow { padding-right: 6px; }
.btn-arrow .arrow {
  width: 34px; height: 34px; border-radius: 999px; background: rgba(4, 19, 13, 0.14);
  display: inline-flex; align-items: center; justify-content: center; transition: transform 0.5s var(--spring);
}
.btn-arrow:hover .arrow { transform: translate(2px, -1px) scale(1.05); }

/* ------------------------------------------------------------ moduli */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.form-grid .field { margin-bottom: 0; }
.field label, .label { font-weight: 500; font-size: 14px; }
.field label.required::after { content: ' *'; color: var(--bad); }
.help { color: var(--muted); font-size: 13px; }

.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
  font: inherit; transition: border-color 0.4s var(--spring), box-shadow 0.4s var(--spring);
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.input.code { font-family: var(--mono); font-size: 13px; min-height: 300px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.input:disabled { color: var(--muted); background: var(--tile); }
.input::placeholder { color: #6b7380; }
input[type='file'].input { padding: 8px; }
input[type='file'].input::file-selector-button {
  margin-right: 12px; min-height: 30px; padding: 0 14px; border: none; border-radius: 999px;
  background: var(--line); color: var(--text); font: inherit; cursor: pointer;
}
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters .input { width: auto; flex: 1 1 200px; }

/* ------------------------------------------------------------ tabelle */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; padding: 12px 16px; color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background 0.4s var(--spring); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table .right { text-align: right; }
.table td.mono { white-space: nowrap; }
.dim { color: var(--muted); }

/* ------------------------------------------------------------ etichette di stato */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; background: rgba(255, 255, 255, 0.06); color: var(--text); }
.tag.ok { background: rgba(110, 231, 183, 0.12); color: var(--ok); }
.tag.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.tag.bad { background: rgba(252, 165, 165, 0.12); color: var(--bad); }
.tag.info { background: rgba(125, 211, 252, 0.12); color: var(--info); }
.tag.off { color: var(--muted); }

/* ------------------------------------------------------------ messaggi */
.flash { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px; border-radius: var(--r-tile); background: var(--core); border: 1px solid var(--line-strong); }
.flash.success { border-color: rgba(110, 231, 183, 0.35); }
.flash.danger, .flash.error { border-color: rgba(252, 165, 165, 0.4); }
.flash.warning { border-color: rgba(251, 191, 36, 0.4); }
.flash button { border: none; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; min-width: 32px; min-height: 32px; border-radius: 999px; }
.flash button:hover { color: var(--text); background: var(--tile); }

/* ------------------------------------------------------------ gestione di un codice */
.code-card { border-radius: var(--r-tile); background: var(--tile); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.code-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.code-value { font-family: var(--mono); font-size: 16px; }
details.manage summary { cursor: pointer; color: var(--ok); font-weight: 500; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
details.manage summary::-webkit-details-marker { display: none; }
details.manage summary::before { content: '+'; font-family: var(--mono); }
details.manage[open] summary::before { content: '-'; }
.manage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.manage-row label { color: var(--muted); font-size: 14px; min-width: 92px; }
.manage-row .input { width: auto; min-height: 38px; padding: 6px 12px; flex: 0 1 150px; }

/* ------------------------------------------------------------ schede (impostazioni) */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--core); border: 1px solid var(--line); align-self: flex-start; }
.tabs button { min-height: 40px; padding: 0 18px; border: none; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.tabs button[aria-selected='true'] { background: var(--line); color: #ffffff; }
.tab-panel[hidden] { display: none; }

/* ------------------------------------------------------------ paginazione e pie' di pagina */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px; color: var(--muted); }
.pager .btn.is-off { opacity: 0.4; pointer-events: none; }
.footer { margin-top: auto; padding-top: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.site-footer { margin-top: auto; padding-top: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--text); }

/* ------------------------------------------------------------ accesso */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.login-logo { display: flex; justify-content: center; }
.login-logo img { max-height: 54px; max-width: 220px; }
.login-box h1 { font-size: 34px; font-weight: 300; letter-spacing: -0.03em; }
.login-back { text-align: center; }

/* ------------------------------------------------------------ movimento */
@media (prefers-reduced-motion: no-preference) {
  .rise { opacity: 0; transform: translateY(18px); animation: rise 0.9s var(--spring) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
  @keyframes rise { to { opacity: 1; transform: none; } }
}

@media (max-width: 720px) {
  .page { padding: 12px 12px 40px; gap: 20px; }
  .nav-wrap { position: static; }
  .nav-pill { border-radius: 26px; }
  .nav-sep { display: none; }
  .core { padding: 20px; }
  .stat-value { font-size: 44px; }
  .triple { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}

/* ------------------------------------------------------------ area cliente: righe delle sessioni */
.session-row { border-radius: var(--r-tile); background: var(--tile); padding: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.session-row[hidden] { display: none; }
.session-main { flex: 1 1 260px; min-width: 0; }
.session-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 17px; font-weight: 500; }
.session-title a { color: var(--text); overflow-wrap: anywhere; }
.session-title a:hover { color: var(--ok); }
.session-stats { display: flex; gap: 24px; }
.session-stats .num { font-size: 22px; font-weight: 300; font-variant-numeric: tabular-nums; }
.session-stats .lbl { color: var(--muted); font-size: 13px; }
.table input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.empty h2 { font-size: 20px; font-weight: 500; color: var(--text); }

/* lingua come link (pagine pubbliche) */
.lang .lang-link { min-width: 40px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 500; }
.lang .lang-link.active { background: var(--line); color: #ffffff; }

/* testo delle pagine pubbliche (privacy ecc.): HTML scritto dall'admin */
.prose { color: var(--muted); font-size: 16px; line-height: 1.7; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); font-weight: 500; letter-spacing: -0.01em; margin: 28px 0 10px; }
.prose h1:first-child, .prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose h2 { font-size: 24px; }
.prose h3 { font-size: 19px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 22px; }
.prose strong { color: var(--text); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 14px; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }

/* pagine pubbliche: il contenuto vive in un riquadro isolato, su fondo chiaro come e' stato scritto */
.page-frame { display: block; width: 100%; height: 70vh; min-height: 300px; border: 0; border-radius: var(--r-core); background: var(--core); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
