:root {
  --bg: #edf2f5;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --ink: #111a22;
  --muted: #64727f;
  --line: #d8e1e7;
  --nav: #111c24;
  --accent: #f3c642;
  --accent-strong: #d4a80e;
  --good: #168252;
  --bad: #bd3434;
  --warn: #a96f08;
  --shadow: 0 16px 50px rgba(17, 26, 34, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 94px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  background: #111c24;
  color: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
}

.auth-brand {
  min-height: 270px;
  border-radius: var(--radius);
  background: var(--nav);
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: var(--shadow);
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: #fff;
  object-fit: cover;
}

.brand-logo.large {
  width: 82px;
  height: 82px;
  margin-bottom: auto;
}

.auth-brand h1,
.auth-card h2,
.app-header h1,
.view-heading h2,
.panel h3 {
  margin: 0;
  line-height: 1.05;
}

.auth-brand h1 {
  font-size: clamp(2.4rem, 12vw, 4.8rem);
}

.auth-status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.78);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.auth-card,
.panel,
.summary-card,
.hero-panel,
.month-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(17, 26, 34, 0.03);
}

.auth-card {
  align-self: center;
  padding: 22px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(243, 198, 66, 0.24);
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
}

.button.primary {
  border-color: #111c24;
  background: #111c24;
  color: #fff;
}

.button.ghost {
  background: var(--surface-soft);
}

.button.compact {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  background: var(--surface-soft);
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--bad);
  font-weight: 800;
}

.app-screen {
  min-height: 100dvh;
  padding-bottom: 86px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(216, 225, 231, 0.8);
  background: rgba(237, 242, 245, 0.94);
  padding: 14px 18px;
  backdrop-filter: blur(12px);
}

.brand-block,
.header-actions,
.toolbar,
.panel-header,
.check-row {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 12px;
}

.brand-block h1 {
  overflow: hidden;
  max-width: 56vw;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.35rem;
}

.header-actions {
  gap: 8px;
}

.app-layout {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.month-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 12px;
}

.view-heading h2 {
  font-size: clamp(1.85rem, 8vw, 3.3rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: #2869d8;
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mini-state,
.badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 950;
}

.mini-state,
.badge {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.pill.good {
  background: rgba(22, 130, 82, 0.12);
  color: var(--good);
}

.pill.bad {
  background: rgba(189, 52, 52, 0.12);
  color: var(--bad);
}

.pill.warn {
  background: rgba(169, 111, 8, 0.12);
  color: var(--warn);
}

.view {
  display: none;
}

.view.active-view {
  display: grid;
  gap: 14px;
}

.hero-panel {
  overflow: hidden;
  padding: 18px;
  background: #111c24;
  color: #fff;
}

.hero-panel h3 {
  margin: 0;
  font-size: clamp(2rem, 10vw, 4.4rem);
  line-height: 0.98;
}

.hero-panel p {
  max-width: 720px;
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.stat-card small,
.muted {
  color: var(--muted);
  font-weight: 750;
}

.stat-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 7vw, 2.25rem);
  line-height: 1;
}

.content-grid {
  display: grid;
  gap: 12px;
}

.panel,
.summary-card {
  padding: 14px;
}

.panel-header {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel h3 {
  font-size: 1.15rem;
}

.list {
  display: grid;
  gap: 8px;
}

.list-row,
.player-row,
.match-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-main strong {
  overflow-wrap: anywhere;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 14px;
  text-align: center;
  font-weight: 800;
}

.toolbar {
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar label {
  flex: 1 1 220px;
}

.summary-card {
  display: grid;
  gap: 14px;
  background: #fff9e6;
  border-color: rgba(212, 168, 14, 0.35);
}

.summary-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.summary-title h3 {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 3rem);
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-row {
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
}

.check-row input {
  width: 22px;
  min-height: 22px;
}

.player-table {
  display: grid;
  gap: 8px;
}

.player-row {
  grid-template-columns: minmax(0, 1fr);
}

.player-row .amounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.amount-box {
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
  min-width: 0;
}

.amount-box span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.amount-box strong {
  overflow-wrap: anywhere;
}

.row-actions,
.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions .button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 8px 10px;
  font-weight: 900;
}

.compact-list .list-row {
  padding: 10px;
}

.admin-layout {
  display: grid;
  gap: 12px;
}

.admin-page.hidden {
  display: none !important;
}

.admin-menu-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: #07141c;
  color: #eef6fb;
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.admin-title h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.admin-title p {
  margin: 5px 0 0;
  color: var(--accent);
  font-weight: 950;
}

.admin-bell {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(238, 246, 251, 0.82);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  border-bottom: 0;
  position: relative;
}

.admin-bell::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: -7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(238, 246, 251, 0.82);
}

.admin-group {
  display: grid;
  gap: 0;
  margin-top: 18px;
}

.admin-group-title {
  margin: 0 0 8px;
  color: rgba(238, 246, 251, 0.78);
  font-size: 0.82rem;
  font-weight: 950;
}

.admin-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.06);
  color: #eef6fb;
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.admin-row:first-of-type {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.admin-row:last-of-type {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.admin-row.active {
  background: rgba(243, 198, 66, 0.14);
}

.admin-row.danger {
  color: #ff6d6d;
}

.admin-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.admin-row small {
  color: #5fd18e;
  font-weight: 950;
}

.chevron {
  color: rgba(238, 246, 251, 0.66);
  font-weight: 950;
}

.admin-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  position: relative;
  color: rgba(238, 246, 251, 0.82);
}

.admin-icon::before,
.admin-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.icon-user::before {
  width: 10px;
  height: 10px;
  top: 3px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.icon-user::after {
  width: 18px;
  height: 8px;
  bottom: 2px;
  border: 2px solid currentColor;
  border-radius: 9px 9px 2px 2px;
}

.icon-rule::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-rule::after {
  width: 10px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
}

.icon-status::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.icon-status::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}

.icon-theme::before {
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 6px 6px 10px 10px;
}

.icon-theme::after {
  width: 8px;
  height: 4px;
  top: 2px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.icon-export::before {
  width: 16px;
  height: 10px;
  bottom: 3px;
  border: 2px solid currentColor;
  border-top: 0;
}

.icon-export::after {
  width: 9px;
  height: 9px;
  top: 3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon-audit::before {
  width: 16px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-audit::after {
  width: 8px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

.icon-lock::before {
  width: 16px;
  height: 12px;
  bottom: 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-lock::after {
  width: 10px;
  height: 10px;
  top: 1px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.icon-backup::before {
  width: 18px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.icon-backup::after {
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.admin-panels {
  display: grid;
  gap: 12px;
}

.admin-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: #07141c;
  color: #eef6fb;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  padding: 14px;
}

.admin-detail-header .eyebrow {
  color: var(--accent);
}

.admin-detail-header h3 {
  margin: 0;
  line-height: 1;
  font-size: 1.35rem;
}

.admin-back-button {
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #eef6fb;
}

.admin-panel {
  display: none;
}

.admin-panel.active-admin-panel {
  display: block;
}

.admin-form {
  margin-bottom: 12px;
}

.invite-box {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(243, 198, 66, 0.32);
  border-radius: var(--radius);
  background: #fff9e6;
  margin-bottom: 14px;
  padding: 12px;
}

.invite-box .panel-header {
  margin-bottom: 0;
}

.invite-result {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(22, 130, 82, 0.22);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.invite-result input {
  font-size: 0.88rem;
}

.editor-list {
  display: grid;
  gap: 10px;
}

.editor-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.editor-card .row-actions {
  justify-content: flex-end;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--nav);
  padding: 8px;
  box-shadow: 0 -12px 34px rgba(17, 26, 34, 0.2);
}

.bottom-nav button {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.66);
  cursor: pointer;
  font-size: clamp(0.68rem, 2.7vw, 0.86rem);
  font-weight: 950;
  line-height: 1.1;
  padding: 8px 4px;
}

.bottom-nav button.active {
  background: #fff;
  color: var(--nav);
}

.bottom-nav button[hidden],
.admin-only[hidden],
.treasury-only[hidden] {
  display: none !important;
}

@media (min-width: 740px) {
  .auth-screen {
    grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 0.65fr);
    align-items: stretch;
    padding: 34px;
  }

  .auth-brand,
  .auth-card {
    min-height: calc(100dvh - 68px);
  }

  .auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 34px;
  }

  .app-layout {
    padding: 24px;
  }

  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reverse-mobile {
    direction: rtl;
  }

  .reverse-mobile > * {
    direction: ltr;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-layout {
    width: min(760px, 100%);
    margin: 0 auto;
  }

  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1020px) {
  .app-screen {
    padding-bottom: 102px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(860px, calc(100vw - 48px));
    transform: translateX(-50%);
    border-radius: var(--radius);
  }

  .player-row {
    grid-template-columns: minmax(220px, 1.1fr) minmax(320px, 1fr) auto;
    align-items: center;
  }
}
