/* Server licenze VTH Virtuale: grafica comune di portale e pannello (tema chiaro e scuro automatico). */
:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f0f2f5; --line: #e2e5ea; --text: #16191f; --muted: #667085;
  --accent: #c8102e; --accent-ink: #fff; --focus: #2563eb;
  --ok: #157f3b; --ok-bg: #e7f6ec; --err: #b42318; --err-bg: #fdecea; --warn-bg: #fff4e5;
  --free: #475467; --free-bg: #eef1f5; --active: #157f3b; --active-bg: #e3f5e9; --revoked: #b42318; --revoked-bg: #fde8e7;
  --radius: 12px; --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1e222b; --line: #2a2f3a; --text: #e8eaee; --muted: #98a2b3;
    --accent: #e5484d; --focus: #60a5fa;
    --ok: #5bd187; --ok-bg: #12301f; --err: #ff8a80; --err-bg: #3a1614;
    --free: #c0c7d2; --free-bg: #262b35; --active: #5bd187; --active-bg: #143222; --revoked: #ff8a80; --revoked-bg: #3a1a19;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: inherit; }
code, pre, .mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; }
h1 { font-size: 22px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* struttura */
main { margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1180px; }
main.narrow { max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 0 0 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h1, .card-head h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* barra del pannello */
.bar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand span, .login h1 span { color: var(--accent); }
.bar nav { display: flex; gap: 4px; flex: 1; }
.bar nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.bar nav a:hover { background: var(--surface-2); color: var(--text); }
.bar nav a[aria-current] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); }

/* pulsanti e campi */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); }
.btn.link { border-color: transparent; background: none; padding-left: 4px; padding-right: 4px; color: var(--muted); }
.btn.link:hover { color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.done { color: var(--ok); }
input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input::placeholder { color: var(--muted); }
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
form.inline { display: inline; margin: 0; }
.stack { display: grid; gap: 14px; }

/* messaggi */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.empty { padding: 24px 0; text-align: center; }

/* riepilogo */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; }
.tile:hover { border-color: var(--muted); }
.tile.on { outline: 2px solid var(--accent); outline-offset: -1px; }
.tile .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.active .n { color: var(--active); }
.tile.revoked .n { color: var(--revoked); }

/* creazione */
details.create summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.create summary::-webkit-details-marker { display: none; }
details.create summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; }
details.create[open] summary::before { content: "−"; }
details.create summary h2 { margin: 0; }
.grid-form { display: grid; grid-template-columns: 2fr 2fr 110px auto; gap: 12px; align-items: end; margin-top: 16px; }
.new-keys { border-color: var(--ok); }
pre.codes { margin: 0; padding: 12px 14px; background: var(--surface-2); border-radius: 8px; font-size: 15px; line-height: 1.7; overflow-x: auto; }

/* elenco */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.search { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.count { margin: 4px 0 8px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.code { white-space: nowrap; }
td.code a { text-decoration: none; font-weight: 600; }
td.code a:hover { text-decoration: underline; }
.copy { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 15px; }
.copy:hover, .copy.done { color: var(--text); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form + form { margin-left: 4px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--free-bg); color: var(--free); }
.pill.active { background: var(--active-bg); color: var(--active); }
.pill.revoked { background: var(--revoked-bg); color: var(--revoked); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }

/* singolo codice */
.key-title { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 20px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; margin: 8px 0 16px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts dd.mono { font-size: 12px; }

/* registro */
.ev { font-weight: 600; }
.ev.attivato, .ev.riemesso, .ev.creato, .ev.accesso { color: var(--ok); }
.ev.rifiutato, .ev.revocato, .ev.accesso-negato { color: var(--err); }

/* pagine pubbliche: portale e accesso */
.hero { text-align: center; padding: 32px 0 20px; }
.steps { padding-left: 20px; margin: 0 0 20px; }
.steps li { margin-bottom: 6px; }
.drop { position: relative; display: grid; place-items: center; padding: 28px; border: 2px dashed var(--line); border-radius: var(--radius);
  font-weight: 600; cursor: pointer; text-align: center; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#out:empty { display: none; }
#out { margin: 16px 0 0; }
.login { max-width: 400px; margin: 10vh auto 0; padding: 28px; }
.login .btn { width: 100%; padding: 10px; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-form { grid-template-columns: 1fr; }
  .bar-in { flex-wrap: wrap; gap: 8px 16px; }
  .bar nav { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .who { display: none; }
  .search { max-width: none; }
}
