/* Tempi Gare — stili condivisi tra /storicoGare, /gara/:key e /atleta/:key */

.sg {
  --sg-primary: #0960b6;
  --sg-primary-dark: #074a8f;
  --sg-green: #28a745;
  --sg-ink: #1f2933;
  --sg-muted: #6b7280;
  --sg-line: #e3e8ee;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  color: var(--sg-ink);
}

.sg h1 { font-size: 1.6rem; margin: 0 0 4px; }
.sg .sg-sub { color: var(--sg-muted); font-size: .92rem; margin: 0 0 18px; }
.sg a { color: var(--sg-primary); text-decoration: none; }
.sg a:hover { text-decoration: underline; }

/* --- toolbar --- */
.sg-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: #fff; border: 1px solid var(--sg-line); border-radius: 12px;
  padding: 14px; margin-bottom: 14px;
}
.sg-search { flex: 1 1 260px; display: flex; gap: 8px; }
.sg-search input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--sg-line); border-radius: 8px;
  font-size: .95rem; background: #fff; min-width: 0;
}
.sg-search input:focus { outline: 2px solid var(--sg-primary); outline-offset: -1px; border-color: transparent; }
.sg-search button {
  border: 0; background: var(--sg-primary); color: #fff; font-weight: 600;
  padding: 0 16px; border-radius: 8px; cursor: pointer;
}
.sg-search button:hover { background: var(--sg-primary-dark); }

.sg-field { display: flex; flex-direction: column; gap: 4px; }
.sg-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--sg-muted); font-weight: 700;
}
.sg-field select {
  border: 1px solid var(--sg-line); border-radius: 8px; padding: 9px 10px;
  font-size: .9rem; background: #fff; min-width: 160px;
}
.sg-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sg-chip {
  border: 1px solid var(--sg-line); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: .85rem; color: var(--sg-ink); text-decoration: none;
}
.sg-chip:hover { text-decoration: none; border-color: var(--sg-primary); color: var(--sg-primary); }
.sg-chip[aria-current="true"] {
  background: var(--sg-primary); border-color: var(--sg-primary); color: #fff; font-weight: 600;
}
.sg-reset { align-self: center; color: var(--sg-muted); font-size: .85rem; text-decoration: underline; }

/* --- summary --- */
.sg-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; margin: 0 2px 10px; font-size: .9rem; color: var(--sg-muted);
}
.sg-summary strong { color: var(--sg-ink); }

/* --- table --- */
.sg-tablewrap {
  overflow-x: auto; border: 1px solid var(--sg-line); border-radius: 12px; background: #fff;
}
.sg-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 0; }
.sg-table thead th {
  position: sticky; top: 0; background: #f8fafc; text-align: left; z-index: 1;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--sg-muted); padding: 11px 12px; border-bottom: 1px solid var(--sg-line); white-space: nowrap;
}
.sg-table thead a { color: inherit; text-decoration: none; }
.sg-table thead a:hover { color: var(--sg-primary); }
.sg-table thead .sg-arrow { opacity: .4; margin-left: 4px; }
.sg-table thead th[aria-sort="ascending"] .sg-arrow,
.sg-table thead th[aria-sort="descending"] .sg-arrow { opacity: 1; color: var(--sg-primary); }
.sg-table tbody td { padding: 10px 12px; border-bottom: 1px solid #f0f3f7; vertical-align: middle; }
.sg-table tbody tr:last-child td { border-bottom: 0; }
.sg-table tbody tr:hover { background: #f8fbff; }
.sg-num { text-align: right; font-variant-numeric: tabular-nums; }
.sg-time { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sg-race small { display: block; color: var(--sg-muted); font-size: .78rem; }
.sg-dist {
  display: inline-block; background: #eef4fb; color: var(--sg-primary-dark);
  border-radius: 999px; padding: 2px 9px; font-size: .76rem; white-space: nowrap;
}
.sg-empty { padding: 40px 16px; text-align: center; color: var(--sg-muted); }

/* --- detail pages --- */
.sg-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: .9rem; }
.sg-card { background: #fff; border: 1px solid var(--sg-line); border-radius: 12px; overflow: hidden; }
.sg-head { padding: 18px 20px; border-bottom: 1px solid var(--sg-line); }
.sg-head h1 { margin: 0 0 6px; font-size: 1.3rem; }
.sg-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--sg-muted); font-size: .88rem; }
.sg-meta b { color: var(--sg-ink); font-weight: 600; }
.sg-meta span + span::before { content: '•'; margin-right: 14px; color: #cbd5e1; }

.sg-pbgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.sg-pb { padding: 14px; border: 1px solid var(--sg-line); border-radius: 12px; background: #fff; }
.sg-pb .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sg-muted); font-weight: 700; }
.sg-pb .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.sg-pb .w { font-size: .78rem; color: var(--sg-muted); }

.sg-pos { width: 44px; color: var(--sg-muted); font-variant-numeric: tabular-nums; }
.sg-pos.sg-p1, .sg-pos.sg-p2, .sg-pos.sg-p3 { font-weight: 800; color: var(--sg-ink); }
.sg-table tbody tr.sg-podium { background: #fbfdff; }

/* --- mobile --- */
@media (max-width: 560px) {
  .sg h1 { font-size: 1.35rem; }
  .sg-tablewrap { border: 0; background: transparent; overflow: visible; }
  .sg-table, .sg-table tbody, .sg-table tr, .sg-table td { display: block; width: 100%; }
  .sg-table thead { display: none; }
  .sg-table tbody tr {
    border: 1px solid var(--sg-line); border-radius: 12px; margin: 10px 0;
    padding: 10px 12px; background: #fff;
  }
  .sg-table tbody tr:hover { background: #fff; }
  .sg-table tbody td {
    border: 0; padding: 3px 0; display: flex; justify-content: space-between;
    gap: 12px; text-align: left !important;
  }
  .sg-table tbody td::before {
    content: attr(data-label); color: var(--sg-muted); font-size: .75rem;
    text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  }
  .sg-table tbody td:first-child { font-weight: 700; }
  .sg-race small { text-align: right; }
}
