:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #283549;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #15803d;
  --primary-hover: #166534;
  --danger: #b91c1c;
  --plus: #22c55e;
  --minus: #ef4444;
  --zero: #94a3b8;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 1rem 0;
  padding-top: max(env(safe-area-inset-top), .5rem);
  padding-bottom: .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.logout-form { margin: 0; }
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  padding: .5rem .25rem;
}
.btn-link:hover { color: var(--text); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 49px;
  z-index: 9;
}
.tabs a {
  flex: 1;
  text-align: center;
  padding: .75rem .5rem;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.section { margin-bottom: 1.5rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
  gap: .5rem;
}
.empty { color: var(--text-muted); padding: 1rem 0; }
.hint { color: var(--text-muted); font-size: .875rem; margin: .5rem 0 0; }
.link-row { margin: .75rem 0 0; }

/* Buttons */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: .65rem 1rem;
  border-radius: var(--radius);
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}
.btn-secondary:hover { background: #324154; text-decoration: none; }
.btn-danger-link {
  background: none;
  border: none;
  color: var(--minus);
  font: inherit;
  cursor: pointer;
  padding: .5rem .25rem;
  font-size: .875rem;
}
.btn-danger-link:hover { text-decoration: underline; }

/* Bilanz */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
}
.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--zero);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.balance-card.plus { border-left-color: var(--plus); }
.balance-card.minus { border-left-color: var(--minus); }
.balance-name { font-weight: 600; font-size: .95rem; }
.balance-net {
  font-size: 1.5rem;
  font-weight: 700;
  margin: .15rem 0;
}
.balance-card.plus .balance-net { color: var(--plus); }
.balance-card.minus .balance-net { color: var(--minus); }
.balance-card.zero .balance-net { color: var(--zero); }
.balance-detail { color: var(--text-muted); font-size: .8rem; }

/* Expenses */
.expense-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.exp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.exp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
}
.exp-amount { font-size: 1.25rem; font-weight: 700; }
.exp-date { color: var(--text-muted); font-size: .875rem; }
.exp-club { font-weight: 600; margin-top: .15rem; }
.exp-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  margin-top: .35rem;
  font-size: .9rem;
  color: var(--text-muted);
}
.exp-meta b { color: var(--text); font-weight: 600; }
.exp-desc {
  margin-top: .35rem;
  font-size: .9rem;
  color: var(--text-muted);
  font-style: italic;
}
.exp-actions {
  margin-top: .5rem;
  text-align: right;
}

/* Weather */
.weather-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.weather-row {
  display: grid;
  grid-template-columns: 64px 48px 1fr auto;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
}
.weather-row.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset, var(--shadow);
}
.w-day { line-height: 1.15; }
.w-wd { font-weight: 700; font-size: 1rem; }
.w-date { color: var(--text-muted); font-size: .8rem; }
.w-icon {
  font-size: 1.75rem;
  text-align: center;
  line-height: 1;
}
.w-temp {
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
}
.t-max { color: var(--text); }
.t-min { color: var(--text-muted); }
.t-sep { color: var(--text-muted); margin: 0 .25rem; }
.w-rain {
  display: inline-flex;
  align-items: baseline;
  gap: .15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rain-icon { font-size: .9rem; margin-right: .15rem; }
.rain-pct { font-size: .8rem; font-weight: 500; margin-left: 1px; }
.rain-low  { color: var(--text-muted); }
.rain-mid  { color: #60a5fa; }
.rain-high { color: #3b82f6; }

.saying {
  margin-top: 1rem;
  padding: .9rem 1.1rem;
  background: linear-gradient(135deg, rgba(21,128,61,.18), rgba(21,128,61,.06));
  border: 1px solid rgba(21,128,61,.4);
  border-radius: var(--radius);
  font-style: italic;
  color: var(--text);
  font-size: .98rem;
  line-height: 1.45;
  text-align: center;
}
.saying-quote {
  color: var(--primary);
  font-weight: 700;
  font-style: normal;
  font-size: 1.2rem;
  vertical-align: -.05em;
  margin: 0 .15rem;
}

/* Forms */
.form, .form-inline {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.form-inline {
  flex-direction: row;
  align-items: stretch;
  gap: .5rem;
}
.form-inline input { flex: 1; }
.form label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-weight: 600;
  font-size: .9rem;
}
.form input[type="text"],
.form input[type="date"],
.form input[type="password"],
.form select,
.form-inline input {
  width: 100%;
  padding: .7rem .8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  min-height: 44px;
}
.form input:focus, .form select:focus, .form-inline input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.players-field {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem .8rem;
  background: var(--surface-2);
  margin: 0;
}
.players-field legend { padding: 0 .35rem; font-weight: 600; font-size: .9rem; }
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .9rem;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 500;
  cursor: pointer;
  padding: .35rem .25rem;
  min-height: 32px;
}
.check input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--primary);
}
.form-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* Listen (Spieler / Vereine) */
.list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: .4rem;
}
.row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}

/* Flash */
.flash {
  padding: .65rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.flash-success { background: #052e16; border-color: #166534; color: #bbf7d0; }
.flash-error   { background: #450a0a; border-color: #991b1b; color: #fecaca; }
.flash-info    { background: var(--surface); }

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.login-card h1 { text-align: center; margin-bottom: 1rem; }
.login-card form {
  display: flex; flex-direction: column; gap: .75rem;
}
.login-card label { font-weight: 600; font-size: .9rem; }
.login-card input {
  width: 100%;
  padding: .7rem .8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  min-height: 44px;
}
.login-card .btn-primary { width: 100%; margin-top: .25rem; }

@media (min-width: 600px) {
  .exp-meta { flex-direction: row; gap: 1rem; }
}
