* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Inter', system-ui, sans-serif; background: #fff; color: #1a1a1a; -webkit-font-smoothing: antialiased; }
a { color: #0d5e3c; text-decoration: none; }
a:hover { color: #169856; }
:root {
  --green-dark: #0d5e3c;
  --green-base: #169856;
  --green-mid: #1fae65;
  --green-light: #d4f5e8;
  --green-pale: #f0faf7;
  --accent-orange: #ff6b35;
  --accent-red: #e63946;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-tertiary: #999;
  --border-light: #e8e8e8;
  --border-med: #d8d8d8;
  --bg-gray: #f6f7f6;
  --bg-white: #fff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.07);
}
.viewport { width: 100%; min-height: 100vh; position: relative; background: var(--bg-white); }
.page { width: 100%; min-height: 100vh; display: none; }
.page.active { display: flex; flex-direction: column; }

/* turf placeholder */
.turf-photo { position: relative; overflow: hidden; background: #14814f; }
.turf-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.turf-label { position: absolute; bottom: 16px; right: 16px; font: 500 11px 'Geist Mono', monospace; color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.25); padding: 6px 10px; border-radius: 6px; letter-spacing: 0.02em; z-index: 3; }

/* topnav (marketing) */
.marketing-nav { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 48px; flex-shrink: 0; border-bottom: 1px solid var(--border-light); }
.logo { font: 800 20px Inter; color: var(--green-dark); letter-spacing: -0.02em; }
.marketing-nav-actions { display: flex; gap: 12px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px Inter; padding: 12px 20px; border-radius: 8px; border: none; cursor: pointer; transition: all 0.15s; min-height: 44px; white-space: nowrap; }
.btn-primary { background: var(--green-base); color: white; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--bg-gray); color: var(--text-primary); }
.btn-secondary:hover { background: #ececec; }
.btn-outline { background: transparent; border: 1.5px solid var(--border-med); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--green-base); color: var(--green-base); }
.btn-danger-outline { background: transparent; border: 1.5px solid #f3c9cd; color: var(--accent-red); }
.btn-danger-outline:hover { background: #fff2f3; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 34px; }
.btn-link { background: none; border: none; color: var(--green-base); font: 600 13px Inter; cursor: pointer; }

/* form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { display: block; font: 600 13px Inter; color: var(--text-primary); margin-bottom: 6px; }
.form-hint { font: 400 12px Inter; color: var(--text-tertiary); margin-top: 5px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border-light); border-radius: 8px; font: 14px Inter; color: var(--text-primary); background: var(--bg-white); transition: border-color 0.15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--green-base); }
.checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--green-base); }

/* app shell */
.app-shell { display: flex; width: 100%; height: 100vh; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.sidebar { width: 232px; background: var(--bg-white); border-right: 1px solid var(--border-light); display: flex; flex-direction: column; padding: 20px 14px; flex-shrink: 0; overflow-y: auto; }
.sidebar-logo { font: 800 19px Inter; color: var(--green-dark); padding: 6px 10px 22px; letter-spacing: -0.02em; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px; font: 500 14px Inter; color: var(--text-secondary); cursor: pointer; margin-bottom: 2px; position: relative; }
.nav-item:hover { background: var(--bg-gray); }
.nav-item.active { background: var(--green-pale); color: var(--green-dark); font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-dot { width: 7px; height: 7px; background: var(--accent-red); border-radius: 50%; margin-left: auto; }
.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border-light); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green-light); color: var(--green-dark); display: flex; align-items: center; justify-content: center; font: 700 13px Inter; flex-shrink: 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 68px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; flex-shrink: 0; }
.topbar-title { font: 700 19px Inter; color: var(--text-primary); }
.topbar-sub { font: 400 13px Inter; color: var(--text-secondary); margin-top: 2px; }
.main-content { flex: 1; overflow-y: auto; padding: 28px 32px; background: var(--bg-gray); }

/* table */
.table-card { background: var(--bg-white); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font: 600 11px Inter; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; padding: 13px 20px; border-bottom: 1px solid var(--border-light); }
.table td { padding: 15px 20px; border-bottom: 1px solid var(--border-light); font: 14px Inter; color: var(--text-primary); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable:hover { background: var(--green-pale); cursor: pointer; }
.cell-sub { font: 12px Inter; color: var(--text-secondary); margin-top: 2px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 6px; font: 600 11.5px Inter; white-space: nowrap; }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-orange { background: #ffe8d0; color: #b25f1f; }
.badge-red { background: #ffe1e3; color: var(--accent-red); }
.badge-gray { background: var(--bg-gray); color: var(--text-secondary); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* cards */
.panel { background: var(--bg-white); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 24px; }
.panel-title { font: 700 15px Inter; color: var(--text-primary); margin-bottom: 16px; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-secondary); }
.info-row .v { color: var(--text-primary); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-light); margin-bottom: 16px; }
.tab { padding: 10px 4px; margin-right: 22px; font: 600 13.5px Inter; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--green-base); border-bottom-color: var(--green-base); }

.list-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.list-row:last-child { border-bottom: none; }
.list-name { font: 600 13.5px Inter; color: var(--text-primary); }
.list-sub { font: 12px Inter; color: var(--text-secondary); margin-top: 2px; }

.chip { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 20px; background: var(--bg-gray); font: 500 12.5px Inter; color: var(--text-primary); border: 1px solid var(--border-light); cursor: pointer; transition: all 0.15s; }
.chip:hover { border-color: var(--green-base); }
.chip.on { background: var(--green-dark); color: #fff; border-color: var(--green-dark); font-weight: 600; }

/* photo upload: perfil / grupo (circular), cancha (rectangular cover) */
.photo-slot { display: block; position: relative; overflow: hidden; background: var(--bg-white); flex-shrink: 0; }
.photo-slot.circle { border-radius: 50%; }
.photo-slot.rect { border-radius: 10px; }
.photo-slot .empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1.5px dashed var(--border-med); border-radius: inherit; color: var(--text-tertiary); background: var(--bg-white); transition: border-color .12s, background .12s; }
.photo-slot .empty-state svg { opacity: .5; }
.photo-slot .empty-state .cap { font: 500 12px Inter; text-align: center; padding: 0 6px; }
.photo-slot:not(.read-only):hover .empty-state { border-color: var(--green-base); background: var(--green-pale); }
/* los circulos son demasiado chicos para el texto del caption sin que se
   corte contra el borde redondeado -- solo el icono adentro, el caption
   queda como title/tooltip del label. El rect (portada de cancha) tiene
   espacio de sobra y conserva el texto. */
.photo-slot.circle .empty-state .cap { display: none; }
.photo-slot.circle .empty-state svg { width: 40%; height: 40%; }
/* la foto siempre llena el circulo/rectangulo (recorta si la relacion de
   aspecto no coincide, nunca la deja mas chica con bandas alrededor) y
   se puede click-ear para verla grande */
.photo-slot img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; cursor: zoom-in; }
/* label invisible que cubre todo el slot vacio -- clickear en cualquier
   parte abre el selector de archivo */
.empty-state-overlay { position: absolute; inset: 0; cursor: pointer; }
.photo-slot.circle .edit-badge { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--green-base); border: 2px solid #fff; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; cursor: pointer; }
.photo-slot.rect .edit-badge { position: absolute; right: 10px; bottom: 10px; padding: 6px 12px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font: 500 12px Inter; backdrop-filter: blur(4px); cursor: pointer; }
.photo-slot--profile { width: 72px; height: 72px; }
.photo-slot--sidebar { width: 34px; height: 34px; }
.photo-slot--group-card { width: 40px; height: 40px; }
.photo-slot--cancha-cover { width: 100%; height: 180px; }
.photo-slot.read-only .empty-state { border-style: solid; cursor: default; }

/* lightbox: ver foto en grande, cruz para cerrar */
.foto-lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 1000; align-items: center; justify-content: center; }
.foto-lightbox.open { display: flex; }
.foto-lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.foto-lightbox-close { position: absolute; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.foto-lightbox-close:hover { background: rgba(255,255,255,.28); }

/* mapa de cancha: dropdown de sugerencias de direccion (Nominatim) */
.mapa-sugerencias { display: none; position: absolute; z-index: 1100; background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 8px; box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; }
.mapa-sugerencias.open { display: block; }
.mapa-sugerencia-item { padding: 10px 14px; font: 400 13.5px Inter; color: var(--text-primary); cursor: pointer; border-bottom: 1px solid var(--border-light); }
.mapa-sugerencia-item:last-child { border-bottom: none; }
.mapa-sugerencia-item:hover { background: var(--green-pale); color: var(--green-dark); }
/* pin arrastrable del mapa de cancha: cursor de mano para que se note que se puede mover */
.leaflet-marker-draggable { cursor: grab !important; }
.leaflet-marker-draggable:active { cursor: grabbing !important; }

.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.stat-box { background: var(--bg-white); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 20px; text-align: center; }
.stat-num { font: 700 28px Inter; color: var(--green-dark); }
.stat-label { font: 500 12px Inter; color: var(--text-secondary); margin-top: 4px; }

/* responsive utility grids */
.grid-2-340 { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.grid-2-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2-340-right { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.grid-2-300 { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* hero splits (home/login/register) */
.split-hero { flex: 1; display: flex; }
.split-auth { display: flex; height: 100%; }
.split-image { position: relative; }

/* alert banner (partido detail) */
.alert-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; font: 600 13.5px Inter; margin-bottom: 10px; }
.alert-banner.warn { background: #ffe8d0; color: #8a4a12; }
.alert-banner.danger { background: #ffe1e3; color: #a01f28; }

.otp-input { width: 52px; padding: 12px 0; }

@media (max-width: 900px) {
  .grid-2-340, .grid-2-equal, .grid-2-340-right, .grid-2-300 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; border-right: none; border-top: 1px solid var(--border-light); position: fixed; bottom: 0; left: 0; padding: 6px 4px; box-shadow: 0 -2px 10px rgba(0,0,0,0.06); z-index: 20; order: 2; }
  .sidebar-logo, .sidebar-footer { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 2px; margin-bottom: 0; text-align: center; justify-content: center; }
  .nav-icon { font-size: 18px; width: auto; }
  .nav-dot { position: absolute; top: 2px; right: 22%; margin-left: 0; }
  .main { order: 1; padding-bottom: 60px; }
  .topbar { padding: 0 16px; height: 56px; flex-wrap: wrap; }
  .topbar-title { font-size: 16px; }
  .main-content { padding: 16px; }
  .split-auth, .split-hero { flex-direction: column; }
  .split-image { width: 100% !important; height: 160px !important; flex: none !important; }
  .table { min-width: 620px; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .otp-input { width: 42px !important; padding: 10px 0 !important; }
  .marketing-nav { padding: 0 20px; }
  .marketing-nav-actions .btn { padding: 10px 14px; font-size: 13px; }
}