﻿:root {
  --bg: #f2f3f5;
  --card: rgba(255,255,255,0.92);
  --card-strong: #ffffff;
  --text: #0f2112;
  --muted: #4a6358;
  --border: rgba(15,33,18,0.12);
  --line: rgba(15,33,18,0.08);
  --accent: #16a34a;
  --accent-rgb: 22, 163, 74;
  --accent-2: #0ea5e9;
  --success: #15803d;
  --danger: #dc2626;
  --header-bg-start: #14532d;
  --header-bg-end: #16a34a;
  --header-text: #ffffff;
  --brand-logo-size: 48px;
  --header-title-size: 22px;
  --btn-primary-bg-start: #16a34a;
  --btn-primary-bg-end: #22c55e;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg-start: #14532d;
  --btn-secondary-bg-end: #16a34a;
  --btn-secondary-text: #ffffff;
  --shadow: 0 4px 24px rgba(15,33,18,0.10);
  --shadow-card: 0 2px 12px rgba(15,33,18,0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --bottom-nav-h: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: #f2f3f5;
  padding-bottom: var(--bottom-nav-h);
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: 300;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" -25, "opsz" 24;
}

/* ── Header ─────────────────────────────────────── */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--header-bg-start) 0%, var(--header-bg-end) 100%);
  color: var(--header-text);
  box-shadow: 0 2px 20px rgba(20,83,45,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: var(--brand-logo-size);
  height: var(--brand-logo-size);
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.24);
  flex: 0 0 auto;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}
.brand-mark .material-symbols-outlined { font-size: 24px; }

/* Mobile: hide all text in header, show only on tablet+ */
.brand-copy { display: none; }

.brand-kicker, .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
  font-weight: 800;
}

.brand-copy strong {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  font-size: var(--header-title-size);
  line-height: 1.1;
  white-space: nowrap;
}

.brand-copy strong, .brand-copy span, .brand-copy p { margin: 0; }

.topbar-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.76);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.16);
}

/* Mobile: profile chip icon only */
.profile-copy { display: none; }
.profile-chip { padding: 7px; border-radius: 12px; }

.topbar-source-link .btn-label-full,
#backPortalBtn .btn-label-full,
.toolbar-actions .btn-label-full,
#teamViewBack .btn-label-full { display: none; }

/* Mobile: compact icon-only buttons */
.topbar-actions .btn {
  padding: 8px;
  min-height: 38px;
  min-width: 38px;
  border-radius: 12px;
}

.topbar-actions .btn .material-symbols-outlined { font-size: 20px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  min-height: 44px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.65; cursor: progress; transform: none; }
.btn:active { transform: translateY(0); }

.btn-primary {
  color: var(--btn-primary-text);
  background: linear-gradient(135deg, var(--btn-primary-bg-start), var(--btn-primary-bg-end));
  box-shadow: 0 8px 20px rgba(var(--accent-rgb),0.28);
}

.btn-secondary {
  color: var(--btn-secondary-text);
  background: linear-gradient(135deg, var(--btn-secondary-bg-start), var(--btn-secondary-bg-end));
  box-shadow: 0 8px 20px rgba(20,83,45,0.22);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--border);
}

.btn-ghost.disabled { pointer-events: none; opacity: 0.5; }
.btn-danger { color: #fff; background: linear-gradient(135deg, #dc2626, #ef4444); }

.is-busy .material-symbols-outlined {
  animation: spin 0.9s linear infinite;
}
.bg-syncing { opacity: 0.65; }
.bg-syncing .material-symbols-outlined { animation: spin 1.4s linear infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Source toolbar ─────────────────────────────── */
.source-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  max-width: 1480px;
  margin: 0 auto;
}

.source-picker {
  flex: 1;
  min-width: 0;
  position: relative;
}

.source-picker::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
  pointer-events: none;
}

.source-select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.08);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),0.16);
  cursor: pointer;
  appearance: none;
  outline: none;
}

.source-select:focus {
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),0.3), 0 0 0 3px rgba(var(--accent-rgb),0.12);
}

.toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.toolbar-btn { padding: 10px; border-radius: 999px; min-height: 42px; min-width: 42px; }

/* ── Alert ─────────────────────────────────────── */
.alert {
  margin: 0 14px 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  border: 1px solid transparent;
}

.alert-success {
  color: var(--success);
  background: rgba(240,253,244,0.96);
  border-color: rgba(var(--accent-rgb),0.24);
}

.alert-error {
  color: var(--danger);
  background: rgba(254,242,242,0.96);
  border-color: rgba(220,38,38,0.24);
}

/* ── Panel ─────────────────────────────────────── */
.panel, .info-panel {
  margin: 0 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.info-panel { padding: 20px; text-align: center; color: var(--muted); }
.error-panel { color: var(--danger); border-color: rgba(220,38,38,0.3); background: rgba(254,242,242,0.95); }

/* ── Login ─────────────────────────────────────── */
.login-shell {
  display: grid;
  place-items: center;
  padding: 32px 14px 80px;
  min-height: 80vh;
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.login-heading { display: grid; gap: 8px; }
.login-heading h1, .section-head h2 {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  margin: 0;
}

.login-heading h1 { font-size: clamp(26px, 6vw, 38px); line-height: 1; }
.login-heading p, .section-copy { color: var(--muted); margin: 0; font-size: 14px; }

/* ── App content ────────────────────────────────── */
.app-content {
  max-width: 1480px;
  margin: 0 auto;
  padding-bottom: 20px;
}

/* ── Hero stats ─────────────────────────────────── */
.hero {
  padding: 14px;
  background: rgba(255,255,255,0.98);
}

/* Always a single scrollable row on every device */
.hero-stats {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 8px;
}

.hero-stats::-webkit-scrollbar { display: none; }

.stat-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 4px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.94);
  display: grid;
  gap: 4px;
  align-content: center;
  justify-items: center;
  text-align: center;
  overflow: hidden;
}

.stat-card-sync,
.countdown-stat-card { display: grid; }

.stat-label {
  display: block;
  font-size: clamp(7px, 0.85vw, 10px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  display: block;
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  font-size: clamp(13px, 1.55vw, 22px);
  line-height: 1.05;
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value-small { font-size: inherit; }

.countdown-stat-card { gap: 4px; }
#countdownValue {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  font-size: clamp(13px, 1.55vw, 22px);
  line-height: 1.05;
  white-space: nowrap;
}

/* ── View tabs (bottom nav mobile) ────────────── */
.view-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  height: var(--bottom-nav-h);
}

.view-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
  min-height: 0;
}

.view-tab-btn .material-symbols-outlined { font-size: 24px; }

.view-tab-btn.active {
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.06);
}

.view-tab-btn span:not(.material-symbols-outlined) {
  display: block;
  line-height: 1;
}

/* ── Eyebrow ──────────────────────────────────── */
.eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.1);
  font-size: 10px;
  margin-bottom: 4px;
}

/* ── Section head ─────────────────────────────── */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-head-wide { align-items: center; }
.section-head h2 { font-size: clamp(20px, 4vw, 28px); }
.section-actions { display: flex; gap: 8px; align-items: center; }

/* ── Standings ─────────────────────────────────── */
.standings-panel, .matches-panel { padding: 16px; }

.category-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%230f2112' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat calc(100% - 8px) 50% / 14px,
    rgba(255,255,255,0.96);
  appearance: none;
  cursor: pointer;
  outline: none;
  min-width: 0;
}

.category-select:focus {
  border-color: rgba(var(--accent-rgb),0.4);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.1);
}

.standings-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Compact standings table — all columns always visible ─── */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.standings-table th,
.standings-table td {
  padding: 7px 2px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
}

.standings-table th {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  padding: 6px 2px;
}

.standings-table tbody tr:hover { background: rgba(var(--accent-rgb),0.04); }
.standings-table tbody tr:active { background: rgba(var(--accent-rgb),0.08); }

/* Column widths — fixed so everything fits on a 375px screen */
.standings-table .col-pos  { width: 28px; font-weight: 800; font-size: 12px; }
.standings-table .col-team { text-align: left; padding-left: 4px; }
.standings-table .col-num  { width: 24px; }
.standings-table .col-pts  { width: 28px; font-weight: 800; font-size: 12.5px; }
.standings-table .col-neg  { color: var(--danger); font-weight: 700; }
.standings-table .col-dg-pos { color: var(--success); font-weight: 600; }

/* Compact team cell */
.team-cell-compact {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.team-logo-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(15,33,18,0.1);
  flex-shrink: 0;
}

.team-logo-sm-fallback {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.team-name-compact {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  min-width: 0;
  max-width: 100%;
  display: block;
}

.team-name-compact:hover { color: var(--accent); text-decoration: underline; }

.standings-footer {
  margin-top: 10px;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  font-style: italic;
}

@media (min-width: 640px) {
  .standings-table th,
  .standings-table td { font-size: 13px; padding: 10px 6px; }
  .standings-table th { font-size: 10px; }
  .standings-table .col-pos  { width: 32px; font-size: 14px; }
  .standings-table .col-num  { width: 32px; }
  .standings-table .col-pts  { width: 36px; font-size: 14px; }
  .team-logo-sm, .team-logo-sm-fallback { width: 32px; height: 32px; }
  .team-name-compact { font-size: 13px; }
}

.team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.team-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--team-color);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--team-color) 18%, transparent);
}

.team-logo {
  width: 36px;
  height: 36px;
  padding: 3px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.team-logo-fallback {
  display: grid;
  place-items: center;
  font-family: "Sora", sans-serif;
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 700;
}

.team-copy { display: grid; gap: 2px; min-width: 0; }
.team-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.team-copy span { font-size: 11px; color: var(--muted); }

/* ── Matches ────────────────────────────────────── */
.matches-content { display: grid; gap: 12px; }

.date-accordion {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.88);
  overflow: hidden;
}

.date-accordion-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.date-accordion-head::-webkit-details-marker { display: none; }

.date-accordion-icon { transition: transform 200ms ease; color: var(--accent); }
details[open] .date-accordion-icon { transform: rotate(0deg); }
details:not([open]) .date-accordion-icon { transform: rotate(-90deg); }

.date-match-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(15,33,18,0.06);
  padding: 3px 8px;
  border-radius: 999px;
}

.date-accordion-body { display: grid; gap: 8px; padding: 0 10px 10px; }

/* ── Match card ─────────────────────────────────── */
.match-card { padding: 8px 0; }

/* Result color on the analyzed team's button — fixed, do not use theme variables */
.match-team-btn.result-win  { background: rgba(22,163,74,0.11);  border-color: rgba(22,163,74,0.32); }
.match-team-btn.result-loss { background: rgba(220,38,38,0.09);  border-color: rgba(220,38,38,0.30); }
.match-team-btn.result-draw { background: rgba(202,138,4,0.10);  border-color: rgba(202,138,4,0.35); }

/* All-categories result row coloring — fixed */
.cat-row-win  { background: rgba(22,163,74,0.10)  !important; border-radius: 10px; }
.cat-row-loss { background: rgba(220,38,38,0.08)  !important; border-radius: 10px; }
.cat-row-draw { background: rgba(202,138,4,0.09)  !important; border-radius: 10px; }

.match-row-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.match-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  width: 100%;
  text-align: center;
}

.match-team-home { align-items: center; }
.match-team-away { align-items: center; }

.match-team-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
  text-align: center;
  max-width: 100%;
}

.match-team-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(15,33,18,0.08);
  padding: 10px 6px;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.match-team-btn-home { justify-content: center; }
.match-team-btn-away { justify-content: center; }

.match-team-btn:hover {
  background: #f2f3f5;
  border-color: rgba(15,33,18,0.14);
  transform: translateY(-1px);
}

.match-team-highlight {
  background: #f2f3f5;
  border-color: rgba(15,33,18,0.16);
}

.match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 90px;
  padding: 4px 6px;
  text-align: center;
}

.match-score {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.match-score-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  transition: transform 130ms ease, opacity 130ms ease;
}

.match-score-btn:hover { opacity: 0.75; transform: translateY(-1px); }
.match-score-sep { margin: 0 2px; color: var(--muted); }
.match-score-pending { font-size: 14px; color: var(--muted); }

.match-status {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: 999px;
}

.match-status-done { background: rgba(15,33,18,0.06); color: var(--muted); }
.match-status-live { background: rgba(220,38,38,0.1); color: var(--danger); }
.match-status-pending { background: rgba(15,33,18,0.06); color: var(--muted); }

.match-kickoff, .match-round { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* ── Team view ──────────────────────────────────── */
.team-view { display: grid; gap: 0; }
.team-view-header { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.team-view-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.team-view-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; justify-content: space-between; }
/* Categoria en section-head de Resultados */
.team-view-cat-badge { font-family: "Sora", "Plus Jakarta Sans", sans-serif; font-size: clamp(20px, 4vw, 28px); font-weight: 900; color: var(--text); white-space: nowrap; flex-shrink: 0; line-height: 1; align-self: flex-end; }
/* Results section-head: badge centered, HISTORIAL right */
.team-results-head { position: relative; align-items: center; }
.team-results-head .team-view-cat-badge { position: absolute; left: 50%; transform: translateX(-50%); align-self: auto; }
.team-results-head .eyebrow { margin-bottom: 0; }
/* Nombre completo del club en el header: hasta 2 líneas, sin cortar */
.team-view-name { font-size: 14px; font-weight: 800; white-space: normal; line-height: 1.25; word-break: break-word; overflow: visible; text-overflow: unset; max-width: none; }
/* .team-copy strong tiene especificidad 0,1,1 y gana sobre .team-view-name (0,1,0) — esta regla tiene 0,2,0 */
.team-copy .team-view-name { white-space: normal; overflow: visible; text-overflow: unset; max-width: none; }
.team-view-body { display: grid; gap: 0; }

/* ── Team stats accordion ───────────────────────── */
.team-stats-accordion { margin: 0; border-radius: 0; border-top: 1px solid var(--border); }
.team-stats-accordion[open] .tsa-chevron { transform: rotate(180deg); }
.team-stats-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
}
.team-stats-summary::-webkit-details-marker { display: none; }
.tsa-icon { font-size: 18px; color: var(--accent); }
.tsa-title { flex: 1; }
.tsa-chevron { font-size: 20px; transition: transform 0.2s ease; }
.tsa-body { padding: 0 16px 16px; }
.team-stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.team-stats-table th,
.team-stats-table td { text-align: center; padding: 7px 5px; border-bottom: 1px solid var(--border); }
.team-stats-table th { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding-bottom: 6px; }
.team-stats-table tbody tr:last-child td { border-bottom: none; }
.tsa-label { text-align: left !important; font-weight: 700; color: var(--text); padding-left: 2px; }
.tsa-pts { font-weight: 800; color: var(--accent); }
.tsa-pos { color: #16a34a; font-weight: 700; }
.tsa-neg { color: #dc2626; font-weight: 700; }
.tsa-warn { font-size: 18px !important; color: #ca8a04; }
.tsa-alert { font-size: 12px; color: #92400e; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
/* Fila "Todos" — mismo fondo que el selector de torneo */
.tsa-row-all td { background: rgba(var(--accent-rgb),0.08); color: var(--text); font-weight: 700; border-bottom: none; }
.tsa-row-all .tsa-label { color: var(--accent); font-weight: 800; }
.tsa-row-all td:last-child { color: var(--accent); font-weight: 800; }
/* Posición: lado derecho, flex-shrink */
.team-view-rank { flex-shrink: 0; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); background: rgba(var(--accent-rgb),0.10); border-radius: 999px; padding: 5px 10px; white-space: nowrap; }

/* ── Sync errors tab ───────────────────────────── */
.sync-errors-summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 4px; }
.sync-err-badge { font-size: 11px; font-weight: 700; border-radius: 99px; padding: 3px 10px; }
.sync-err-badge.error   { background: rgba(220,38,38,0.1); color: #dc2626; }
.sync-err-badge.warning { background: rgba(202,138,4,0.12); color: #92400e; }
.sync-err-badge.info    { background: rgba(107,114,128,0.1); color: #374151; }
.sync-errors-list { display: grid; gap: 8px; padding: 8px 0 4px; }
.sync-error-item { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.sync-error-item.sync-error-error  { border-color: rgba(220,38,38,0.25); background: rgba(220,38,38,0.04); }
.sync-error-item.sync-error-warning{ border-color: rgba(202,138,4,0.25);  background: rgba(202,138,4,0.04);  }
.se-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.se-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.se-msg  { font-size: 13px; font-weight: 700; color: var(--text); }
.se-detail { font-size: 11px; color: var(--text-muted); word-break: break-word; line-height: 1.4; }
.se-nav-btn { padding: 6px; min-width: 32px; min-height: 32px; flex-shrink: 0; align-self: center; border-radius: 50%; }
.se-nav-btn .material-symbols-outlined { font-size: 18px; }

/* ── Match detail modal ─────────────────────────── */
.match-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.match-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

.match-detail-dialog {
  position: relative;
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.99);
  box-shadow: 0 24px 64px rgba(0,0,0,0.24);
}

.match-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.match-detail-head h2 {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  margin: 4px 0 0;
  font-size: 20px;
}

.match-detail-body { display: grid; gap: 14px; padding-top: 14px; }

.match-detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.match-detail-summary-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.match-detail-summary-home { align-items: center; }
.match-detail-summary-away { align-items: center; }

.match-detail-summary-team .team-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.match-detail-team-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  word-break: break-word;
  text-align: center;
  line-height: 1.25;
}

.match-detail-summary-center { display: grid; gap: 4px; text-align: center; min-width: 70px; }
.match-detail-scoreline {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  font-size: 30px;
  font-weight: 700;
}

.match-detail-status { font-size: 11px; font-weight: 700; color: var(--muted); }
.match-detail-date { color: var(--muted); font-size: 12px; }

.match-detail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(15,33,18,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.match-detail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.match-detail-column {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.match-detail-column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13px;
}

.match-detail-scorer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  gap: 3px;
}

.match-detail-scorer-name {
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.match-detail-scorer-goals {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--success);
}

.match-detail-scorer-goals .material-symbols-outlined { font-size: 16px; color: var(--success); }

.match-detail-scorer-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--success);
  background: rgba(21,128,61,0.1);
  padding: 3px 8px;
  border-radius: 999px;
}

/* ── Config drawer ──────────────────────────────── */
.config-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.config-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.44);
  backdrop-filter: blur(4px);
}

.config-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: rgba(255,255,255,0.98);
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.config-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}

.config-drawer-head h2 {
  font-family: "Sora", "Plus Jakarta Sans", sans-serif;
  margin: 4px 0 0;
}

.config-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.config-tabs::-webkit-scrollbar { display: none; }

.config-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms ease;
}

.config-tab-btn .material-symbols-outlined { font-size: 16px; }

.config-tab-btn.active {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb),0.3);
  background: rgba(var(--accent-rgb),0.08);
}

.config-body {
  overflow-y: auto;
  padding: 16px;
  display: grid;
  align-content: start;
}

.config-tab-content { display: grid; gap: 16px; }

.config-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.config-section-head h3 { font-family: "Sora", "Plus Jakarta Sans", sans-serif; margin: 4px 0 0; font-size: 18px; }

/* ── Status stack ───────────────────────────────── */
.status-stack { display: grid; gap: 8px; }

.config-section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.info-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  text-align: center;
}

.info-tile-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.info-tile-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  font-size: 13px;
}

.status-row strong {
  max-width: 60%;
  text-align: right;
  font-size: 12px;
  overflow-wrap: break-word;
}

/* ── Sync settings ──────────────────────────────── */
.sync-settings-panel { display: grid; gap: 14px; }

.sync-settings-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sync-preset-btn { padding: 6px 12px; min-height: 34px; font-size: 12px; border-radius: 999px; }

.sync-settings-grid { display: grid; gap: 12px; }

.sync-settings-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.9);
  display: grid;
  gap: 10px;
}

.sync-settings-card h4 { margin: 2px 0 0; font-size: 14px; }

.sync-status-options { display: grid; gap: 6px; }

.sync-interval-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.readonly-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(15,33,18,0.08);
  color: var(--muted);
  white-space: nowrap;
}

/* ── Form fields ────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 700; color: var(--muted); }

.field input,
.field select,
.field textarea,
.color-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font: inherit;
  font-size: 16px; /* ≥16px evita auto-zoom de iOS Safari */
  background: rgba(255,255,255,0.98);
  color: var(--text);
  outline: none;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(var(--accent-rgb),0.4);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.1);
}

.color-field { display: flex; align-items: stretch; gap: 8px; }
.color-field input[type="color"] { width: 64px; min-width: 64px; padding: 4px; border-radius: 10px; cursor: pointer; }

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.checkbox-field input { width: 18px; height: 18px; cursor: pointer; }

/* ── Team form ──────────────────────────────────── */
.team-form-panel {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(246,253,248,0.98);
  margin-bottom: 16px;
}

.team-form, .field { display: grid; gap: 10px; }

.team-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.source-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Color palette ──────────────────────────────── */
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; }

.palette-swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid rgba(15,33,18,0.08);
  background: var(--swatch);
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.palette-swatch.active {
  transform: translateY(-2px);
  border-color: #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--swatch) 50%, rgba(15,33,18,0.15));
}

.palette-swatch:hover { transform: translateY(-1px); }

/* ── Teams grid ─────────────────────────────────── */
.teams-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.teams-wrap { display: grid; gap: 10px; }

.team-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(15,33,18,0.08);
  background: rgba(255,255,255,0.96);
}

.team-card-inactive { opacity: 0.68; }

.team-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.team-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.team-card-actions { display: flex; gap: 6px; }
.team-card-actions .btn { min-height: 34px; padding: 6px 10px; font-size: 12px; border-radius: 10px; }

.mini-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(var(--accent-rgb),0.1);
  color: var(--accent);
}

.mini-badge-alt { background: rgba(14,165,233,0.1); color: var(--accent-2); }
.mini-badge-muted { background: rgba(15,33,18,0.08); color: var(--muted); }

.meta-pill {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.88);
  font-size: 13px;
}

.meta-pill strong { display: block; margin-top: 3px; }

/* ── PLP category editor ────────────────────────── */
.plp-section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; }
.cat-pages-editor { display: grid; gap: 6px; margin-bottom: 4px; }
.cat-page-row { display: flex; gap: 8px; align-items: center; }
.cat-page-row .field-input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 16px; background: var(--card); color: var(--text); }
.cat-page-row .field-input:focus { outline: none; border-color: var(--accent); }
.cat-page-row .cat-page-del { padding: 6px; min-width: 32px; min-height: 32px; flex-shrink: 0; }
#sourcePlpFields { background: rgba(var(--accent-rgb),0.04); border: 1px solid rgba(var(--accent-rgb),0.15); border-radius: 12px; padding: 14px; }

/* ── Sources list ───────────────────────────────── */
.sources-wrap { display: grid; gap: 10px; }

.source-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.96);
  display: grid;
  gap: 8px;
}

.source-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.source-card-title { font-weight: 800; font-size: 14px; margin: 0; }
.source-card-actions { display: flex; gap: 6px; }
.source-card-actions .btn { min-height: 34px; padding: 6px 10px; font-size: 12px; border-radius: 10px; }

.source-card-params {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.source-param {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(240,253,244,0.6);
  font-size: 11px;
}

.source-param-label { color: var(--muted); font-weight: 700; }
.source-param-value { font-weight: 800; font-size: 12px; }

/* ── Tables browser ─────────────────────────────── */
.tables-wrap { overflow-x: auto; }

.tables-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tables-table th,
.tables-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.tables-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }
.tables-table tbody tr:hover { background: rgba(var(--accent-rgb),0.03); }
.table-empty-value { color: var(--muted); }
.table-cell-truncate { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.table-cell-wrap { white-space: normal; max-width: 220px; word-break: break-all; }

.tables-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* ── Empty state ────────────────────────────────── */
.empty-state {
  padding: 24px 14px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.5);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════
   TABLET  ≥ 640px
═══════════════════════════════════════════════ */
@media (min-width: 640px) {
  /* Desktop/tablet: reducir inputs a 14px (no hay riesgo de iOS auto-zoom) */
  .field input, .field select, .field textarea, .color-field input,
  .cat-page-row .field-input { font-size: 14px; }

  body { padding-bottom: 0; }

  /* Tablet+: restore header text */
  .brand-copy { display: grid; gap: 1px; min-width: 0; }
  .topbar-desc { display: block; }
  .profile-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    font-size: 12px;
  }
  .profile-copy strong { font-size: 13px; }
  .profile-chip { padding: 6px 10px; border-radius: 999px; }
  .topbar-actions .btn { padding: 10px 14px; min-height: 44px; min-width: auto; border-radius: 14px; }
  .topbar-actions .btn .material-symbols-outlined { font-size: 22px; }
  .btn-label-full { display: inline; }
  .toolbar-btn { padding: 10px 18px; }

  /* Tabs become top nav */
  .view-tabs {
    position: static;
    background: transparent;
    border-top: none;
    height: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    max-width: 1480px;
    margin: 0 auto;
  }

  .view-tab-btn {
    flex-direction: row;
    flex: 0 0 auto;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.72);
    font-size: 13px;
    color: var(--muted);
  }

  .view-tab-btn .material-symbols-outlined { font-size: 18px; }

  .view-tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--btn-primary-bg-start), var(--btn-primary-bg-end));
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(var(--accent-rgb),0.22);
  }

  .view-tab-btn span:not(.material-symbols-outlined) { display: inline; }

  .stat-card { padding: 12px 8px; }

  .hero { padding: 16px; }

  .source-toolbar { padding: 10px 14px; }
  .panel { margin: 0 14px 14px; }
  .alert { margin: 0 14px 12px; }

  .teams-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ═══════════════════════════════════════════════
   DESKTOP  ≥ 1024px
═══════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .app-topbar { padding: 12px 24px; }

  .panel { margin: 0 20px 20px; }
  .alert { margin: 0 20px 14px; }
  .source-toolbar { padding: 10px 20px; }

  .view-tabs { padding: 8px 20px; }

  .standings-panel, .matches-panel { padding: 22px; }

  .standings-table th,
  .standings-table td { padding: 12px 10px; font-size: 14px; }

  .team-copy strong { max-width: 220px; }

  .teams-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .config-drawer { width: 540px; }

  .source-card-params { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
