html {
  font-size: 14px;
}

:root,
html[data-theme='light'] {
  --bg-main: radial-gradient(circle at 0% 0%, #eef4ff 0%, #e6eeff 45%, #dfe9fb 100%);
  --bg-accent: radial-gradient(circle at 100% 0%, rgba(76, 110, 245, 0.22), transparent 45%), radial-gradient(circle at 0% 100%, rgba(0, 201, 255, 0.14), transparent 40%);
  --text-main: #1d2942;
  --text-strong: #0f172a;
  --muted: #66789b;
  --owner: #3158d6;

  --surface: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 251, 255, 0.95));
  --surface-2: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(242, 248, 255, 0.95));
  --surface-border: rgba(63, 98, 186, 0.2);
  --surface-shadow: 0 18px 40px rgba(59, 88, 158, 0.16);

  --sidebar-bg: linear-gradient(180deg, #13213d 0%, #0f1a31 55%, #0a1428 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #d7e2ff;
  --sidebar-muted: #8da4d8;
  --sidebar-active-bg: linear-gradient(90deg, rgba(109, 145, 255, 0.32), rgba(109, 145, 255, 0.08));

  --topbar-bg: linear-gradient(115deg, rgba(255, 255, 255, 0.88), rgba(236, 245, 255, 0.92));
  --topbar-border: rgba(63, 98, 186, 0.22);

  --table-hover: rgba(76, 110, 245, 0.08);
  --table-border: rgba(30, 45, 78, 0.12);
}

html[data-theme='dark'] {
  --bg-main: radial-gradient(circle at 0% 0%, #111d35 0%, #0a1325 48%, #050a17 100%);
  --bg-accent: radial-gradient(circle at 100% 0%, rgba(0, 201, 255, 0.16), transparent 40%), radial-gradient(circle at 0% 100%, rgba(120, 85, 255, 0.16), transparent 45%);
  --text-main: #dbe7ff;
  --text-strong: #f4f7ff;
  --muted: #8ea3ca;
  --owner: #7fb5ff;

  --surface: linear-gradient(180deg, rgba(19, 35, 66, 0.9), rgba(10, 20, 39, 0.94));
  --surface-2: linear-gradient(180deg, rgba(24, 43, 78, 0.9), rgba(11, 24, 46, 0.93));
  --surface-border: rgba(126, 165, 250, 0.22);
  --surface-shadow: 0 24px 48px rgba(0, 0, 0, 0.42);

  --sidebar-bg: linear-gradient(180deg, #0e1830 0%, #0b1428 60%, #081021 100%);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-text: #d6e2ff;
  --sidebar-muted: #8ca5d8;
  --sidebar-active-bg: linear-gradient(90deg, rgba(79, 130, 255, 0.35), rgba(79, 130, 255, 0.1));

  --topbar-bg: linear-gradient(115deg, rgba(16, 31, 59, 0.86), rgba(10, 20, 40, 0.9));
  --topbar-border: rgba(126, 165, 250, 0.24);

  --table-hover: rgba(126, 165, 250, 0.09);
  --table-border: rgba(255, 255, 255, 0.13);
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #4c6ef5;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-accent), var(--bg-main);
  color: var(--text-main);
}

body.is-page-transitioning .app-shell,
body.is-page-transitioning .footer {
  opacity: 0;
  pointer-events: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  transition: opacity 0.12s ease;
}

.side-nav {
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 1rem 0.8rem;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 20px 0 45px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
}

.stat-card .staff-link {
  font-size: 1rem;
  font-weight: 700;
}

.brand-panel {
  padding: 0.65rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.85rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
}

.northcloud-logo {
  display: block;
  width: 170px;
  max-width: 100%;
  height: auto;
}

.side-nav .navbar-brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  display: block;
  margin-top: 0.25rem;
  color: var(--sidebar-muted);
}

.menu-caption {
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  margin: 0.05rem 0 0.35rem 0.45rem;
}

.side-nav .nav-link {
  color: var(--sidebar-text);
  border-radius: 0.75rem;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.menu-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #a1b8ff, #78d9ff);
  box-shadow: 0 0 0 3px rgba(125, 158, 255, 0.22);
}

.side-nav .nav-link:hover,
.side-nav .nav-link.active {
  color: #fff;
  background: var(--sidebar-active-bg);
  transform: translateX(2px);
}

.side-nav-footer {
  margin-top: auto;
  padding-top: 0.7rem;
}

.theme-toggle {
  border: 1px solid var(--surface-border);
  color: var(--text-strong);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(4px);
}

.theme-toggle:hover {
  background-color: color-mix(in oklab, var(--surface-2) 90%, transparent);
  color: var(--text-strong);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 0.7rem;
}

.top-menu-bar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(6px);
}

.mobile-nav-toggle,
.mobile-nav-close {
  display: none;
}

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 29, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  z-index: 1040;
}

.scroll-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1090;
  border-radius: 999px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.scroll-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.top-menu-sync-label {
  color: var(--muted);
  font-weight: 600;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.dashboard-header,
.group-card,
.stat-card,
.fixture-card {
  backdrop-filter: blur(6px);
}

.dashboard-header {
  background: var(--surface-2);
  border: 1px solid var(--surface-border);
  border-radius: 0.75rem;
  box-shadow: var(--surface-shadow);
}

.stat-card {
  min-width: 110px;
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--surface-shadow);
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.1;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 0.72rem;
  box-shadow: var(--surface-shadow);
}

.group-header h2 {
  color: var(--text-strong);
}

.team-row {
  border-color: var(--table-border) !important;
}

.team-row:last-child {
  border-bottom: 0 !important;
}

.team-flag {
  width: 30px;
  height: 20px;
  border-radius: 0.35rem;
  object-fit: cover;
  border: 1px solid color-mix(in oklab, var(--surface-border) 65%, transparent);
}

.team-owner {
  color: var(--owner);
  font-weight: 600;
}

.staff-link {
  color: var(--owner);
  text-decoration: none;
}

.staff-link:hover {
  text-decoration: underline;
}

.standings-table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--table-hover);
  --bs-table-color: var(--text-main);
  --bs-table-border-color: var(--table-border);
}

.fixture-card {
  position: relative;
  border: 1px solid var(--table-border);
  border-radius: 0.65rem;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  overflow: hidden;
  padding-left: 2rem !important;
  padding-right: 2rem !important;
}

.matches-fixed-width {
  width: min(50vw, 960px);
  margin-inline: auto;
}

.matches-header {
  width: min(50vw, 960px);
  margin-inline: auto;
}

.matches-fixed-width .fixture-card {
  width: 100%;
}

.fixture-card::before,
.fixture-card::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  opacity: 0;
}

.fixture-card::before {
  left: 0;
}

.fixture-card::after {
  right: 0;
}

.fixture-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
}

.fixture-team {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.fixture-score {
  min-width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  text-align: center;
  font-weight: 700;
  color: var(--text-strong);
}

.fixture-scoreline {
  font-size: 0.86rem;
  font-style: normal;
  color: var(--text-strong);
}

.fixture-home-win::before,
.fixture-away-win::after {
  background: #16a34a;
  opacity: 1;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, #0f7a35 70%, #ffffff 30%);
}

.fixture-home-loss::before,
.fixture-away-loss::after {
  background: #dc2626;
  opacity: 1;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, #991b1b 70%, #ffffff 30%);
}

.fixture-home-draw::before,
.fixture-away-draw::after {
  background: #6b7280;
  opacity: 1;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, #4b5563 70%, #ffffff 30%);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  border: 1px solid transparent;
}

.status-chip-finished {
  background: #2f6fed;
  border-color: #2f6fed;
  color: #ffffff;
}

.status-chip-not-started {
  background: #6b7280;
  border-color: #6b7280;
  color: #ffffff;
}

.status-chip-in-progress {
  background: #facc15;
  border-color: #facc15;
  color: #1f2937;
}

.footer,
.footer a,
.text-light-emphasis,
.text-secondary,
.text-muted {
  color: var(--muted) !important;
}

.footer {
  margin: 0.2rem 0.7rem 0.7rem;
  border-color: var(--surface-border) !important;
  transition: opacity 0.12s ease;
  font-size: 0.86rem;
}

.table {
  font-size: 0.9rem;
}

.table th,
.table td {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.staff-team-highlight > td {
  background: color-mix(in oklab, var(--owner) 18%, transparent) !important;
}

.page-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--bg-main) 72%, transparent);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.page-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loading-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  border-radius: 0.75rem;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: var(--surface-shadow);
}

@media (max-width: 991.98px) {
  body.mobile-nav-open {
    overflow: hidden;
  }

  .app-shell {
    flex-direction: column;
  }

  .top-menu-bar {
    position: sticky;
    top: 0;
    z-index: 1050;
  }

  .mobile-nav-toggle,
  .mobile-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .side-nav {
    width: min(84vw, 320px);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1045;
    box-shadow: 20px 0 45px rgba(0, 0, 0, 0.32);
    overflow-y: auto;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  body.mobile-nav-open .side-nav {
    transform: translateX(0);
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .page-content,
  .footer {
    margin-left: 0;
    margin-right: 0;
  }

  .page-content {
    padding: 1rem;
  }
}

@media (max-width: 767.98px) {
  .matches-fixed-width,
  .matches-header {
    width: 100%;
  }

  .matches-header-content {
    flex-direction: column;
    align-items: stretch !important;
  }

  .matches-header-content .btn-group {
    width: 100%;
  }

  .matches-header-content .btn-group .btn {
    flex: 1 1 0;
  }

  .fixture-card {
    padding-left: 1.7rem !important;
    padding-right: 1.7rem !important;
  }

  .fixture-row {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .fixture-score {
    order: -1;
    margin-bottom: 0.1rem;
  }

  .fixture-team {
    justify-content: space-between;
  }

  .fixture-team.text-end {
    text-align: left !important;
  }
}
