:root {
  --bg: #081124;
  --panel: #0f1d37;
  --panel-2: #132447;
  --line: #2a3f6b;
  --text: #e8eefc;
  --muted: #9db0d8;
  --good: #37c978;
  --bad: #ff6a88;
  --pending: #ffd36b;
  --accent: #41d6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 15% -10%, #1a3a78 0%, #081124 52%), #081124;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0;
  font-size: 1.7rem;
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

select,
input,
button {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, #2154af, #2992d9);
  border-color: #5bc4ea;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.admin-users-panel {
  margin: 0 0 14px;
}

.admin-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-users-header h2 {
  margin: 0;
  font-size: 1rem;
}

.admin-users-header strong {
  color: #9bd4ff;
}

.admin-users-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}

.admin-users-table-wrap {
  margin: 0;
}

.admin-user-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #9bd4ff;
  text-align: left;
  text-decoration: underline;
}

.admin-users-table-wrap tr.active {
  background: #17294d;
}

.admin-user-detail {
  border: 1px solid #2a3f66;
  border-radius: 10px;
  background: #12223f;
  padding: 12px;
}

.admin-user-detail h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.admin-user-meta {
  margin: 0;
  display: grid;
  gap: 9px;
}

.admin-user-meta div {
  display: grid;
  gap: 3px;
}

.admin-user-meta dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-user-meta dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}

.best-of-day {
  margin-bottom: 16px;
}

.tab-shell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.day-tab-shell {
  margin-bottom: 16px;
}

.day-search-field {
  min-width: 220px;
  margin-left: auto;
}

.team-search-results {
  margin: -6px 0 14px;
  padding: 10px 12px;
  border: 1px solid #2a3f66;
  border-radius: 12px;
  background: #10213e;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.team-search-label {
  color: var(--muted);
  font-size: 0.84rem;
}

.team-search-hit {
  border: 1px solid #36558b;
  background: #17305b;
  color: #dbe9ff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.status-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #8b7531;
  background: linear-gradient(135deg, #3f2f14, #5a4117);
  color: #ffe8a6;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tab-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}

.tab-btn.locked {
  border-color: #6f5b2a;
  color: #d6c28c;
}

.tab-lock {
  margin-left: 6px;
  font-size: 0.88rem;
}

.auth-user-chip {
  border: 1px solid #2f8f4b;
  color: #aef5c3;
  background: #0f2e1d;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.signup-teaser {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 700;
  border: 1px solid #5b4a1e;
  background: linear-gradient(135deg, #2b2412, #3a2e12);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
  width: min(280px, calc(100vw - 24px));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.signup-teaser p {
  margin: 0;
  color: #ffe6a8;
  font-size: 0.84rem;
}

.signup-teaser button {
  width: 100%;
}

.signup-teaser-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.day-tab-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}

.day-tab-btn.locked {
  border-color: #6f5b2a;
  color: #d6c28c;
}

.day-lock {
  margin-left: 6px;
  font-size: 0.88rem;
}

.tab-btn.active {
  color: var(--text);
  border-color: #5bc4ea;
  background: linear-gradient(135deg, #2154af, #2992d9);
}

.day-tab-btn.active {
  color: var(--text);
  border-color: #5bc4ea;
  background: linear-gradient(135deg, #2154af, #2992d9);
}

.best-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.best-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.best-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.best-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.combo-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 16px;
}

.combo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.combo-card {
  border: 1px solid #2c4d84;
  border-radius: 12px;
  background: linear-gradient(145deg, #122444, #0e1d38);
  padding: 12px;
}

.combo-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.combo-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.combo-hit-rate {
  color: #a2f1ff;
  font-size: 0.82rem;
  font-weight: 600;
}

.combo-legs {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 9px;
}

.combo-leg-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.combo-leg-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.combo-leg-meta {
  margin-top: 6px;
  color: #dbe9ff;
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.best-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
}

.best-card h3 {
  margin: 6px 0 4px;
  font-size: 0.95rem;
  line-height: 1.3;
}

.best-rank {
  display: inline-block;
  border: 1px solid #3b5f95;
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
}

.best-league {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.best-metrics {
  margin-top: 10px;
  display: grid;
  gap: 4px;
  font-size: 0.84rem;
}

.best-metrics strong {
  color: #a2f1ff;
  margin-right: 4px;
}

.best-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.loading-card {
  color: var(--muted);
}

.stats article {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
}

.stats h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  background: var(--panel);
}

.tab-panel {
  margin-bottom: 16px;
}

.tab-panel[hidden] {
  display: none !important;
}

.stream-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.stream-controls {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.signup-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 20, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
}

.signup-modal[hidden] {
  display: none !important;
}

.signup-modal-card {
  width: min(520px, 96vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 18px;
  position: relative;
}

.signup-modal-card h3 {
  margin: 0 0 8px;
}

.signup-modal-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.signup-form {
  display: grid;
  gap: 10px;
}

.signup-form[hidden] {
  display: none !important;
}

.auth-mode-switch button.active {
  border-color: #5bc4ea;
  background: linear-gradient(135deg, #2154af, #2992d9);
  color: #f6fbff;
}

.signup-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 36px;
  padding: 8px 10px;
}

.signup-feedback {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: #ffd9a8;
}

.inline-field span {
  min-width: 56px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

thead {
  background: var(--panel-2);
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #22365e;
  vertical-align: top;
  font-size: 0.88rem;
}

tbody tr:hover {
  background: #17294d;
}

.badge {
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  font-size: 0.76rem;
  display: inline-block;
}

.badge.good {
  color: var(--good);
  border-color: #2d8d5c;
}

.badge.bad {
  color: var(--bad);
  border-color: #8f3550;
}

.badge.live {
  color: var(--accent);
  border-color: #2f6ea0;
}

.badge.pending {
  color: var(--pending);
  border-color: #8b7531;
}

.badge.legacy {
  color: #9fc5ff;
  border-color: #4a6ea6;
}

.live-time {
  font-weight: 600;
}

.live-time-early {
  color: #9de7ff;
}

.live-time-mid {
  color: #ffd36b;
}

.live-time-late {
  color: #ff9d5c;
}

.live-time-empty {
  color: var(--muted);
  font-weight: 500;
}

.loading {
  color: var(--muted);
  text-align: center;
}

.confidence-panel {
  display: grid;
  gap: 14px;
}

.analysis-shell {
  padding: 12px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.analysis-warning {
  border: 1px solid #8b7531;
  border-radius: 12px;
  background: linear-gradient(135deg, #3f2f14, #5a4117);
  color: #ffe8a6;
  padding: 10px 12px;
  font-weight: 700;
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
}

.analysis-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.analysis-subtitle {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.analysis-card-table {
  overflow: auto;
}

.analysis-table {
  min-width: 560px;
}

@media (max-width: 1100px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    width: 100%;
    align-items: stretch;
  }

  .hero-actions .field {
    flex: 1 1 180px;
  }

  .hero-actions select,
  .hero-actions button {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .best-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .combo-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page {
    padding: 12px;
  }

  .signup-teaser {
    right: 10px;
    bottom: 10px;
    width: min(260px, calc(100vw - 16px));
  }

  .hero h1 {
    font-size: 1.35rem;
  }

  .hero p {
    font-size: 0.86rem;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .hero-actions .field {
    display: none;
  }

  .hero-actions button {
    width: 100%;
  }

  .tab-shell {
    gap: 6px;
  }

  .tab-btn,
  .day-tab-btn {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    min-height: 42px;
    padding: 9px 10px;
    font-size: 0.9rem;
  }

  .day-search-field {
    margin-left: 0;
    min-width: 100%;
    flex: 1 1 100%;
  }

  #team-search-clear {
    width: 100%;
  }

  .stream-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .inline-field {
    width: 100%;
    justify-content: space-between;
  }

  .inline-field select {
    width: 58%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats article {
    padding: 10px;
  }

  .admin-users-layout {
    grid-template-columns: 1fr;
  }

  .stats strong {
    font-size: 1.05rem;
  }

  table {
    min-width: 760px;
  }

  th,
  td {
    padding: 8px;
    font-size: 0.8rem;
  }

  .tab-panel:not(#tab-confidence-analysis) > table {
    min-width: 100%;
  }

  .tab-panel:not(#tab-confidence-analysis) > table thead {
    display: none;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody {
    display: block;
    width: 100%;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody tr {
    display: block;
    border: 1px solid #22365e;
    border-radius: 10px;
    margin: 0 0 10px;
    background: rgba(16, 31, 59, 0.65);
    overflow: hidden;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    border-bottom: 1px dashed #284371;
    text-align: right;
    padding: 9px 10px;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td:last-child {
    border-bottom: 0;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td::before {
    content: attr(data-label);
    display: inline-block;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    margin-right: auto;
    min-width: 44%;
    white-space: normal;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td[data-label=""] {
    display: block;
    text-align: center;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td[data-label=""]::before {
    content: "";
    display: none;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody td.mobile-extra {
    display: none;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody tr.mobile-expanded td.mobile-extra {
    display: flex;
  }

  .tab-panel:not(#tab-confidence-analysis) > table tbody tr.mobile-expanded td.mobile-extra::before {
    color: #8fb2e8;
  }

  .mobile-toggle-wrap {
    margin-top: 8px;
    text-align: left;
  }

  .mobile-details-toggle {
    border: 1px solid #36558b;
    background: #17305b;
    color: #d7e8ff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.76rem;
    line-height: 1.3;
    cursor: pointer;
  }

  .best-grid {
    grid-template-columns: 1fr;
  }

  .analysis-table {
    min-width: 460px;
  }
}
