/* paldash — foglio di stile unico, nessuna dipendenza esterna.
   Tema scuro predefinito; il chiaro si attiva con data-theme="light" sulla
   radice (vedi theme.js). Ogni colore passa da una variabile, così i due temi
   restano allineati senza duplicare regole. */

:root,
:root[data-theme="dark"] {
  --bg: #0a0e15;
  --bg-top: #0d1420;
  --glow-1: rgba(63, 185, 80, .13);
  --glow-2: rgba(88, 166, 255, .14);
  --surface: #141b26;
  --surface-2: #10161f;
  --sheen: linear-gradient(160deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .012) 55%, rgba(255, 255, 255, 0));
  --glass: rgba(18, 25, 35, .72);
  --line: #263140;
  --fg: #e8eff7;
  --muted: #91a0b3;
  --accent: #3fb950;
  --accent2: #58a6ff;
  --on-accent: #06121a;
  --warn: #d29922;
  --danger: #f85149;
  --shadow: 0 18px 48px rgba(0, 0, 0, .5);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .35);
  --radius: 14px;
  --dock-h: 68px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg: #eef2f8;
  --bg-top: #f8fafc;
  --glow-1: rgba(26, 127, 55, .12);
  --glow-2: rgba(9, 105, 218, .13);
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --sheen: linear-gradient(160deg, rgba(255, 255, 255, .9), rgba(246, 249, 252, .55));
  --glass: rgba(255, 255, 255, .78);
  --line: #dae2ec;
  --fg: #17202c;
  --muted: #5b6878;
  --accent: #1a7f37;
  --accent2: #0969da;
  --on-accent: #ffffff;
  --warn: #9a6700;
  --danger: #cf222e;
  --shadow: 0 18px 44px rgba(20, 40, 70, .14);
  --shadow-sm: 0 6px 16px rgba(20, 40, 70, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 620px at 10% -12%, var(--glow-1), transparent 62%),
    radial-gradient(900px 520px at 102% -4%, var(--glow-2), transparent 58%),
    linear-gradient(180deg, var(--bg-top), var(--bg) 42%);
  background-attachment: fixed;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; color: var(--muted); word-break: break-all; }
h1 { font-size: 1.4rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; letter-spacing: -.005em; }
hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---- riga superiore: solo marchio e utente ---- */
.topline {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(12px) saturate(130%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--fg); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brandname {
  background: linear-gradient(120deg, var(--fg), color-mix(in srgb, var(--accent2) 70%, var(--fg)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: -.01em;
}
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px transparent; transition: box-shadow .3s, background .3s; }
.dot.good { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }

.avatar {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: var(--on-accent); font-weight: 700; font-size: .95rem;
  box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s;
}
.avatar:hover { text-decoration: none; transform: scale(1.06); }
.avatar.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent2); }
.avatar-card {
  position: absolute; top: calc(100% + .55rem); right: 0;
  display: flex; flex-direction: column; gap: .05rem;
  padding: .45rem .7rem; border-radius: 10px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.avatar:hover .avatar-card, .avatar:focus-visible .avatar-card { opacity: 1; transform: translateY(0); }
.avatar-name { color: var(--fg); font-size: .88rem; font-weight: 600; }
.avatar-role { color: var(--muted); font-size: .76rem; font-weight: 400; }

/* ---- barra flottante in basso ---- */
.dock {
  position: fixed; left: 50%; bottom: 1.1rem; transform: translateX(-50%);
  z-index: 40; display: flex; align-items: center; gap: .15rem;
  padding: .4rem .5rem; max-width: calc(100vw - 1.5rem); overflow-x: auto;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(150%);
  scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dockform { display: contents; }
.dockitem {
  position: relative; flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 14px; padding: 0;
  display: grid; place-items: center;
  background: none; border: none; color: var(--muted); cursor: pointer;
  transition: color .18s, background .18s;
}
.dockitem:hover, .dockitem:focus-visible { color: var(--fg); text-decoration: none; background: color-mix(in srgb, var(--fg) 8%, transparent); }
.dockitem:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.dockitem.on { color: var(--accent); }
.dockitem.on::after {
  content: ""; position: absolute; bottom: 5px; left: 50%; translate: -50% 0;
  width: 4px; height: 4px; border-radius: 50%; background: currentColor;
}
.dockitem.quit:hover { color: var(--danger); }
.ico {
  width: 23px; height: 23px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .22s cubic-bezier(.2, .8, .25, 1.35);
}
.dockitem:hover .ico, .dockitem:focus-visible .ico { transform: translateY(-5px) scale(1.32); }
.docklabel {
  position: absolute; bottom: calc(100% + .5rem); left: 50%; translate: -50% 0;
  padding: .25rem .6rem; border-radius: 9px; white-space: nowrap;
  font-size: .78rem; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(5px); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.dockitem:hover .docklabel, .dockitem:focus-visible .docklabel { opacity: 1; transform: translateY(0); }
.docksep { flex: 0 0 auto; width: 1px; height: 26px; margin: 0 .3rem; background: var(--line); }
:root[data-theme="dark"] .only-light { display: none; }
:root[data-theme="light"] .only-dark { display: none; }
@media (max-width: 560px) {
  .dockitem { width: 40px; height: 40px; }
  .ico { width: 21px; height: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .ico, .docklabel, .avatar, .avatar-card { transition: none; }
  .dockitem:hover .ico, .dockitem:focus-visible .ico { transform: none; }
}

/* ---- struttura ---- */
main {
  max-width: 1180px; margin: 0 auto;
  padding: 1.15rem 1rem calc(var(--dock-h) + 2rem);
  display: flex; flex-direction: column; gap: 1rem;
}
main.centered { min-height: 86vh; justify-content: center; align-items: center; padding-bottom: 1.15rem; }
.card {
  background: var(--sheen), var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 520px; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat.wide { grid-column: span 2; }
@media (max-width: 640px) { .stat.wide { grid-column: span 1; } }
.stat .k { color: var(--muted); font-size: .82rem; letter-spacing: .01em; }
.stat .v { font-size: 1.75rem; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.stat .v.small { font-size: 1.05rem; letter-spacing: 0; }
.stat .sub { color: var(--muted); font-size: .79rem; }
.stat .dim { color: var(--muted); font-size: 1rem; }
.good { color: var(--accent); }
.bad { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; color: var(--muted); }

.row { display: flex; align-items: center; gap: .5rem; }
.row.gap { gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field label { color: var(--muted); font-size: .85rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .88rem; }
.w5 { width: 5rem; } .w6 { width: 6rem; } .w12 { width: 12rem; }

/* ---- controlli ---- */
input, select, textarea {
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 9px; padding: .45rem .6rem; font: inherit; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent2); outline-offset: 1px; }
input[disabled] { opacity: .55; }
.row > input { flex: 1; }
button, .btn {
  background: var(--sheen), var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 9px; padding: .45rem .85rem; font: inherit; cursor: pointer;
  /* justify-content serve ai pulsanti a tutta larghezza (es. "Entra"):
     senza, il testo resterebbe appoggiato a sinistra. */
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: color-mix(in srgb, var(--fg) 30%, var(--line)); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: progress; }
button.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent2) 45%, var(--accent)));
  border-color: transparent; color: var(--on-accent); font-weight: 600;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent);
}
button.primary:hover { box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 38%, transparent); }
button.warn { border-color: var(--warn); color: var(--warn); }
button.danger { border-color: var(--danger); color: var(--danger); }
.switch { display: inline-block; }
.switch input { width: 2.6rem; height: 1.4rem; }

/* ---- tabelle ---- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: .82rem;
  padding: .45rem .5rem; border-bottom: 1px solid var(--line);
}
.table td { padding: .5rem .5rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); }
.table tr:last-child td { border-bottom: none; }
.table td.actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.table td.detail { max-width: 32rem; }

/* ---- avvisi ---- */
.alert { border-radius: var(--radius); padding: .7rem .9rem; border: 1px solid; font-size: .9rem; }
.alert.err { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.alert.ok { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.alert.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.opbanner {
  background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 22%, var(--surface)), color-mix(in srgb, var(--warn) 10%, var(--surface)));
  border-bottom: 1px solid var(--warn);
  padding: .55rem 1rem; font-size: .9rem; text-align: center;
}

/* ---- notifiche ---- */
.toasts {
  position: fixed; right: 1rem; bottom: calc(var(--dock-h) + 1.4rem);
  display: flex; flex-direction: column; gap: .5rem; z-index: 50; max-width: min(92vw, 26rem);
}
.toast {
  background: var(--glass); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: .6rem .85rem; font-size: .88rem; box-shadow: var(--shadow);
}
.toast.err { border-left-color: var(--danger); }

/* ---- accesso ---- */
.auth { width: min(400px, 92vw); display: flex; flex-direction: column; gap: .7rem; }
.auth h1 { margin: 0; }
.auth label { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .85rem; }
.auth input { font-size: 1rem; }
/* Il pulsante di accesso sborda: metà dentro la scheda e metà fuori. Il margine
   negativo vale il bordo inferiore (padding della scheda) più mezza altezza del
   pulsante; quello superiore lo stacca dal campo password. */
.auth .primary {
  align-self: center; width: min(100%, 15rem);
  margin-top: 1.1rem; margin-bottom: -2.6rem;
  padding: .6rem 1rem; font-size: 1rem;
  border-radius: 999px;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 36%, transparent);
}
main.centered { padding-bottom: 4rem; }

/* ---- grafici ---- */
.chart { margin: .8rem 0 0; }
.chart figcaption { color: var(--muted); font-size: .8rem; margin-bottom: .2rem; }
.chart svg { width: 100%; height: 160px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
#chart-online { height: 40px; }
.rangebar { display: flex; gap: .25rem; }
.rangebar button { padding: .25rem .55rem; font-size: .82rem; }
.rangebar button.on { border-color: var(--accent2); color: var(--accent2); }

/* ---- parametri ---- */
.group .fields { display: flex; flex-direction: column; gap: .1rem; }
.param { display: grid; grid-template-columns: 18rem 1fr; gap: 1rem; align-items: start;
  padding: .55rem .2rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.param:last-child { border-bottom: none; }
@media (max-width: 720px) { .param { grid-template-columns: 1fr; gap: .3rem; } }
.param label { display: flex; flex-direction: column; }
.plabel { font-size: .92rem; }
.pkey { font-size: .74rem; }
.param.locked { opacity: .75; }
.pinput p { margin: .25rem 0 0; }
.pinput input[type=number] { width: 9rem; }
.pinput input[type=text], .pinput input[type=password] { width: min(100%, 26rem); }
.stickybar {
  position: sticky; bottom: calc(var(--dock-h) + 1.2rem);
  background: var(--glass); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem 1rem; z-index: 10; box-shadow: var(--shadow);
}
.diff { margin-top: .6rem; max-height: 40vh; overflow: auto; font-family: var(--mono); font-size: .82rem; }
.diff div { padding: .12rem 0; border-bottom: 1px dashed var(--line); }
.diff .from { color: var(--danger); }
.diff .to { color: var(--accent); }

/* ---- wiki ---- */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a {
  padding: .35rem .8rem; border-radius: 999px; color: var(--muted);
  border: 1px solid transparent; font-size: .92rem;
}
.tabs a:hover { text-decoration: none; color: var(--fg); background: color-mix(in srgb, var(--fg) 6%, transparent); }
.tabs a.on { color: var(--fg); background: var(--sheen), var(--surface); border-color: var(--line); }
.filters { padding: .8rem; }
.filters input[type=search] { flex: 1 1 12rem; }

.palgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.palcard {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
  background: var(--sheen), var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg);
  transition: transform .15s, border-color .15s;
}
.palcard:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.palcard-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.palname { font-weight: 600; }
.palmeta { color: var(--muted); font-size: .76rem; }
.palstats { display: flex; gap: .5rem; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.palimg { border-radius: 12px; background: var(--surface-2); object-fit: contain; }
.palimg.none {
  display: grid; place-items: center; width: 48px; height: 48px;
  font-weight: 700; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.palimg.big { width: 96px; height: 96px; font-size: 2rem; border-radius: 16px; }
.palhead { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.palhead h1 { margin: 0; }
.palhead p { margin: .15rem 0 0; }

.pairlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .3rem; }
.pair { padding: .3rem .5rem; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.eggresult { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin-top: 1rem; }
.eggresult .parents { font-size: 1.05rem; }
.eggresult .arrow { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.eggresult .child { display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--fg); }
.eggresult .child:hover { text-decoration: none; }
.eggresult .child strong { font-size: 1.15rem; }
ul.tight { margin: .4rem 0 0; padding-left: 1.1rem; }

.teamrow { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: .9rem; }
.teamslot { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.teamslot a { color: var(--fg); display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.teamslot a:hover { text-decoration: none; }
.teamslot .palimg.big { width: 72px; height: 72px; }
.btn.small, button.small { padding: .2rem .5rem; font-size: .78rem; }
.table tr.off td { opacity: .55; }

/* ---- log ---- */
.logview {
  background: var(--surface-2); color: var(--fg); font-family: var(--mono);
  font-size: .8rem; line-height: 1.45;
  height: 68vh; overflow: auto; margin: .8rem 0 0; padding: .75rem;
  border-radius: 10px; border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word;
}
:root[data-theme="dark"] .logview { background: #05080d; color: #cfd8e3; }
.secret { user-select: all; background: var(--surface-2); padding: .2rem .4rem; border-radius: 6px; color: var(--fg); }
