/* Volley Coach PWA — M1 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --border: #d1d5db;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --focus: #f59e0b;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: .5rem 1rem;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}
.skip-link:focus { left: 1rem; top: 1rem; }

header.app {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.app h1 {
  font-size: 1.1rem;
  margin: 0;
}

nav[aria-label="principale"] ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
}

nav a, nav button {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .5rem .75rem;
  border: 1px solid transparent;
  border-radius: .375rem;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  cursor: pointer;
}

nav a:hover, nav a:focus, nav button:hover, nav button:focus {
  background: #eff6ff;
  border-color: var(--primary);
  outline: none;
}

nav a[aria-current="page"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

main {
  max-width: 70rem;
  margin: 1rem auto;
  padding: 0 1rem;
}

section.page { display: none; }
section.page.active { display: block; }

h2 { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .9rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-size: .9rem;
}

button:focus, .btn:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button.primary, .btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: .5rem 0 1rem;
}

caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: .5rem;
}

th, td {
  border: 1px solid var(--border);
  padding: .5rem .6rem;
  text-align: left;
}

th { background: #f3f4f6; font-weight: 600; }

tr:nth-child(even) { background: #f9fafb; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: .25rem;
  font-size: .8rem;
  font-weight: 600;
}
.badge.green { background: #dcfce7; color: var(--success); }
.badge.orange { background: #ffedd5; color: var(--warning); }
.badge.red { background: #fee2e2; color: var(--danger); }
.badge.blue { background: #dbeafe; color: var(--primary-dark); }

.heatmap {
  display: grid;
  grid-template-columns: repeat(3, minmax(5rem, 1fr));
  gap: .5rem;
  max-width: 24rem;
}

.zone {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: .375rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .5rem;
  text-align: center;
}

.zone .label { font-size: .75rem; color: var(--muted); }
.zone .value { font-size: 1.25rem; font-weight: 700; }
.zone .detail { font-size: .7rem; color: var(--muted); }

.zone.low { background: #eff6ff; }
.zone.mid { background: #bfdbfe; }
.zone.high { background: #60a5fa; color: #fff; }
.zone.very-high { background: #1d4ed8; color: #fff; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.report-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--text);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}

.history-chart {
  display: flex;
  align-items: flex-end;
  gap: .4rem;
  height: 10rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
}

.bar {
  width: 100%;
  min-height: .25rem;
  background: var(--primary);
  border-radius: .25rem .25rem 0 0;
}

.bar-label {
  font-size: .7rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

kbd { font-family: inherit; background: #f3f4f6; padding: .1rem .3rem; border-radius: .2rem; border: 1px solid var(--border); }

@media print {
  header.app, .actions, .skip-link { display: none !important; }
  main { max-width: none; margin: 0; }
  section.page { display: block !important; }
  .page:not(.active) { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; border: 1px solid #999; }
}

@media (max-width: 640px) {
  header.app { flex-direction: column; align-items: flex-start; }
  nav[aria-label="principale"] ul { gap: .15rem; }
  nav a, nav button { padding: .4rem .5rem; font-size: .8rem; }
  .heatmap { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Entry (M1 rally capture) */
.entry-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.entry-status {
  font-size: .9rem;
  color: var(--muted);
  padding: .5rem 0;
}

.entry-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1rem;
}

.entry-step h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.entry-hint {
  color: var(--muted);
}

.entry-form {
  display: grid;
  gap: .75rem;
  max-width: 24rem;
}

.entry-form label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-weight: 500;
}

.entry-form select,
.entry-form input {
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  font-size: 1rem;
  background: #fff;
  min-height: 2.75rem;
}

.entry-form button {
  min-height: 2.75rem;
  min-width: 2.75rem;
}

.entry-form select:focus,
.entry-form input:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.entry-grid {
  display: grid;
  gap: .75rem;
  margin: 1rem 0;
}

.entry-grid.three {
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}

.big-btn {
  min-height: 4rem;
  font-size: 1.15rem;
  font-weight: 600;
  justify-content: center;
  border-radius: .5rem;
  border-width: 2px;
}

.big-btn.success {
  background: #dcfce7;
  border-color: var(--success);
  color: var(--success);
}

.big-btn.danger {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

.big-btn.primary {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.entry-undo-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.entry-undo-row button {
  font-size: .85rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
}

.error-banner {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: .75rem 1rem;
  border-radius: .375rem;
}

.diff-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.diff-list li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}

.sr-only {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 640px) {
  .entry-grid.three {
    grid-template-columns: 1fr;
  }
  .big-btn {
    min-height: 3.5rem;
  }
}
