/* SmartSkating — design system
   Scala spaziature: 8 / 16 / 24 / 32 / 40 / 48 / 64
   Palette: unica, neutra. Nessun gradiente, nessun glow.
   Font: due pesi soli (400 regolare, 600 semibold).
   Icone: linea, stroke 1.5, stessa libreria (Feather). */
:root {
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px; --s8: 64px;

  --bg: #14161a;
  --surface: #1b1e23;
  --surface-2: #22262c;
  --line: #333941;
  --line-strong: #454c56;
  --text: #e6e8ec;
  --text-dim: #9aa1ab;
  --text-faint: #6f7681;
  --focus: #8fa0b5;

  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  padding: var(--s3);
  max-width: 1200px;
  margin: 0 auto;
}

h1, h2, h3, b, strong { font-weight: 600; }
h1 { font-size: 20px; letter-spacing: .2px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: var(--s2);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--line);
  margin-bottom: var(--s3);
}
.brand { display: flex; align-items: center; gap: var(--s1); }
.brand .logo { width: 32px; height: 32px; border-radius: var(--radius-sm); display: block; }
.brand .name { font-weight: 600; font-size: 16px; letter-spacing: .2px; }
.site-header .meta { margin-left: auto; color: var(--text-dim); font-size: 13px; display: flex; gap: var(--s1); align-items: center; }

/* ---------- filtri ---------- */
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s2); margin-bottom: var(--s3);
}
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field label { font-size: 12px; color: var(--text-dim); }
select, input[type="text"], input[type="search"] {
  appearance: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px var(--s2); font: inherit; width: 100%;
}
select:hover, input:hover { border-color: var(--line-strong); }
select:disabled { color: var(--text-faint); }

/* ---------- elenco gare ---------- */
.event-block { margin-bottom: var(--s4); }
.event-title {
  display: flex; align-items: baseline; gap: var(--s1);
  margin-bottom: var(--s2); padding-bottom: var(--s1);
  border-bottom: 1px solid var(--line);
}
.event-title .date { color: var(--text-dim); font-size: 13px; }
.event-title .count { margin-left: auto; color: var(--text-faint); font-size: 12px; }

.comp {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s2);
  margin-bottom: var(--s1);
}
.comp-head { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.comp-head .cat { font-weight: 600; }
.tag {
  font-size: 12px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px var(--s1);
}
.phases { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s2); }
.phase {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 32px; padding: 0 var(--s2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13px; font-weight: 400;
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.phase:hover { border-color: var(--line-strong); }
.phase[disabled] { cursor: default; color: var(--text-faint); border-color: var(--line); }
.phase.ready { border-color: var(--line-strong); }
.phase .pstate { color: var(--text-faint); font-size: 11px; }
.phase.locked { color: var(--text-faint); }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 0; width: min(760px, 92vw); max-height: 88vh;
}
dialog::backdrop { background: rgba(10, 11, 13, .72); }
.dialog-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line);
}
.dialog-head h2 { flex: 1; }
.dialog-body { padding: var(--s3); overflow: auto; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  height: 32px; padding: 0 var(--s2); font: inherit; color: var(--text-dim); cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- gate / pagamento ---------- */
.gate { display: flex; flex-direction: column; gap: var(--s2); }
.gate p { color: var(--text-dim); font-size: 14px; }
.gate-row { display: flex; gap: var(--s1); flex-wrap: wrap; }
.gate-row input { flex: 1 1 220px; }
.btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  border-radius: var(--radius-sm); padding: 10px var(--s2);
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: var(--focus); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { border-color: var(--text); }
.btn[disabled] { opacity: .5; cursor: default; }

.divider { height: 1px; background: var(--line); margin: var(--s1) 0; }

/* ---------- risultati ---------- */
.results { width: 100%; border-collapse: collapse; font-size: 14px; }
.results th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--text-dim);
  border-bottom: 1px solid var(--line); padding: var(--s1);
}
.results td { padding: var(--s1); border-bottom: 1px solid var(--line); vertical-align: top; }
.results tr:last-child td { border-bottom: 0; }
.results .pos { width: 48px; color: var(--text-dim); }
.results .bib { width: 64px; color: var(--text-dim); }
.results tr.top td { color: var(--text); font-weight: 600; }
.results tr.top .pos { color: var(--text); }

.result-head { display: flex; align-items: center; gap: var(--s1); margin-bottom: var(--s2); flex-wrap: wrap; }
.grow { flex: 1; }
.note { color: var(--text-dim); font-size: 13px; }
.error { color: #d08a8a; font-size: 13px; min-height: 20px; }

/* ---------- stati ---------- */
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: var(--s4); text-align: center; color: var(--text-dim);
}
.empty svg { width: 24px; height: 24px; stroke: var(--text-faint); margin-bottom: var(--s1); }

.loading { color: var(--text-dim); font-size: 14px; padding: var(--s3) 0; }

@media (max-width: 720px) {
  body { padding: var(--s2); }
  .site-header { flex-wrap: wrap; }
  .site-header .meta { margin-left: 0; }
}

@media print {
  body { background: #fff; color: #000; padding: 0; }
  .site-header .meta, .filters, .btn, .btn-ghost { display: none; }
  .comp, dialog { border-color: #bbb; background: #fff; color: #000; }
  dialog { width: auto; max-height: none; }
  .results td, .results th { border-color: #bbb; }
}
