/* ===== Admira Balou Ballone — Design System ===== */
:root {
  /* Admira Brand */
  --admira-blue: #1E5BA8;
  --admira-blue-dark: #154078;
  --admira-blue-darker: #0E2C56;
  --admira-blue-light: #5BAEE0;
  --admira-blue-pale: #E8F1FA;
  --admira-blue-tint: #F4F8FC;

  /* Neutrals (cool / blue-leaning) */
  --ink-900: #0A2540;
  --ink-700: #2A4360;
  --ink-500: #5C7290;
  --ink-400: #8497B0;
  --ink-300: #B8C4D6;
  --ink-200: #D7DEE9;
  --ink-100: #ECEFF5;
  --ink-50:  #F6F8FB;
  --paper:   #FFFFFF;

  /* Semantic */
  --success: #2E9F5C;
  --warn:    #D97706;
  --danger:  #C0392B;

  /* Surfaces */
  --bg: var(--ink-50);
  --surface: var(--paper);
  --surface-2: var(--ink-50);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --text-soft: var(--ink-400);

  --primary: var(--admira-blue);
  --primary-hover: var(--admira-blue-dark);
  --primary-pale: var(--admira-blue-pale);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.06);
  --shadow-md: 0 4px 12px rgba(10, 37, 64, 0.08);
  --shadow-lg: 0 12px 32px rgba(10, 37, 64, 0.10);
  --shadow-xl: 0 24px 64px rgba(10, 37, 64, 0.14);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --admira-blue: #4A8DD6;
  --admira-blue-dark: #2E6BB5;
  --admira-blue-light: #7CC4F5;
  --admira-blue-pale: #1A2E4A;
  --admira-blue-tint: #14233A;

  --ink-900: #ECEFF5;
  --ink-700: #C5CFDD;
  --ink-500: #8497B0;
  --ink-400: #6B7E96;
  --ink-300: #3A4B65;
  --ink-200: #2A3A52;
  --ink-100: #1A2638;
  --ink-50:  #11192A;
  --paper:   #161F33;

  --bg: #0B1322;
  --surface: #161F33;
  --surface-2: #11192A;
  --border: #2A3A52;
  --border-strong: #3A4B65;
  --text: #ECEFF5;
  --text-muted: #8497B0;
  --text-soft: #6B7E96;

  --primary: #4A8DD6;
  --primary-hover: #6BA5E5;
  --primary-pale: #1A2E4A;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.6);
}

[data-theme="light-blue"] {
  --bg: #EAF2FB;
  --surface: #FFFFFF;
  --surface-2: #F4F8FC;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--ink-100); border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--ink-100); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: rgba(192,57,43,0.08); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--r-sm); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; }

/* ===== Inputs ===== */
.input, .select {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.input-sm { height: 34px; font-size: 13px; padding: 0 10px; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-pad-lg { padding: 28px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-pale);
  color: var(--primary);
}

/* ===== Layout ===== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.sidebar-brand-text .t1 { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.sidebar-brand-text .t2 { font-size: 15px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.12s;
}
.nav-item:hover { background: var(--ink-100); color: var(--text); }
.nav-item.active {
  background: var(--primary-pale);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 8px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Mobile Tab Bar ===== */
.mobile-topbar {
  display: none;
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .mobile-topbar img { width: 28px; height: 28px; }
  .mobile-topbar h1 { font-size: 16px; margin: 0; flex: 1; }

  .mobile-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
  }
  .mobile-tab.active { color: var(--primary); }
}

.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 37, 64, 0.35);
  z-index: 40;
}
.mobile-menu {
  position: fixed;
  top: 56px;
  right: 10px;
  left: 10px;
  max-width: 360px;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

/* ===== Main ===== */
.main {
  padding: 28px 32px 64px;
  max-width: 1400px;
  width: 100%;
  min-width: 0;
}
@media (max-width: 900px) {
  .main { padding: 16px 16px 96px; }
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 4px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}
.login-hero {
  background: linear-gradient(135deg, var(--admira-blue) 0%, var(--admira-blue-dark) 60%, var(--admira-blue-darker) 100%);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(91,174,224,0.25) 0%, transparent 50%);
  pointer-events: none;
}
.login-hero-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}
.login-hero-top img { width: 56px; height: 56px; }
.login-hero-content {
  position: relative;
  z-index: 1;
}
.login-hero-content h1 {
  font-size: 42px;
  line-height: 1.05;
  margin: 0 0 16px;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.login-hero-content p {
  font-size: 17px;
  line-height: 1.5;
  opacity: 0.85;
  max-width: 460px;
  margin: 0;
}
.login-hero-meta {
  position: relative;
  display: flex;
  gap: 32px;
  font-size: 13px;
  opacity: 0.7;
}
.login-hero-meta b { font-weight: 600; opacity: 1; display: block; font-size: 22px; margin-bottom: 2px; }

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}
.login-form {
  width: 100%;
  max-width: 380px;
}
.login-form h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.login-form .sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.profile-pick {
  display: grid;
  gap: 8px;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.profile-card:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
}
.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.profile-info {
  flex: 1;
}
.profile-name {
  font-weight: 600;
  font-size: 14px;
}
.profile-role {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Stats ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Player Pool ===== */
.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  transition: all 0.12s;
  flex-wrap: wrap;
}
.player-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.player-row.is-inactive { opacity: 0.55; background: var(--ink-50); }
.player-row.is-inactive .player-name { text-decoration: line-through; text-decoration-color: var(--text-soft); }
.player-main { flex: 1; min-width: 140px; }

/* Toggle switch — thumb-friendly */
.switch {
  flex-shrink: 0;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: var(--ink-300);
  padding: 3px;
  display: inline-flex;
  align-items: center;
  transition: background 0.18s ease;
  cursor: pointer;
}
.switch.on { background: var(--primary); }
.switch-knob {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.18s ease;
}
.switch.on .switch-knob { transform: translateX(20px); }
.player-num {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
  text-align: center;
}
.player-name {
  font-weight: 600;
  font-size: 14px;
}
.player-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.player-team-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ink-100);
  color: var(--text-muted);
}
.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ===== Teams Grid ===== */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.team-card-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.team-letter {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.team-name-input {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  width: 100%;
  outline: none;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 4px;
}
.team-name-input:focus { background: var(--ink-100); }

.team-coach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--ink-50);
}
.team-coach-icon { display: inline-flex; flex-shrink: 0; }
.team-coach-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 5px 9px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.team-coach-input::placeholder { color: var(--text-soft); }
.team-coach-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-pale); }

.team-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--surface);
  outline: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
}

.team-roster {
  padding: 8px 8px 12px;
  min-height: 100px;
}
.team-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  font-style: italic;
}
.team-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--r-sm);
  cursor: grab;
  user-select: none;
}
.team-player:hover { background: var(--ink-100); }
.team-player.dragging { opacity: 0.4; }
.team-player.movable { cursor: pointer; }
.team-player.movable:hover { background: var(--primary-pale); }

/* ===== Tap-to-assign (mobile-friendly team building) ===== */
.assign-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.assign-bar-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.assign-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.assign-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px 0 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.12s;
}
.assign-chip:hover { border-color: var(--text-muted); }
.assign-chip.active {
  background: var(--primary-pale);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.assign-chip-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.assign-chip-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assign-chip-count {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink-100);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.assign-chip.active .assign-chip-count { background: var(--primary); color: #fff; }

.pool-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pool-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px 6px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--ink-50);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.12s;
}
.pool-chip:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-pale); }
.pool-chip:active:not(:disabled) { transform: scale(0.97); }
.pool-chip:disabled { opacity: 0.55; }
.pool-chip-add {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.team-letter-btn { border: none; cursor: pointer; padding: 0; transition: transform 0.1s; }
.team-letter-btn:hover { transform: scale(1.06); }
.team-card.is-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-pale);
}

/* ===== Color picker ===== */
.color-popover {
  position: absolute;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  width: 220px;
}
.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.color-swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  outline: 1px solid rgba(0,0,0,0.1);
}
.color-swatch.selected { border-color: var(--text); }
.color-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.color-input-row input[type="color"] {
  width: 36px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* ===== Settings sliders ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 700px) {
  .settings-grid { grid-template-columns: 1fr; }
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info {
  flex: 1;
}
.setting-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
}
.setting-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.stepper button {
  width: 36px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--text);
  font-weight: 600;
}
.stepper button:hover { background: var(--ink-100); }
.stepper input {
  width: 56px;
  height: 40px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--text);
}
.stepper input:focus { outline: none; background: var(--ink-100); }

/* ===== Matrix ===== */
.matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.view-tabs {
  display: inline-flex;
  background: var(--ink-100);
  padding: 3px;
  border-radius: var(--r-md);
  gap: 2px;
}
.view-tab {
  padding: 7px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
}
.view-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Segmented control (Spielerpool-Ansicht) */
.seg-control {
  display: inline-flex;
  background: var(--ink-100);
  padding: 3px;
  border-radius: var(--r-md);
  gap: 2px;
}
.seg-btn {
  padding: 7px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.matrix-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 720px;
}
.matrix-table th, .matrix-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
}
.matrix-table th {
  background: var(--ink-50);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  position: sticky;
  top: 0;
}
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table td:last-child, .matrix-table th:last-child { border-right: none; }
.matrix-table .col-name {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}
.matrix-table .col-num {
  color: var(--text-soft);
  font-size: 12px;
}
.matrix-cell-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  color: white;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}

/* Cards view */
.rounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.round-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.round-head {
  padding: 12px 16px;
  background: var(--ink-50);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.round-title {
  font-weight: 700;
  font-size: 15px;
}
.round-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.match-row:last-child { border-bottom: none; }
.match-field {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  width: 38px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.match-team {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}
.match-team.right { justify-content: flex-end; text-align: right; }
.match-vs {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 700;
}
.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}

.count-circle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.count-circle b { font-size: 12px; font-weight: 700; }
.count-circle i { font-size: 9px; font-style: normal; opacity: 0.85; font-weight: 600; }
.count-circle b + i { margin-top: 1px; }

/* ===== Heatmap ===== */
.heatmap-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 14px;
}
.heatmap {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.heatmap th, .heatmap td {
  padding: 0;
  text-align: center;
  vertical-align: middle;
}
.heatmap th.row-h {
  text-align: right;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 8px;
  height: 26px;
  white-space: nowrap;
}
.heatmap th.col-h {
  font-weight: 500;
  font-size: 10px;
  color: var(--text-muted);
  height: 60px;
  width: 26px;
}
.heatmap th.col-h span {
  display: inline-block;
  transform: rotate(-60deg);
  transform-origin: center;
  white-space: nowrap;
}
.heatmap td.cell {
  width: 26px;
  height: 26px;
  border: 1px solid var(--surface);
  font-size: 11px;
  font-weight: 600;
}
.heatmap td.diag {
  background: var(--ink-100);
}

/* ===== Player history cards ===== */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.history-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.history-mate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.history-mate-name {
  flex: 1;
  font-size: 13px;
}
.history-bar {
  height: 6px;
  background: var(--ink-100);
  border-radius: 3px;
  overflow: hidden;
  flex: 0 0 80px;
}
.history-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}
.history-count {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 14px;
  text-align: right;
  color: var(--text);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text);
}
.empty-state p {
  margin: 0 0 16px;
  font-size: 14px;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 37, 64, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Logo position variants ===== */
[data-logo-pos="header"] .sidebar-brand { /* default */ }
[data-logo-pos="floating"] .sidebar-brand img { width: 44px; height: 44px; }
[data-logo-pos="hidden"] .sidebar-brand img { display: none; }

/* Section headers */
.section-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
  gap: 12px;
}
.section-h h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section-h .section-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Drag indicator */
.dragging-over {
  background: var(--primary-pale) !important;
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}

.checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Admin / classes / inventory ===== */
.class-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.class-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--primary-pale);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.class-switch.switchable {
  transition: background 0.12s, border-color 0.12s;
}
.class-switch.switchable:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}
.class-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: grid;
  gap: 2px;
}
.class-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.class-menu-item:hover { background: var(--ink-100); }
.class-menu-item.active { background: var(--primary-pale); font-weight: 600; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.chip-toggle {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.12s;
}
.chip-toggle.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.inv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.inv-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-pale);
  color: var(--primary);
  flex-shrink: 0;
}
.inv-handle { cursor: grab; }
.inv-count-ro {
  min-width: 56px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}.inv-handle:active { cursor: grabbing; }
.inv-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.inv-move {
  width: 26px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.1s;
}
.inv-move:hover:not(:disabled) { background: var(--ink-100); color: var(--text); border-color: var(--text-muted); }
.inv-move:disabled { opacity: 0.3; cursor: not-allowed; }
.inv-row.dragging { opacity: 0.4; }
.inv-row.drop-target { border-color: var(--primary); box-shadow: 0 -2px 0 var(--primary) inset; }

/* ===== Inventur-Verlauf (audit trail) ===== */
.inv-change-list { display: grid; gap: 6px; }
.inv-change {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; padding: 7px 10px;
  border-radius: 8px; background: var(--ink-50);
  border: 1px solid var(--border);
}
.inv-change-base { color: var(--text-muted); font-size: 13px; background: transparent; border-style: dashed; }
.inv-tag {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em;
}
.inv-tag-add { background: rgba(6,167,125,0.14); color: #06845f; }
.inv-tag-del { background: rgba(230,57,70,0.13); color: #c5303b; }
.inv-tag-chg { background: rgba(30,91,168,0.12); color: var(--primary); }
.inv-change-nums { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.inv-delta {
  flex-shrink: 0; min-width: 38px; text-align: right;
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px;
}
.inv-delta-up { color: #06845f; }
.inv-delta-down { color: #c5303b; }
.inv-snapshot {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: grid; gap: 2px;
}
.inv-snapshot-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 5px 6px; border-radius: 6px;
}
.inv-snapshot-row:nth-child(odd) { background: var(--ink-50); }
.inv-snapshot-count {
  font-family: var(--font-mono); font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text);
  min-width: 40px; text-align: right;
}

/* ===== Jahresplan ===== */
.jp-input {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.jp-input:hover { border-color: var(--border); }
.jp-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 2px var(--primary-pale); }
.jp-zyklus { text-align: center; width: 52px; }
.jp-past {
  color: var(--danger);
  font-weight: 700;
  background: rgba(192,57,43,0.07);
}
[data-theme="dark"] .jp-past { background: rgba(192,57,43,0.18); }.jp-trainer-h {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  height: 70px;
  font-size: 11px !important;
  padding: 6px 2px !important;
}
.jp-att {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
}
.jp-att:hover { border-color: var(--text-muted); }
.jp-att.present { background: var(--primary); border-color: var(--primary); color: #fff; }
.jp-att.cancelled { background: rgba(217,119,6,0.14); border-color: var(--warn); color: var(--warn); }
.jp-table td { padding: 4px 6px; }
.jp-einheit-btn {
  text-align: left;
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.jp-einheit-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.jp-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.jp-lineup-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.jp-lineup-btn:hover { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); }
.lineup-teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.lineup-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--ink-100);
  font-size: 13px;
  cursor: grab;
  user-select: none;
}
.lineup-chip:active { cursor: grabbing; }
.lineup-chip-add { display: none; margin-left: 2px; font-weight: 800; color: var(--primary); }

/* Mobile tap-to-assign target bar inside the Aufstellung modal — desktop keeps drag & drop */
.lineup-target-bar { display: none; }
@media (max-width: 900px) {
  .lineup-target-bar { display: block; }
  .lineup-target-bar .assign-bar { flex-direction: column; align-items: stretch; }
  .lineup-target-bar .assign-chips { width: 100%; }
  .lineup-chip { padding: 10px 14px; font-size: 15px; }
  .lineup-chip .lineup-chip-add { display: inline; }
  .team-player.movable { cursor: pointer; }
  .team-player.movable:active { background: var(--primary-pale); }
}
@media print {
  .sidebar, .mobile-topbar, .mobile-tabs, .matrix-toolbar button { display: none !important; }
  .main { padding: 0 !important; }
}

/* helpers */
.row { display: flex; align-items: center; gap: 8px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.muted { color: var(--text-muted); }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }

/* ===== Mobile usability refinements ===== */
/* Keep wide tables inside their scroll containers, never the whole page */
.matrix-table-wrap, .heatmap-wrap { max-width: 100%; }

/* Modals never exceed the screen — body scrolls instead of clipping */
.modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
}
.modal-body { overflow-y: auto; }

/* Toast lifts above the bottom tab bar on phones */
@keyframes toastUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  /* Prevent iOS auto-zoom on focus by keeping control text ≥ 16px */
  .input, .select, .input-sm, .jp-input, .team-coach-input,
  .team-name-input, .stepper input, textarea,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="date"], input[type="number"], input[type="search"] {
    font-size: 16px;
  }
  /* Tighter page headers + titles for narrow screens */
  .page-title { font-size: 23px; }
  .page-header { margin-bottom: 18px; }
  /* Segmented toggles a touch taller for thumbs */
  .view-tab { padding: 9px 14px; }

  /* Safe-area aware chrome */
  .mobile-topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .mobile-menu { top: calc(60px + env(safe-area-inset-top)); }

  /* Toast clears the fixed bottom tab bar and spans the width */
  .toast {
    bottom: calc(74px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    transform: none;
    text-align: center;
    animation: toastUp 0.3s ease;
  }
}

@media (max-width: 560px) {
  /* Action buttons in modals stack/grow instead of overflowing */
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  /* Player row: the team dropdown gets its own full-width line */
  .player-row > .select { flex: 1 1 100% !important; width: 100% !important; order: 9; }
}
