/* =====================================================================
   TenisRed · hoja de estilos
   Reproduce el sistema visual de la app original (neutros + acento verde)
   sin depender de ningún framework CSS.
   ===================================================================== */

:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --primary: #171717;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --accent: #f5f5f5;
  --ring: #0a0a0a;

  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --sidebar-bg: #fafafa;
  --sidebar-fg: #3f4451;

  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- Layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__logo {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.sidebar__name { font-weight: 700; font-size: 13px; line-height: 1.2; }
.sidebar__tag { font-size: 10px; color: var(--muted-foreground); }

.sidebar__nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px; }

.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  color: var(--sidebar-fg);
  transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: #f0f0f2; }
.navlink.is-active { background: #1b1d22; color: #fff; }
.navlink svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); }
.sidebar__user { font-size: 12px; color: var(--muted-foreground); margin-bottom: 8px; }
.sidebar__user strong { display: block; color: var(--foreground); font-size: 13px; }

.main { flex: 1; overflow: auto; background: var(--background); }
.page { padding: 24px; max-width: 1200px; margin: 0 auto; }
.page--narrow { max-width: 780px; }
.page--wide { max-width: 1400px; }

@media (min-width: 768px) { .page { padding: 40px; } }

.page__head { margin-bottom: 24px; }
.page__eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--emerald);
}
.page__title { font-size: 24px; margin-top: 4px; }
.page__title--xl { font-size: 30px; }
.page__sub { font-size: 13.5px; color: var(--muted-foreground); margin-top: 6px; max-width: 62ch; }

.head-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}

.section { margin-bottom: 32px; }
.section__title {
  font-size: 16px; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

/* Menú móvil */
.topbar {
  display: none;
  align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar:not(.is-open) .sidebar__nav,
  .sidebar:not(.is-open) .sidebar__foot { display: none; }
  .sidebar__nav { flex-direction: column; }
}

/* ---------------------------------------------------------------- Cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card--xl { border-radius: var(--radius-xl); padding: 20px; }
.card--flat { padding: 0; overflow: hidden; }
.card--dashed { border-style: dashed; text-align: center; padding: 40px 20px; color: var(--muted-foreground); }
.card--selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.card--link { transition: box-shadow .15s ease, transform .15s ease; display: block; }
.card--link:hover { box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid--map { grid-template-columns: 1fr 300px; }
.grid--tight { gap: 12px; }

@media (max-width: 1100px) {
  .grid--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--map { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .grid--2, .grid--3, .grid--4, .grid--6 { grid-template-columns: 1fr; }
}

/* KPI */
.kpi__icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__value { font-size: 24px; font-weight: 700; margin-top: 12px; }
.kpi__label { font-size: 11.5px; color: var(--muted-foreground); }

.is-green  { background: #ecfdf5; color: #047857; }
.is-blue   { background: #eff6ff; color: #1d4ed8; }
.is-amber  { background: #fffbeb; color: #b45309; }
.is-violet { background: #f5f3ff; color: #6d28d9; }
.is-teal   { background: #f0fdfa; color: #0f766e; }
.is-indigo { background: #eef2ff; color: #4338ca; }

/* --------------------------------------------------------------- Botones */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: opacity .15s ease, background .15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); color: var(--primary-foreground); }
.btn--primary:hover { opacity: .9; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn--ghost:hover { background: var(--accent); }
.btn--danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn--danger:hover { background: #fee2e2; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--lg { padding: 12px 20px; font-size: 14px; font-weight: 600; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row--split { justify-content: space-between; }

/* Tarjetas de acción del panel */
.action {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px; border-radius: var(--radius-xl);
}
.action--primary { background: var(--primary); color: var(--primary-foreground); }
.action--primary .action__sub { color: rgba(250,250,250,.8); }
.action--ghost { border: 1px solid var(--border); background: var(--card); }
.action--ghost:hover { background: var(--accent); }
.action__title { font-size: 16px; font-weight: 600; }
.action__sub { font-size: 13px; color: var(--muted-foreground); }
.action svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ------------------------------------------------------------ Distintivos */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge--green  { background: #d1fae5; color: #065f46; }
.badge--blue   { background: #dbeafe; color: #1e40af; }
.badge--amber  { background: #fef3c7; color: #92400e; }
.badge--clay   { background: #fef3c7; color: #92400e; }
.badge--slate  { background: #f1f5f9; color: #475569; }
.badge--violet { background: #ede9fe; color: #5b21b6; }
.badge--red    { background: #fee2e2; color: #991b1b; }
.badge--indigo { background: #e0e7ff; color: #3730a3; }
.badge--orange { background: #ffedd5; color: #9a3412; }
.badge--yellow { background: #fef9c3; color: #854d0e; }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ------------------------------------------------------------ Formularios */

.field { margin-bottom: 14px; }
.field__label {
  display: block; font-size: 12px; color: var(--muted-foreground); margin-bottom: 5px;
}
.field__hint { font-size: 11.5px; color: var(--muted-foreground); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--background);
  font-family: inherit; font-size: 13.5px; color: var(--foreground);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
}
.textarea { resize: vertical; min-height: 90px; }
.textarea--mono { font-family: var(--font-mono); font-size: 13px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* Selección tipo tarjeta (radio oculto) */
.choice { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice__box {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  transition: border-color .15s ease, background .15s ease;
  height: 100%;
}
.choice:hover .choice__box { background: var(--accent); }
.choice input:checked + .choice__box {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  background: #fafafa;
}
.choice input:focus-visible + .choice__box { outline: 2px solid var(--ring); outline-offset: 2px; }
.choice__title { font-weight: 500; font-size: 13.5px; }
.choice__meta { font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; }

/* ----------------------------------------------------------------- Avisos */

.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--ok    { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert--error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert--info  { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert--warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ----------------------------------------------------------------- Tablas */

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  background: #fafafa; text-align: left; padding: 12px;
  font-size: 11.5px; font-weight: 500; color: var(--muted-foreground);
  white-space: nowrap;
}
.table tbody td { padding: 12px; border-top: 1px solid var(--border); }
.table tbody tr:hover { background: #fcfcfc; }
.table .num { text-align: right; }
.table .mid { text-align: center; }
.table__empty { padding: 32px; text-align: center; color: var(--muted-foreground); }

/* Rejilla de disponibilidad */
.gridtable { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.gridtable th, .gridtable td { padding: 6px 4px; }
.gridtable thead tr { background: #fafafa; border-bottom: 1px solid var(--border); }
.gridtable th:first-child, .gridtable td:first-child {
  position: sticky; left: 0; background: var(--card); z-index: 1;
  text-align: left; min-width: 170px; font-weight: 500; white-space: nowrap;
}
.gridtable thead th:first-child { background: #fafafa; }
.gridtable tbody tr { border-bottom: 1px solid var(--border); }
.gridtable tbody tr:last-child { border-bottom: 0; }
.slot {
  height: 26px; min-width: 40px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 500;
}
.slot--free { background: #d1fae5; }
.slot--busy { background: #fecaca; color: #991b1b; }
.legend {
  display: flex; gap: 16px; padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted-foreground);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* -------------------------------------------------------------- Listados */

.stack { display: flex; flex-direction: column; gap: 12px; }

.row-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.row-card__title { font-weight: 600; font-size: 13.5px; }
.row-card__meta { font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; }
.row-card__side { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.row-card__price { font-weight: 600; }

.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.icon-inline { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------------------------------------------------------------- Mapa */

#mapa { height: 460px; width: 100%; border-radius: var(--radius-xl); }
.map-frame { border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; height: 460px; }
.map-fallback {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); font-size: 13px; padding: 24px; text-align: center;
}
.filters { display: flex; flex-direction: column; gap: 12px; }
.filters__title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted-foreground);
}
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ------------------------------------------------------------- Asistente */

.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.step { display: flex; align-items: center; gap: 8px; flex: 1; }
.step__dot {
  width: 24px; height: 24px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--secondary); color: var(--muted-foreground);
}
.step__label { font-size: 11.5px; font-weight: 500; color: var(--muted-foreground); }
.step.is-done .step__dot, .step.is-current .step__dot {
  background: var(--primary); color: var(--primary-foreground);
}
.step.is-done .step__label, .step.is-current .step__label { color: var(--foreground); }
.step__line { flex: 1; height: 1px; background: var(--border); }
.step.is-done .step__line { background: var(--primary); }
@media (max-width: 620px) { .step__label { display: none; } }

.scroll-list { max-height: 420px; overflow: auto; padding-right: 4px; }

.summary { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.summary__row { display: flex; justify-content: space-between; gap: 16px; }
.summary__row span:first-child { color: var(--muted-foreground); }
.summary__row span:last-child { font-weight: 500; text-align: right; }
.summary__total {
  display: flex; justify-content: space-between;
  padding-top: 10px; margin-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 16px; font-weight: 700;
}
.totals { background: var(--muted); border-radius: var(--radius-lg); padding: 14px; }

.done-mark {
  width: 56px; height: 56px; border-radius: 999px; margin: 0 auto;
  background: #d1fae5; color: #047857;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}

/* -------------------------------------------------------------- Torneos */

.bracket { display: flex; gap: 32px; min-width: max-content; padding: 4px; }
.bracket__round { display: flex; flex-direction: column; gap: 16px; justify-content: space-around; }
.bracket__label {
  font-size: 11.5px; font-weight: 600; color: var(--muted-foreground);
  text-align: center; margin-bottom: 4px;
}

.match {
  width: 190px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); padding: 8px; font-size: 12px;
}
.match__id { font-size: 10px; color: var(--muted-foreground); margin-bottom: 4px; }
.match__player {
  width: 100%; text-align: left; background: none; border: 0;
  padding: 4px 6px; border-radius: 4px; font: inherit; color: inherit;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.match__player:hover:not(:disabled) { background: var(--accent); }
.match__player:disabled { cursor: default; }
.match__player.is-winner { background: #d1fae5; color: #065f46; font-weight: 600; }
.match__player.is-empty { color: var(--muted-foreground); }
.match__score {
  margin-top: 6px; width: 100%; padding: 3px 6px;
  border: 1px solid var(--input); border-radius: 4px; font-size: 11px; font-family: inherit;
}
.match__result { margin-top: 6px; font-size: 10px; color: var(--muted-foreground); text-align: center; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin-bottom: 32px; }
.podium__step { border-radius: var(--radius-lg); border: 1px solid; text-align: center; padding: 16px 8px; }
.podium__step--1 { background: #fffbeb; border-color: #fde68a; padding-top: 24px; padding-bottom: 32px; }
.podium__step--2 { background: #f8fafc; border-color: #e2e8f0; padding-top: 20px; padding-bottom: 24px; }
.podium__step--3 { background: #fff7ed; border-color: #fed7aa; padding-top: 16px; padding-bottom: 20px; }
.podium__pos { font-weight: 700; margin-top: 8px; }
.podium__name { font-size: 13.5px; font-weight: 500; margin-top: 4px; }
.podium__icon { width: 28px; height: 28px; margin: 0 auto; }

.champion {
  display: inline-flex; align-items: center; gap: 8px;
  background: #ecfdf5; color: #065f46;
  padding: 10px 16px; border-radius: var(--radius-lg); font-weight: 600;
}

/* ------------------------------------------------------- Gráfico de barras */

.chart { display: flex; align-items: flex-end; gap: 12px; height: 260px; padding: 8px 4px 0; }
.chart__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.chart__bar {
  width: 100%; max-width: 56px; background: var(--emerald);
  border-radius: 4px 4px 0 0; min-height: 2px;
  transition: height .3s ease;
}
.chart__value { font-size: 11px; font-weight: 600; }
.chart__label {
  font-size: 10.5px; color: var(--muted-foreground);
  text-align: center; word-break: break-word; line-height: 1.2;
}

/* ------------------------------------------------------------ Autenticación */

.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: #fafafa;
}
.auth__card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 32px;
}
.auth__brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.auth__title { font-size: 20px; text-align: center; }
.auth__sub { font-size: 13px; color: var(--muted-foreground); text-align: center; margin-top: 6px; margin-bottom: 22px; }
.auth__foot { text-align: center; font-size: 13px; color: var(--muted-foreground); margin-top: 20px; }
.auth__foot a { font-weight: 500; color: var(--foreground); text-decoration: underline; }
.auth__demo {
  margin-top: 18px; padding: 12px; border-radius: var(--radius);
  background: var(--muted); font-size: 12px; color: var(--muted-foreground);
}

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