:root {
  --primary: #18181b;         /* TTC Altdorf Wappen Schwarz / Anthrazit */
  --primary-hover: #27272a;
  --primary-light: #f4f4f5;
  --accent: #dc2626;          /* Klassisches Tischtennis Wettkampf-Rot */
  --accent-hover: #b91c1c;
  --accent-light: #fef2f2;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --success: #15803d;
  --success-light: #dcfce7;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 80px; /* Platz für mobile Navigationsleiste */
}

/* Header */
header.app-header {
  background-color: #18181b;
  color: white;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 2px solid #27272a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.app-header-logo {
  height: 44px;
  width: auto;
  background: white;
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: block;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.2;
  color: white;
  margin: 0;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .header-title {
    font-size: 1.15rem;
    letter-spacing: 0.5px;
  }
}

.header-subtitle {
  font-size: 0.72rem;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.2s;
}

@media (min-width: 640px) {
  .header-actions {
    gap: 8px;
  }
  .header-btn {
    padding: 7px 12px;
    font-size: 0.85rem;
  }
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
}

@media (max-width: 639px) {
  .hide-on-mobile {
    display: none !important;
  }
}

/* Container */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 10px;
}

@media (min-width: 640px) {
  .container {
    padding: 14px;
  }
}

/* View Switcher Tabs (Desktop & Tablet) */
nav.desktop-nav {
  display: none;
  background: white;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

@media (min-width: 640px) {
  nav.desktop-nav {
    display: flex;
  }
  body {
    padding-bottom: 20px;
  }
}

.nav-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-tab.active {
  background: #18181b;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Bottom Navigation (Mobile) */
nav.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px)) 0;
  z-index: 50;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
}

.mobile-tab.active {
  color: #18181b;
  font-weight: 700;
}

@media (min-width: 640px) {
  nav.mobile-nav {
    display: none;
  }
}

.mobile-tab {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
}

.mobile-tab span.icon {
  font-size: 1.25rem;
}

/* Workflow Hero Card (TTC Altdorf Design) */
.workflow-hero-card {
  background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
  color: white;
  border: 1px solid #3f3f46;
  position: relative;
  overflow: hidden;
}

.workflow-card-logo {
  height: 96px;
  width: auto;
  background: white;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: none;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .workflow-card-logo {
    display: block;
  }
}

.btn-hero {
  background: #ffb300;
  color: #111111;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(255, 179, 0, 0.35);
  transition: transform 0.15s, background-color 0.15s;
  width: 100%;
}

@media (min-width: 640px) {
  .btn-hero {
    width: auto;
    font-size: 1rem;
    padding: 12px 22px;
  }
}

.btn-hero:hover {
  background: #ffa000;
  transform: translateY(-1px);
}

/* Club Banner Card */
.club-banner-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  .club-banner-card {
    flex-direction: column;
    text-align: center;
  }
}

.club-banner-logo {
  height: 68px;
  width: auto;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  background: white;
  padding: 2px;
}

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

@media (min-width: 640px) {
  .card {
    padding: 14px;
  }
}

/* Form Controls */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

/* Aufstellungs-Auswahl: Auf Handy 2-zeilig (Typ oben volle Breite, Nummer + Sollstärke darunter 50/50) */
.team-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.team-select-typ {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .team-select-grid {
    display: flex;
    flex-wrap: nowrap;
  }
  .team-select-typ {
    flex: 2;
  }
  .team-select-nr,
  .team-select-soll {
    flex: 1;
  }
}

/* Aufstellungs-Aktionsbuttons: Auf Handy sauberes 2x2-Raster */
.team-toolbar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.team-toolbar-grid .btn {
  width: 100%;
  font-size: 0.82rem;
  padding: 8px 6px;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .team-toolbar-grid {
    display: flex;
    flex-wrap: wrap;
  }
  .team-toolbar-grid .btn {
    width: auto;
    font-size: 0.85rem;
    padding: 8px 14px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 100px;
}

.form-group label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

select, input[type="text"], input[type="number"], input[type="date"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

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

/* Summary Banner */
.summary-banner {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--success-light);
  border: 1px solid #a5d6a7;
  color: var(--success);
}

.summary-banner.warn {
  background: var(--warning-light);
  border-color: #ffe082;
  color: var(--warning);
}

/* Player Item List */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 10px;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.player-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.player-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  padding-left: 30px;
  border-top: 1px dashed #e2e8f0;
}

.player-ttr-meta {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .player-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 14px;
  }
  .player-row-main {
    flex: 1;
    gap: 10px;
  }
  .player-row-bottom {
    padding-top: 0;
    padding-left: 0;
    border-top: none;
    gap: 14px;
    flex-shrink: 0;
  }
}

.player-item.violation {
  border-color: #ef9a9a;
  background-color: var(--danger-light);
}

.player-item.dragging {
  opacity: 0.4;
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.player-item.drag-over {
  border: 2px solid var(--primary);
  background-color: #e8f5e9;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.2);
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 2px 4px;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.drag-handle:hover {
  color: var(--primary);
  background: var(--bg);
}

.drag-handle:active {
  cursor: grabbing;
}

.player-pos {
  font-weight: 800;
  font-size: 0.98rem;
  width: 22px;
  text-align: center;
  color: var(--primary);
  flex-shrink: 0;
}

.player-details {
  flex: 1;
  min-width: 0;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.3;
  word-break: break-word;
}

.player-violation-hint {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 2px;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-sbe {
  background: #e1bee7;
  color: #6a1b9a;
}

.badge-spv {
  background: #ffcdd2;
  color: #b71c1c;
}

.badge-sub {
  background: #e0e0e0;
  color: #424242;
}

.badge-pos {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  text-transform: none;
}

.player-ttr {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
}

/* Quick Action Buttons per Item */
.item-actions {
  display: flex;
  gap: 5px;
}

.btn-icon {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 34px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}

.btn-icon:hover {
  background: var(--bg);
}

.btn-icon.danger {
  color: var(--danger);
  border-color: #ffcdd2;
}

.btn-icon.danger:hover {
  background: var(--danger-light);
}

/* Spieler-Verwaltung Responsive (Desktop Tabelle vs. Mobile Karten) */
.spieler-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.spieler-search-group {
  width: 100%;
}

.spieler-actions-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

@media (min-width: 640px) {
  .spieler-filter-bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .spieler-search-group {
    flex: 1;
    max-width: 380px;
  }
  .spieler-actions-group {
    width: auto;
  }
}

.desktop-spieler-table {
  display: none;
}

.mobile-spieler-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 640px) {
  .desktop-spieler-table {
    display: block;
  }
  .mobile-spieler-list {
    display: none;
  }
}

.mobile-spieler-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-spieler-card.inaktiv {
  opacity: 0.68;
  background: #f8fafc;
}

.msc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.msc-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text);
}

.msc-ttr {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--accent);
  white-space: nowrap;
}

.msc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #475569;
}

.msc-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.msc-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

/* Buttons */
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

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

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #b71c1c;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #333333;
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, bottom 0.25s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  bottom: 90px;
}

@media (min-width: 640px) {
  .toast {
    bottom: 24px;
  }
  .toast.show {
    bottom: 34px;
  }
}

/* Login Screen Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.25s ease-out;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  padding: 28px 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.login-header {
  margin-bottom: 22px;
}

.login-logo {
  height: 64px;
  width: auto;
  border-radius: 10px;
  background: white;
  padding: 3px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  margin-bottom: 12px;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  width: 100%;
  padding-right: 42px;
  font-size: 1rem;
}

.btn-toggle-pw {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px;
  color: #64748b;
  border-radius: 6px;
}

.btn-toggle-pw:hover {
  background: #f1f5f9;
}

.login-remember-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 14px 0 18px 0;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.login-remember-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: left;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
}

.header-btn-logout {
  background: rgba(220, 38, 38, 0.25) !important;
  border-color: rgba(220, 38, 38, 0.5) !important;
}

.header-btn-logout:hover {
  background: rgba(220, 38, 38, 0.45) !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-mtt-card {
  max-width: 680px;
  width: 95%;
  height: 85vh;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

@media (max-width: 600px) {
  .modal-mtt-card {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
