:root {
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg: #f8f7fa;
  --card: #ffffff;
  --text: #24212b;
  --muted: #716c7c;
  --border: #e5e3eb;
  --primary: #5b3a82;
  --primary-hover: #472c67;
  --primary-light: rgba(91, 58, 130, 0.08);
  --accent: #10b981;
  --danger: #ef4444;
  --sidebar-bg: #1c1824;
  --sidebar-text: #e2dfeb;
  --sidebar-muted: #8e899b;
  --sidebar-hover: #292435;
  --sidebar-active: #383149;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* App layout */
.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  padding: 22px 20px;
  color: #ffffff;
  display: flex;
  align-items: center;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
  color: #ffffff;
}

.brand.dark {
  color: var(--primary);
  padding: 0;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 800;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-muted);
  font-size: 18px;
  padding: 12px 16px;
  cursor: pointer;
}

.sidebar-close:hover {
  color: #ffffff;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  padding: 10px 20px 4px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  margin: 2px 10px;
  transition: background 0.15s, color 0.15s;
}

.nav-rank {
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

.nav.active .nav-rank {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
}

.nav:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
  text-decoration: none;
}

.nav.active {
  background: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--sidebar-muted);
}

.sidebar-bottom span {
  word-break: break-all;
}

.text-button {
  background: none;
  border: none;
  padding: 0;
  color: #a78bfa;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
}

.text-button:hover {
  color: #c4b5fd;
}

/* Header & Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  box-sizing: border-box;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  border-radius: 6px;
}

.menu-toggle:hover {
  background: #f1eff5;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  transition: all 0.15s;
}

.top-nav-link:hover {
  background: #f8f7fa;
  border-color: var(--primary);
  text-decoration: none;
}

.top-logout-btn {
  background: none;
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.top-logout-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.main-inner {
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  flex: 1;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

p.muted {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 14px;
}

.notice {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}

.stat span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat strong {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

/* Two Columns & Panels */
.two-cols {
  display: grid;
  grid-template-columns: 1.7fr 1.3fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: start;
}

.two-cols > * {
  min-width: 0;
  max-width: 100%;
}

.two-cols.lower {
  margin-top: 24px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.panel.wide {
  min-width: 0;
}

.section-head {
  margin-bottom: 16px;
}

/* Tables */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

th {
  background: #faf9fc;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #faf9fc;
}

td strong {
  display: block;
  font-weight: 600;
  color: var(--text);
}

td small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.rating {
  font-weight: 700;
  color: var(--primary);
  font-feature-settings: "tnum";
}

.gain {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.loss {
  color: var(--danger);
  font-weight: 600;
  font-size: 13px;
}

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.team-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.team-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(91, 58, 130, 0.1);
  text-decoration: none;
}

.team-icon {
  font-size: 20px;
  color: var(--primary);
}

/* Forms & Buttons */
form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

form.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: -4px;
}

input, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

button.primary {
  background: var(--primary);
  color: #ffffff;
  padding: 10px 18px;
}

button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

button.secondary {
  background: #f1eff5;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
}

button.secondary:hover:not(:disabled) {
  background: #e5e2ec;
}

button.danger {
  background: #ef4444;
  color: #ffffff;
  padding: 10px 18px;
}

button.danger:hover:not(:disabled) {
  background: #dc2626;
}

.danger-btn-sm {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.danger-btn-sm:hover {
  background: #ef4444;
  color: #ffffff;
}

.admin-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5b3a82;
  background: rgba(91, 58, 130, 0.12);
  border: 1px solid rgba(91, 58, 130, 0.25);
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

button.full {
  width: 100%;
}

button.google {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  margin-top: 10px;
}

button.google:hover {
  background: #f8f7fa;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.preview {
  font-size: 13px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: -4px;
  border: 1px dashed rgba(91, 58, 130, 0.3);
}

.match {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.match:last-child {
  border-bottom: none;
}

/* Auth Cards */
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.sidebar-backdrop {
  display: none;
}

/* =========================================
   Responsive Breakpoints for Mobile & Tablet
   ========================================= */

@media (max-width: 900px) {
  .app {
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-close {
    display: block;
  }

  /* Off-canvas sidebar drawer on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-bottom {
    display: flex !important;
    margin-top: auto;
    padding: 20px;
    background: #14111a;
  }

  .content {
    width: 100%;
    min-width: 0;
  }

  .top {
    padding: 12px 16px;
    min-height: 56px;
    gap: 8px;
  }

  .main-inner {
    padding: 16px 14px;
    width: 100%;
    box-sizing: border-box;
  }

  .two-cols, .two-cols.lower {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }

  .panel {
    padding: 18px 14px;
    border-radius: 12px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  table {
    min-width: 100%;
    font-size: 13px;
  }

  th, td {
    padding: 10px 8px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 14px 0;
  }

  .stat {
    padding: 10px 12px;
    border-radius: 10px;
  }

  .stat span {
    font-size: 10px;
  }

  .stat strong {
    font-size: 18px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  form.inline {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .hide-mobile {
    display: none;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  th, td {
    padding: 8px 6px;
    font-size: 12px;
  }

  td strong {
    font-size: 13px;
  }

  td small {
    font-size: 11px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-nav-link {
    padding: 6px 8px;
    font-size: 12px;
  }

  .top-logout-btn {
    padding: 6px 8px;
    font-size: 12px;
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: 12px;
  }

  .auth-actions {
    grid-template-columns: 1fr;
  }
}
