:root {
  --bg: #0f1420;
  --bg-elevated: #161d2e;
  --bg-elevated-2: #1d2740;
  --border: #2a3350;
  --text: #e8ecf6;
  --text-muted: #96a1c2;
  --accent: #1687d9;
  --accent-soft: rgba(22, 135, 217, 0.15);
  --positive: #2fbf71;
  --positive-soft: rgba(47, 191, 113, 0.15);
  --negative: #e2546b;
  --negative-soft: rgba(226, 84, 107, 0.15);
  --radius: 10px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover {
  text-decoration: none;
}
.brand .chip {
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.75rem;
}

.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
.nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
}
.nav a.active,
.nav a:hover {
  color: var(--text);
  text-decoration: none;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 20px;
}
h2 {
  font-size: 1.15rem;
  margin: 28px 0 12px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.tile .label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tile .value {
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--positive);
}
.negative {
  color: var(--negative);
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:last-child td {
  border-bottom: none;
}
tr.clickable {
  cursor: pointer;
}
tr.clickable:hover {
  background: var(--bg-elevated-2);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-bust { background: var(--negative-soft); color: var(--negative); }
.badge-itm { background: var(--accent-soft); color: var(--accent); }
.badge-final_table { background: var(--accent-soft); color: var(--accent); }
.badge-top_3 { background: var(--positive-soft); color: var(--positive); }
.badge-runner_up { background: var(--positive-soft); color: var(--positive); }
.badge-win { background: #f4c542; color: #4a3800; }

.tournament-id {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.copy-btn {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}
.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.copy-btn.copied {
  color: var(--positive);
  border-color: var(--positive);
}

/* --- calendar --- */
.calendar {
  border-collapse: collapse;
  width: 100%;
}
.calendar th {
  text-align: center;
  padding: 6px;
}
.calendar td {
  border: 1px solid var(--border);
  height: 64px;
  width: 14.28%;
  vertical-align: top;
  padding: 6px;
  font-size: 0.8rem;
}
.calendar td.empty {
  background: transparent;
  border: none;
}
.calendar td.has-sessions {
  cursor: pointer;
}
.calendar .day-num {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.calendar .day-net {
  margin-top: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calendar td.pos { background: var(--positive-soft); }
.calendar td.neg { background: var(--negative-soft); }
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.calendar-nav h2 {
  margin: 0;
}

/* --- filters / forms --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.filters select,
.filters input {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 0.88rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 20px;
}
.chart-card canvas {
  max-height: 420px;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.login-wrap {
  max-width: 360px;
  margin: 80px auto;
  padding: 0 20px;
}
.login-wrap form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-wrap input {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
}
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(1.08);
}
.errorlist {
  color: var(--negative);
  padding-left: 18px;
  font-size: 0.85rem;
}
