:root {
  --bg: #f6f4ee;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #667085;
  --line: #ded8cb;
  --primary: #146c5f;
  --primary-dark: #0e554b;
  --secondary: #263a6b;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #087443;
  --soft: #edf7f3;
  --shadow: 0 18px 50px rgba(21, 23, 26, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 108, 95, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(38, 58, 107, 0.08), transparent 38%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-panel {
  width: min(100%, 430px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-weight: 700;
}

.app-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.admin-nav a {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 850;
  text-decoration: none;
}

.admin-nav a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.panel,
.balance-panel {
  background: var(--panel);
  border: 1px solid rgba(222, 216, 203, 0.78);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.balance-panel {
  display: grid;
  gap: 6px;
  padding: 22px;
  margin-bottom: 18px;
}

.balance-panel span {
  color: var(--muted);
  font-weight: 800;
}

.balance-panel strong {
  font-size: clamp(34px, 11vw, 64px);
  line-height: 1;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.compact {
  width: min(100%, 310px);
}

.row.compact input {
  width: 86px;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: var(--secondary);
  color: #fff;
}

.ghost,
.button-like {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.admin-link {
  display: block;
  margin-top: 18px;
  color: var(--primary);
  text-align: center;
  font-weight: 800;
}

.notice {
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  font-weight: 750;
}

.notice.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs,
.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f7f3;
}

.tab,
.segmented span {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.tab.active,
.segmented input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 14px rgba(21, 23, 26, 0.08);
}

.segmented label {
  display: block;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
}

.setup-list,
.players-list,
.history {
  display: grid;
  gap: 10px;
}

.history-filter {
  margin-bottom: 14px;
}

.setup-row,
.player-card,
.tx {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.setup-row {
  grid-template-columns: minmax(110px, 1fr) 110px 140px;
  align-items: end;
}

.player-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.player-card strong,
.tx strong {
  font-size: 17px;
}

.player-card span,
.tx-meta,
.tx-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.tx {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.tx-amount {
  font-weight: 900;
  white-space: nowrap;
}

.tx-amount.income {
  color: var(--success);
}

.tx-amount.expense {
  color: var(--danger);
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(120px);
  width: min(calc(100% - 32px), 460px);
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 760;
  box-shadow: var(--shadow);
  transition: transform 160ms ease;
  z-index: 10;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .ghost {
    flex: 1;
  }

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

  .grid.two,
  .setup-row {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .row.compact {
    width: 100%;
  }
}
