:root {
  --bg: #0b1017;
  --surface: #0e1522;
  --card: #0f1724;
  --border: #1f2b3d;
  --text: #f2f6fb;
  --muted: #8b9eb0;
  --accent: #2f6fe0;
  --accent-hover: #3a7cf0;
  --accent-tint: #1b2f52;
  --accent-text: #9cc6ff;
  --green: #34c98a;
  --red: #f0a294;
  --amber: #f0c877;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: #bcd8ff; }

.header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.35rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: #f2f6fb;
  white-space: nowrap;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-nav { display: flex; align-items: center; gap: 1.15rem; margin-left: auto; }
.header-nav > a,
.header-nav .nav-group-label {
  color: #8ab4ff;
  font-size: 0.95rem;
  font-weight: 500;
}
.header-nav > a:hover,
.header-nav .nav-group-label:hover { color: #e8eef7; }
.header-nav > a.is-current,
.header-nav .nav-group.is-current > .nav-group-label { color: #e8eef7; font-weight: 500; }
.header-nav .user { color: var(--muted); font-size: 0.85rem; }
.inline { display: inline; margin: 0; }
.header button {
  background: #1a2536;
  color: #dbe6f4;
  border: 1px solid #33455e;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.header button:hover { background: #223044; }

/* Hamburger: hidden on desktop */
.header-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  margin-left: auto;
  border-radius: 6px;
}
.header-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

@media (max-width: 900px) {
  .header-toggle { display: flex; }
  .header-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-left: 0;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
  }
  .header-nav.header-nav-open {
    display: flex;
  }
  .header-nav .user { margin: 0.25rem 0; }
  .header-nav form { margin: 0.25rem 0; }
}

.main { width: 90%; max-width: none; margin: 0 auto; padding: 1.5rem 2rem; }
.main:has(.fx-board) { width: auto; max-width: none; }

@media (max-width: 900px) {
  .main { width: 100%; padding: 1rem; }
}

/* Login */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}
.login-box h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.tagline { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.form label { display: block; margin-top: 1rem; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--muted); }
.form input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 1rem; }
.form button { margin-top: 1.5rem; width: 100%; padding: 0.6rem; background: var(--accent); color: #fff; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; }
.form button:hover { background: var(--accent-hover); }

/* Lists */
.page-title { margin: 0 0 1rem; font-size: 1.5rem; letter-spacing: -0.02em; }
.success { color: var(--green); }
.error { color: var(--red); }
.muted { color: var(--muted); }
.actions { margin-bottom: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.9rem; border: none; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #1a2536; color: #dbe6f4; border: 1px solid #33455e; }
.btn-secondary:hover { background: #223044; }
.btn-danger { background: #26161a; color: #f0a294; border: 1px solid #4d2b2e; }
.btn-danger:hover { background: #3a1d22; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}
.card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.card .card-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
th, td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid #17202e; }
th { background: #0d1420; color: var(--muted); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.02em; }
tr:nth-child(even) td { background: #111a27; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #18222f; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text);
}

/* Nav dropdown groups */
.nav-group {
  position: relative;
}
.nav-group-label {
  cursor: pointer;
  color: #8ab4ff;
  font-size: 0.95rem;
  user-select: none;
}
.nav-group-label:hover {
  color: #e8eef7;
}
.nav-group-label::after {
  content: " \25BE";
  font-size: 0.7em;
}
.nav-group-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0;
  padding-top: 0.6rem;
  min-width: 180px;
  z-index: 50;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.nav-group:hover .nav-group-menu {
  display: flex;
}
.nav-group-menu a {
  padding: 0.45rem 1rem;
  white-space: nowrap;
  display: block;
}
.nav-group-menu a:hover {
  background: #222c3a;
}

@media (max-width: 900px) {
  .nav-group { width: 100%; }
  .nav-group-label { display: block; padding: 0.25rem 0; }
  .nav-group-label::after { content: " \25BE"; }
  .nav-group.nav-group-open .nav-group-label::after { content: " \25B4"; }
  .nav-group-menu {
    position: static;
    transform: none;
    display: none;
    border: none;
    background: none;
    box-shadow: none;
    padding: 0 0 0.25rem 1rem;
    min-width: 0;
  }
  .nav-group.nav-group-open .nav-group-menu {
    display: flex;
    flex-direction: column;
  }
  .nav-group:hover .nav-group-menu {
    display: none;
  }
  .nav-group.nav-group-open:hover .nav-group-menu {
    display: flex;
  }
}

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; min-width: 320px; max-width: 90vw; }
.modal-add-referee { max-width: 560px; width: 95vw; max-height: 90vh; overflow-y: auto; }
#add-referee-modal { z-index: 350; }
.modal h3 { margin: 0 0 1rem; }
.modal-actions { margin-top: 1rem; display: flex; gap: 0.5rem; justify-content: flex-end; }
.hidden { display: none !important; }
.modal-feedback { width: min(520px, 90vw); }
.modal-feedback textarea { min-height: 8rem; resize: vertical; }
#feedback-modal {
  display: none !important;
  z-index: 400;
}
#feedback-modal.feedback-open {
  display: flex !important;
}

.pwa-install {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 350;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  max-width: calc(100% - 2rem);
  font-size: 0.9rem;
}

.gb-toast-host {
  position: fixed;
  left: 50%;
  bottom: 1.15rem;
  transform: translateX(-50%);
  z-index: 360;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.45rem;
  width: min(34rem, calc(100% - 1.5rem));
  pointer-events: none;
}
.gb-toast {
  pointer-events: auto;
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #152033;
  color: var(--text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  font-size: 0.92rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.gb-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.gb-toast.is-success {
  background: #12291f;
  border-color: #235640;
  color: #7fdcb4;
}
.gb-toast.is-error {
  background: #26161a;
  border-color: #4d2b2e;
  color: #f0a294;
}
.gb-toast.is-muted {
  background: #152033;
  border-color: #33455e;
  color: #dbe6f4;
}
