:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #2ecc71;
  --accent-dim: #1e8f4e;
  --warn: #f39c12;
  --err: #e74c3c;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.header {
  background: linear-gradient(135deg, #1a472a 0%, #0f1419 60%);
  border-bottom: 2px solid var(--accent-dim);
  padding: 1.25rem 1rem;
}

.header-inner { max-width: 960px; margin: 0 auto; }

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-logo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.grupo-select { min-width: 200px; margin-bottom: 0; }
.grupo-select span { font-size: 0.75rem; }

.header-auth {
  flex: 1 1 280px;
  min-width: 0;
  max-width: 520px;
}

.header-login-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
}

.header-field-grupo {
  flex: 1 1 160px;
  min-width: 140px;
  margin-bottom: 0;
}

.header-field-senha {
  flex: 1 1 120px;
  min-width: 110px;
  margin-bottom: 0;
}

.header-field-grupo span,
.header-field-senha span {
  font-size: 0.72rem;
  color: var(--muted);
}

.header-senha-in {
  width: 100%;
  min-width: 0;
}

.header-auth-hint {
  width: 100%;
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.header-auth-err {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--err);
}

.auth-logado {
  margin-top: 0.35rem;
}

.field-inline select { margin-top: 0.25rem; }

.header h1 { font-size: 1.5rem; font-weight: 700; }

.subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  max-width: 960px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.tab:hover { border-color: var(--accent); color: var(--text); }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1a10;
  font-weight: 600;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.field-compact {
  margin-bottom: 0.75rem;
  max-width: 280px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.field-grow {
  flex: 1 1 200px;
  min-width: 0;
  margin-bottom: 0;
}

.form-msg {
  font-size: 0.88rem;
  margin: -0.5rem 0 1rem;
}

.form-msg.ok { color: var(--accent); }
.form-msg.err { color: var(--err); }

input[type="text"],
input[type="email"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}

.panel { display: none; }
.panel.active { display: block; }

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

.card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.card-head h2 { margin-bottom: 0; }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.hint code, .example code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.example { margin-bottom: 1rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field span { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
}

select { width: 100%; }

textarea {
  font-family: var(--mono);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 200px;
}

select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s;
}

.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); color: #0a1a10; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

.result {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.result.ok { background: rgba(46, 204, 113, 0.12); border: 1px solid var(--accent-dim); }
.result.err { background: rgba(231, 76, 60, 0.12); border: 1px solid var(--err); }
.result.hidden { display: none; }

.result ul { margin: 0.5rem 0 0 1.1rem; }
.result li { margin: 0.2rem 0; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }

tr:hover td { background: rgba(255, 255, 255, 0.03); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.encerrado { background: #2d3f56; color: var(--muted); }
.badge.agendado { background: rgba(46, 204, 113, 0.2); color: var(--accent); }

.muted { color: var(--muted); font-size: 0.88rem; }

.footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.footer-credit {
  margin-bottom: 0.35rem;
  color: var(--text);
  font-size: 0.88rem;
}

.footer a { color: var(--accent); }

.header-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.grade-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.grade-list.is-empty,
.table-wrap.is-empty {
  min-height: 0;
  padding: 0;
}

.match-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.match-card.editavel {
  border-color: var(--accent-dim);
}

.match-card.encerrado {
  opacity: 0.92;
}

.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.match-when {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.match-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.team {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 0;
  min-width: 0;
}

.team-casa {
  justify-content: flex-start;
}

.team-fora {
  justify-content: flex-end;
}

.flag {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.team-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.match-score {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.match-score.inputs {
  flex-direction: row;
}

.score-in {
  width: 2.5rem;
  height: 2.25rem;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
}

.score-in:focus {
  outline: none;
  border-color: var(--accent);
}

.score-num {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
}

.score-sep {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-votar {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.match-footer {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.match-footer.warn { color: var(--warn); }

.match-footer .pts-badge {
  margin-left: 0.35rem;
  color: var(--accent);
  font-weight: 600;
}

.admin-refazer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.card-sub {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}

.card-sub h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.admin-db-upload {
  margin-top: 0.75rem;
}

.err { color: var(--err); }

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(6px);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.login-logo {
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.login-btn {
  width: 100%;
  margin-top: 0.5rem;
}

body.login-locked .header,
body.login-locked .tabs,
body.login-locked .container,
body.login-locked .footer {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.admin-senha-form {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-gate {
  margin-bottom: 1rem;
}

.admin-gate code {
  font-size: 0.9em;
}

#btn-admin-sair {
  margin: 0.5rem 0 1rem;
}

input[type="password"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}

input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 520px) {
  .header-logo {
    width: 56px;
    height: 56px;
  }
  .header h1 {
    font-size: 1.2rem;
  }
  .match-row {
    gap: 0.4rem;
  }
  .team-name {
    font-size: 0.78rem;
    max-width: 4.5rem;
  }
  .flag {
    font-size: 1.15rem;
  }
  .score-in {
    width: 2.1rem;
    height: 2rem;
    font-size: 0.9rem;
  }
  .btn-votar {
    width: 2rem;
    height: 2rem;
  }
}
