:root {
  --bg: #0d1a0d;
  --surface: #162416;
  --surface-2: #1e321e;
  --border: #2a442a;
  --primary: #4caf50;
  --primary-dark: #388e3c;
  --primary-hover: #43a047;
  --gold: #ffc107;
  --red: #ef5350;
  --green: #66bb6a;
  --text: #e8f5e9;
  --text-dim: #a5d6a7;
  --text-muted: #6a9a6a;
  --danger: #c62828;
  --danger-hover: #b71c1c;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Nav ── */
#nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-dark); color: #fff; }

/* ── Main ── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

/* ── Page headings ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary-dark); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Forms ── */
.form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus { border-color: var(--primary); }

.form-group { flex: 1; min-width: 140px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Profit colors ── */
.profit-pos { color: var(--green); font-weight: 600; }
.profit-neg { color: var(--red); font-weight: 600; }
.profit-zero { color: var(--text-muted); }

/* ── Leaderboard ── */
.rank-1 td:first-child { color: var(--gold); font-weight: 700; }

.medal { font-size: 1.1rem; margin-right: 0.3rem; }

/* ── Status badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-open { background: #1b5e20; color: #a5d6a7; }
.badge-closed { background: #333; color: #aaa; }

/* ── Session list ── */
.session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  color: var(--text);
}

.session-card:hover { border-color: var(--primary); background: var(--surface-2); }

.session-info { display: flex; flex-direction: column; gap: 0.2rem; }
.session-name { font-weight: 600; }
.session-meta { font-size: 0.82rem; color: var(--text-muted); }

/* ── Login ── */
.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.login-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* ── Inline add form ── */
.add-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ── Totals row ── */
.totals-row td { font-weight: 600; color: var(--text-dim); border-top: 2px solid var(--border); }

/* ── Inline number inputs in table ── */
td input[type="number"] {
  width: 90px;
  padding: 0.3rem 0.5rem;
  font-size: 0.88rem;
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
}

.toast-success { background: #1b5e20; color: #c8e6c9; border-left: 3px solid var(--green); }
.toast-error   { background: #b71c1c; color: #ffcdd2; border-left: 3px solid var(--red); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── Section headings ── */
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #nav { height: auto; padding: 0.75rem 1rem; }
  .nav-links { gap: 0.1rem; }
  .nav-link { padding: 0.35rem 0.5rem; font-size: 0.85rem; }
  td input[type="number"] { width: 75px; }
}
