/* ── Context Bar ── */
.context-bar {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}

.context-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
}

/* Chips containers inside context-row must also be flex */
#raceChips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.context-row::-webkit-scrollbar { display: none; }

/* Date chip (legacy, kept for reference — sidebar-date-chip in layout.css) */

/* Spelform dot (used in various contexts) */
.spelform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Race row — always visible, stable height so topbar doesn't jump */
#raceRow {
  min-height: 36px;
}

/* Race chip fade-in / fade-out */
@keyframes raceChipIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes raceChipOut { from { opacity: 1; } to { opacity: 0; } }

.race-chip-in  { animation: raceChipIn var(--enter-duration) var(--enter-easing) both; }
.race-chip-out { animation: raceChipOut 150ms ease both; pointer-events: none; }

/* Stagger the fade-in of each chip */
.race-chip-in:nth-child(1)  { animation-delay: 0ms; }
.race-chip-in:nth-child(2)  { animation-delay: 25ms; }
.race-chip-in:nth-child(3)  { animation-delay: 50ms; }
.race-chip-in:nth-child(4)  { animation-delay: 75ms; }
.race-chip-in:nth-child(5)  { animation-delay: 100ms; }
.race-chip-in:nth-child(6)  { animation-delay: 125ms; }
.race-chip-in:nth-child(7)  { animation-delay: 150ms; }
.race-chip-in:nth-child(8)  { animation-delay: 175ms; }
.race-chip-in:nth-child(9)  { animation-delay: 200ms; }
.race-chip-in:nth-child(10) { animation-delay: 225ms; }
.race-chip-in:nth-child(n+11) { animation-delay: 250ms; }

/* Race chips */
.race-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}
.race-chip:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-focus); }
.race-chip.active {
  color: var(--text);
  border-color: var(--border-focus);
  background: var(--bg-active);
}

.race-chip .game-indicator {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

/* Context info line */
.context-info {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 0;
}
.context-info span { margin-right: 12px; }

/* Separator */
.context-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Bet Slip Card ── */
.bet-slip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
  overflow: hidden;
}

.bet-slip-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.bet-slip-track {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-left: 8px;
}

.bet-slip-cost {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: auto;
}

.bet-slip-legs {
  padding: 8px 14px;
}

.bet-leg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}
.bet-leg:last-child { border-bottom: none; }

.bet-leg-label {
  width: 48px;
  font-weight: 500;
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: 12px;
}

.bet-leg-horses {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.horse-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.horse-num:hover { background: var(--bg-active); }
.horse-num.spik {
  background: var(--success);
  color: var(--text-inverse);
  border-color: transparent;
}

.bet-slip-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.btn-copy-ticket {
  padding: 5px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-copy-ticket:hover { background: var(--bg-active); }

/* ── Startlist table ── */
.startlist-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
  overflow: hidden;
}

.startlist-header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.startlist-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.startlist-table th {
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.3px;
}
.startlist-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.startlist-table tr:last-child td { border-bottom: none; }
.startlist-table tr:hover { background: var(--bg-hover); }

/* ── User picker modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn var(--enter-duration) var(--enter-easing);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 320px;
  max-width: 400px;
  animation: modalIn var(--enter-duration) var(--enter-easing);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.modal p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.user-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.15s;
}
.user-option:hover { background: var(--bg-hover); border-color: var(--border-focus); }

.user-option-name { font-weight: 500; font-size: 14px; }
.user-option-role { font-size: 12px; color: var(--text-dim); }

.picker-login-link {
  text-align: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.picker-login-link a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.picker-login-link a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ── Spelform badge ── */
.spelform-badge {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
}

/* ── No data state ── */
.no-data {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Date Dropdown ── */
.date-dropdown {
  /* positioned via JS (fixed, appended to body) to avoid overflow clipping */
  min-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 150;
  animation: dropdownIn var(--enter-duration) var(--enter-easing);
  overflow: hidden;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.date-dropdown-list {
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.date-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border-subtle);
}
.date-dropdown-item:last-child { border-bottom: none; }
.date-dropdown-item:hover { background: var(--bg-hover); }
.date-dropdown-item.selected {
  background: var(--bg-active);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.date-dropdown-item.today .date-dropdown-label {
  color: var(--text);
  font-weight: 600;
}

.date-dropdown-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 90px;
}

.date-dropdown-today-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: none;
  color: var(--accent);
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.date-dropdown-meetings {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.date-dropdown-meeting {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-raised);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.date-dropdown-meeting .spelform-badge {
  font-size: 9px;
  padding: 0 4px;
}

.date-dropdown-no-meetings {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

.date-dropdown-loading {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.date-dropdown-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.date-dropdown-footer:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ── Calendar Modal ── */
.calendar-modal {
  min-width: 500px;
  max-width: 540px;
  padding: 24px 28px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-title {
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
}

.calendar-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.calendar-nav:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-focus);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.calendar-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: none;
  padding: 4px 0;
  letter-spacing: 0.3px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  min-height: 280px;
}

.calendar-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  min-height: 64px;
}
.calendar-cell.empty { cursor: default; }
.calendar-cell:not(.empty):hover { background: var(--bg-hover); }
.calendar-cell.selected {
  background: var(--bg-active);
  outline: 1px solid var(--border-focus);
}

.calendar-cell-day {
  font-size: 13px;
  font-weight: 500;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: all 0.12s;
}
.calendar-cell.today .calendar-cell-day {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 700;
}
.calendar-cell.selected .calendar-cell-day {
  color: var(--text);
  font-weight: 700;
}

.calendar-cell-meetings {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 2px;
  width: 100%;
  overflow: hidden;
}

.calendar-cell-track {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  line-height: 1.3;
}

.calendar-cell-more {
  font-size: 9px;
  color: var(--text-dim);
}

.calendar-cell.has-meetings .calendar-cell-day {
  color: var(--text);
}
.calendar-cell.today.has-meetings .calendar-cell-day {
  color: var(--text-inverse);
}

.calendar-loading {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* calendar-footer and calendar-today-btn removed — no longer used */

/* ── Race Card ── */
/* Context card (auto-injected race card on tab click) */
.message.context-card {
  margin-bottom: 16px;
  padding: 0;
  gap: 0;
  display: block;
  animation: messageIn var(--enter-duration) var(--enter-easing);
}
.message.context-card .race-card {
  margin-top: 0;
}

.race-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
  overflow: hidden;
}
/* ── Analysator loading animation ── */
.az-loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 12px;
}
.az-loading-icon {
  animation: az-pulse 1.2s ease-in-out infinite;
}
@keyframes az-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.az-loading-text {
  color: var(--text-muted);
  font-style: italic;
}

.race-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.race-card-number { font-weight: 700; }
.race-card-distance { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.race-card-right { margin-left: auto; display: inline-flex; align-items: baseline; gap: 4px; }
.race-card-track { display: inline-flex; align-items: baseline; gap: 4px; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.race-card-track .flag { align-self: center; }
.race-card-start { font-size: 10px; color: var(--text-dim); font-weight: 400; }
.race-card-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.race-card-table-wrap::-webkit-scrollbar { height: 2px; }
.race-card-table-wrap::-webkit-scrollbar-track { background: transparent; }
.race-card-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 1px; }
.race-card-table {
  width: 100%;
  min-width: 540px;
  font-size: 12px;
  border-collapse: collapse;
}
.race-card-table th {
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.3px;
}
/* Sortable headers */
.sortable-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 16px;
  transition: color .15s ease;
}
.sortable-table th[data-sort]:hover {
  color: var(--text);
}
.sortable-table th[data-sort]::after {
  content: '';
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  opacity: 0.25;
  border-top: 4px solid currentColor;
  margin-top: 2px;
}
.sortable-table th.sort-asc::after {
  opacity: 0.8;
  border-top: none;
  border-bottom: 4px solid currentColor;
  margin-top: -2px;
}
.sortable-table th.sort-desc::after {
  opacity: 0.8;
  border-top: 4px solid currentColor;
  border-bottom: none;
  margin-top: 2px;
}
.race-card-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
.race-card-table tr:last-child td { border-bottom: none; }
.race-card-table tr:hover { background: var(--bg-hover); }
.race-card-table tr.tillagg-separator { pointer-events: none; }
.race-card-table tr.tillagg-separator:hover { background: none; }
.race-card-table tr.tillagg-separator td {
  text-align: left;
  padding: 3px 10px;
  font-size: 0.7rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}
.race-card-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.race-card-analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.race-card-analyze-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}
.race-card-analyze-btn svg { opacity: 0.7; flex-shrink: 0; }
.race-card-analyze-hint {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
td.race-card-num { font-weight: 700; width: 28px; text-align: center; color: var(--text); }
td.race-card-horse { font-weight: 600; white-space: nowrap; color: var(--text); }
.race-card-trainer { }
.race-card-wr { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.race-card-wr-high { color: #2ecc71; font-weight: 600; }
td.race-card-wr-top { color: #5b9bd5; font-weight: 600; }
.race-card-mark { font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.race-card-shoe { text-align: center; }
.race-card-sulky { font-size: 11px; text-align: center; white-space: nowrap; }
.race-card-form { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.5px; }

/* Scratched entries — struck-through + dimmed */
tr.scratched-entry td { opacity: 0.4; text-decoration: line-through; text-decoration-color: var(--text-dim, #888); }
tr.scratched-entry td.race-card-num { text-decoration: none; } /* keep # readable */


/* Analyzer view — matches startlist table base (12px) */
.az-points { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.az-form { white-space: nowrap; }
td.az-form-toppform { color: #5b9bd5; font-weight: 600; }
td.az-form-uppåt { color: #2ecc71; font-weight: 600; }
td.az-form-stabil { color: var(--text-muted); }
td.az-form-nedåt { color: #e67e22; font-weight: 600; }
td.az-form-dålig { color: #e74c3c; font-weight: 600; }
.az-placerate { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.az-pr-good { color: #2ecc71; font-weight: 600; }
td.az-pr-top { color: #5b9bd5; font-weight: 600; }
.az-gallop { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.az-gallop-high { color: #e67e22; font-weight: 600; }
td.az-gallop-warn { color: #e74c3c; font-weight: 600; }
.az-interval { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.az-competition { white-space: nowrap; }
td.az-cl-elit { color: #5b9bd5; font-weight: 600; }
td.az-cl-hårt { color: var(--success, #2ecc71); font-weight: 600; }
td.az-cl-lätt { color: #e67e22; font-weight: 600; }
td.az-rank { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; text-align: center; color: var(--text-muted); padding: 0 10px; vertical-align: middle; line-height: 1; }
.az-rank-badge { display: inline-flex; align-items: center; justify-content: center; width: 1.15em; height: 1.15em; line-height: 1; text-align: center; border-radius: 2px; color: #111; font-weight: 700; font-size: 11px; }
.az-rank-1 { background: #2ecc71; }
.az-rank-2 { background: #a8e063; }
.az-rank-3 { background: #f1c40f; }
.az-ai-icon { color: #ffd700; margin-right: 2px; vertical-align: middle; }
.race-card-analyze-btn.active {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.race-card-analyze-btn.active:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* Shoe icons — horseshoe rotated 90° so toe points left */
.shoe-pair { display: inline-flex; gap: 2px; align-items: center; }
.shoe-icon { color: var(--text-muted); transform: rotate(90deg); }
.shoe-icon.shoe-off { color: var(--text-dim); }
.form-p1  { color: #2ecc71; font-weight: 700; }
.form-p2  { color: #a8e063; font-weight: 600; }
.form-p3  { color: #f1c40f; font-weight: 600; }
.form-gdk { color: #5a9a6a; }
.form-ejg { color: #e74c3c; }
.form-dim { color: var(--text-muted); }
.form-sep { color: var(--text-muted); opacity: 0.5; }

/* ── Race Card Horse Browser ── */
.race-card-browse { display: flex; min-height: 300px; animation: paneFadeIn var(--enter-duration) var(--enter-easing) both; }
.race-card-numbar { width: 40px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-raised); }
.race-card-numbar-item { display: flex; align-items: center; justify-content: center; padding: 8px 0; font-size: 12px; font-weight: 700; color: var(--text-dim); cursor: pointer; border-bottom: 1px solid var(--border-subtle); }
.race-card-numbar-item:hover { background: var(--bg-hover); color: var(--text); }
.race-card-numbar-item.active { background: var(--bg-active); color: var(--accent); border-left: 2px solid var(--accent); }
.race-card-detail { flex: 1; min-width: 0; animation: paneFadeIn var(--enter-duration) var(--enter-easing) both; }
.race-card-detail-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
.race-card-back { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); display: flex; align-items: center; }
.race-card-back:hover { background: var(--bg-hover); color: var(--text); }
.race-card-detail-name { font-weight: 700; font-size: 15px; }
.race-card-detail .horse-detail-content { border: none; border-radius: 0; }

/* ── Race Result View ── */
.race-result-badge {
  margin-left: auto;
  background: var(--success);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0.3px;
}
.race-result-table th { text-align: left; }
.race-result-table th:nth-child(4),
.race-result-table th:nth-child(5) { text-align: right; }
.race-result-top3 { background: rgba(255,255,255,0.035); }
.race-result-place {
  font-weight: 700;
  width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.race-result-p1 { color: #2ecc71; }
.race-result-p2 { color: #a8e063; }
.race-result-p3 { color: #f1c40f; }
.race-result-divider td { border-bottom: 2px solid var(--border) !important; }
.race-result-out td { color: var(--text-dim); }
.race-result-withdrawn td { color: var(--text-dim); font-style: italic; }
.race-result-time {
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.race-result-prize {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 11px;
}
.race-result-prize-top { font-weight: 600; }

/* ── Verified Data Badges ── */
.verified-badge {
  position: relative;
  cursor: help;
  font-weight: 600;
}
.verified-badge::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.verified-badge:hover::after { opacity: 1; }

/* ── Performance Chart ── */
.perf-chart {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
  overflow: hidden;
}
.perf-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.perf-chart-title { font-size: 13px; font-weight: 600; }
.perf-chart-count { font-size: 11px; color: var(--text-dim); }
.perf-chart-line-body {
  padding: 10px 14px 6px;
}
.perf-chart-line-body .horse-detail-line-chart {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Horse Clickable ── */
.horse-clickable {
  cursor: pointer;
  transition: color 0.15s;
}
.horse-clickable:hover {
  color: var(--accent);
  text-decoration: underline;
}
.person-clickable {
  cursor: pointer;
  transition: color 0.15s;
}
.person-clickable:hover {
  text-decoration: underline;
}
.person-detail-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-left: 8px;
}
/* ── Horse Detail Modal ── */
.horse-detail {
  max-width: 640px;
  width: 90vw;
  padding: 0;
  max-height: 85vh;
  overflow-y: auto;
}
.horse-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.horse-detail-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.horse-detail-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.horse-detail-close:hover { color: var(--text); }
.horse-detail-body { padding: 16px 20px; }
.horse-detail-loading {
  text-align: center;
  color: var(--text-dim);
  padding: 32px 0;
  font-size: 13px;
}
.horse-detail-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.hd-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.hd-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hd-meta-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.04em;
}
.hd-meta-sep {
  color: var(--text-dim);
  margin: 0 2px;
}
/* ── Segmented view toggle (Häst / Kusk / Tränare) ── */
.hd-view-toggles {
  display: inline-flex;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.hd-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.hd-view-toggle:hover { color: var(--text-muted); }
.hd-view-toggle.active {
  background: rgba(255,255,255,0.10);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.hd-tabs-name svg { width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; margin-right: 4px; }
/* ── View panes (Häst / Kusk / Tränare content) ── */
.race-card-view-pane { display: none; }
.race-card-view-pane.active { display: block; animation: paneFadeIn var(--enter-duration) var(--enter-easing) both; }
/* Keep pane tops aligned: identical padding on every feed-card-body inside panes */
.race-card-view-pane > .feed-card-body { padding: 12px 14px; }

/* Shared content fade — reused by analyzer, browse mode, view toggles */
@keyframes paneFadeIn { from { opacity: 0; } to { opacity: 1; } }
.pane-fade-in { animation: paneFadeIn var(--enter-duration) var(--enter-easing) both; }

.horse-detail-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.horse-detail-info-card strong {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.horse-detail-stat-card {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.horse-detail-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.horse-detail-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.horse-detail-stat-row span { color: var(--text-dim); }
.horse-detail-stat-row strong { color: var(--text); }
.horse-detail-section {
  margin-top: 12px;
}
.horse-detail-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
/* ── Info tab grid ── */
.hd-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
  padding: 4px 0 12px;
}
.hd-info-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.hd-info-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.hd-info-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}
.horse-detail-results {
  width: 100%;
  min-width: 520px;
  font-size: 12px;
  border-collapse: collapse;
}
.horse-detail-results th {
  text-align: left;
  padding: 5px 8px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.3px;
}
.horse-detail-results td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.horse-detail-results tr:hover { background: var(--bg-hover); }
.horse-detail-results td:first-child { white-space: nowrap; }
.horse-detail-prize { text-align: right; font-variant-numeric: tabular-nums; }

/* Kusk + trainer in same cell */
td.race-card-kusk { white-space: nowrap; vertical-align: middle; color: var(--text); }
.kusk-trainer-paren { color: var(--text-muted); font-size: 12px; }
.race-card-trainer, .hd-trainer-td {
  white-space: nowrap;
  vertical-align: middle;
}
.hd-trainer-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
  margin-right: 4px;
  vertical-align: middle;
}
.jersey-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}
.hd-trainer-line {
  width: 3px;
  height: 100%;
  min-height: 18px;
  border-radius: 2px;
  margin: 0 auto;
}

/* Game type chips */
.hd-game-col { white-space: nowrap; }
.hd-game-chip {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
/* .hd-game-* classes now injected dynamically by game-types.js */

.horse-detail-line-chart {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Horse Detail Tabs ── */
.hd-tabs {
  display: flex;
  gap: 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  min-height: 36px;       /* stable height across all views */
}
.hd-tabs-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 12px 6px 0;
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.hd-tab:hover { color: var(--text-muted); }
.hd-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.hd-tab-content { display: none; }
.hd-tab-content.active { display: block; }

/* ── Pedigree Tree ── */
.ped-tree {
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.ped-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ped-gen1 { flex: 3; }
.ped-gen2 { flex: 3; }
.ped-gen3 { flex: 4; }
.ped-span4, .ped-span2, .ped-span1 {
  display: flex;
  align-items: center;
}
.ped-span4 { flex: 4; }
.ped-span2 { flex: 2; }
.ped-span1 { flex: 1; }
.ped-cell {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ped-father > .ped-cell {
  border-left: 3px solid var(--info);
}
.ped-mother > .ped-cell {
  border-left: 3px solid #c45ba0;
}
.ped-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ped-record {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}
.ped-empty {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-dim);
  font-size: 11px;
}

/* ── Feed Card (inline detail cards in chat feed) ── */
.feed-card {
  margin-bottom: 16px;
  padding: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: messageIn var(--enter-duration) var(--enter-easing);
}
.feed-card-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  position: relative;
  padding: 6px 10px;
  min-height: 40px;       /* stable height — no jump on view toggle */
  border-bottom: 1px solid var(--border);
}
.feed-card-header .race-card-back {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.feed-card-close { display: none; }
.feed-card-body { padding: 12px 14px; }
.feed-card-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  padding: 32px 0;
  font-size: 13px;
}
.inline-loader-text {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.3px;
  min-height: 1em;
}

/* Visa fler expand button */
.visa-fler-wrap { text-align: center; padding: 10px 0; }
.btn-visa-fler {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-visa-fler:hover {
  background: var(--bg-active);
  color: var(--text);
  border-color: var(--border-focus);
}

/* ── Auth tabs (register/login toggle) ── */
/* ── Auth modal ── */
.auth-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 360px;
  max-width: 92vw;
  overflow: hidden;
  animation: modalIn var(--enter-duration) var(--enter-easing);
  position: relative;
}
.auth-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
  padding: 4px;
}
.auth-close:hover { color: var(--text); }
.auth-tabs {
  display: flex;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s;
  text-align: center;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--accent); }
.auth-tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 50%;
  height: 2px;
  background: var(--accent);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-slider {
  overflow: hidden;
}
.auth-slide-track {
  display: flex;
  width: 200%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-pane {
  width: 50%;
  flex-shrink: 0;
  padding: 24px 28px 28px;
  box-sizing: border-box;
}
.auth-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* ── Form fields ── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: none;
  letter-spacing: 0.3px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.form-group input::placeholder { color: var(--text-dim); }
.field-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px #ef4444 !important;
}
.form-error {
  font-size: 12px;
  color: #ef4444;
  min-height: 0;
  margin-bottom: 0;
}
.auth-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.btn-auth-primary {
  width: 70%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.btn-auth-primary:hover { background: var(--bg-active, #333); color: #fff; }
.btn-auth-primary:active { transform: scale(0.98); }
.btn-auth-primary:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn-auth-secondary {
  padding: 10px 16px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-auth-secondary:hover { background: var(--bg-hover); }

/* Auth terms checkbox */
.auth-terms {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.auth-terms input[type="checkbox"] {
  margin-top: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-panel);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.auth-terms input[type="checkbox"]:checked {
  background: var(--bg-panel);
  border-color: #6ecf6e;
}
.auth-terms input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 0;
  left: 2px;
  font-size: 12px;
  color: #6ecf6e;
  line-height: 16px;
}
.auth-terms a {
  color: var(--text-muted);
  text-decoration: none;
}
.auth-terms a:hover {
  text-decoration: underline;
}

/* Forgot password link */
.auth-forgot {
  text-align: center;
  margin-top: 12px;
}
.auth-forgot a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.auth-forgot a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Forgot password pane */
.auth-pane-forgot {
  padding-top: 8px;
}
.forgot-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}
.form-success {
  color: var(--success, #4caf50);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 4px;
}

/* Keep legacy btn classes for other uses */
.btn-primary {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-primary:hover { background: var(--bg-active, #333); color: #fff; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-cancel {
  padding: 7px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-cancel:hover { background: var(--bg-hover); }

/* ── Page Containers ── */
#pageSettings, #pageAdmin {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#pageChat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  width: 100%;
}
.sidebar-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-nav-item.active { background: var(--bg-active); color: var(--text); }
.sidebar-nav-item svg { flex-shrink: 0; opacity: 0.6; }
.sidebar-nav-item.active svg { opacity: 1; }

/* ── Settings Page ── */
.settings-page {
  height: 100%;
  overflow-y: auto;
  padding: 32px 20px;
}
.settings-inner {
  max-width: 600px;
  margin: 0 auto;
}
.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.settings-back {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.settings-back:hover { color: var(--text); }
.settings-admin-link { margin-left: auto; }
.settings-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 0;
  letter-spacing: -0.3px;
}
.settings-admin-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.settings-admin-link:hover {
  color: var(--text);
  text-decoration: underline;
}
.settings-section {
  margin-bottom: 28px;
}
.settings-section-title {
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 12px;
  text-transform: none;
  letter-spacing: 0.3px;
  color: var(--text-dim);
}
.settings-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.settings-profile-grid {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.settings-profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.settings-label { color: var(--text-dim); }
.settings-value { color: var(--text); font-weight: 500; }
.settings-usage-bar-wrap { padding-top: 8px; }
.settings-usage-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.settings-usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
  width: 0%;
}
.settings-brief {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.settings-brief:focus { border-color: var(--border-focus); }
.settings-brief-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.settings-brief-count { font-size: 12px; color: var(--text-dim); }
.settings-brief-save { min-width: 80px; }
.settings-brief-status {
  margin-top: 6px;
  font-size: 12px;
  min-height: 16px;
}
.settings-brief-status.success { color: var(--success); }
.settings-brief-status.error { color: var(--error); }

/* ── Admin Page ── */
.admin-page {
  height: 100%;
  overflow-y: auto;
  padding: 32px 20px;
}
.admin-inner {
  max-width: 800px;
  margin: 0 auto;
}

/* Admin Top Bar — Tabs + Save */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.admin-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}
.admin-tab {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 2px);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  background: var(--bg-panel);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.admin-save-btn {
  min-width: 80px;
  padding: 7px 20px;
  font-size: 13px;
  font-weight: 600;
}
.admin-save-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.admin-tab-pane { margin-bottom: 0; }

.admin-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.admin-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
.admin-list {
  display: flex;
  flex-direction: column;
}
.admin-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}
/* ── Admin Component Sections (flat, no card) ── */
.admin-component-section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.admin-component-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.admin-component-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.admin-component-label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-card-kind {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}
.admin-card-name {
  font-size: 14px;
  font-weight: 600;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: all 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle-input:checked + .toggle-slider {
  background: var(--success);
  border-color: var(--success);
}
.toggle-input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* Admin Preview */
.admin-preview {
  padding: 0;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}
.admin-preview.disabled {
  opacity: 0.35;
  pointer-events: none;
}
.admin-preview-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
}
.admin-preview .bet-slip,
.admin-preview .race-card,
.admin-preview .perf-chart {
  margin-top: 0;
}

/* Admin Trigger */
.admin-trigger-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-trigger-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  flex-shrink: 0;
}
.admin-trigger-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.admin-trigger-input:focus { border-color: var(--border-focus); }
.admin-trigger-status {
  font-size: 12px;
  flex-shrink: 0;
}
.admin-trigger-status.success { color: var(--success); }
.admin-trigger-status.error { color: var(--error); }

/* ── Admin Game Types (Spelformer) — compact grid ── */
.admin-gt-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.gt-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
  position: relative;
}
.gt-card:hover { border-color: var(--border-focus); }
.gt-card.gt-disabled { opacity: 0.4; }
.gt-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gt-color-picker {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}
.gt-color-picker::-webkit-color-swatch-wrapper { padding: 1px; }
.gt-color-picker::-webkit-color-swatch { border-radius: 2px; border: none; }
.gt-card-preview {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.gt-card-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gt-name-input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.gt-name-input:focus { border-color: var(--border-focus); }
.toggle-sm { width: 30px; height: 16px; flex-shrink: 0; }
.toggle-sm .toggle-slider::before { width: 10px; height: 10px; left: 2px; bottom: 2px; }
.toggle-sm .toggle-input:checked + .toggle-slider::before { transform: translateX(14px); }
.gt-btn-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
  opacity: 0;
}
.gt-card:hover .gt-btn-delete { opacity: 1; }
.gt-btn-delete:hover { color: var(--error); }

/* Add row — inline with grid */
.gt-add-card {
  background: var(--bg-raised);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
  min-height: 76px;
  justify-content: center;
}
.gt-add-card:hover { border-color: var(--border-focus); }
.gt-add-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gt-add-name {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  outline: none;
}
.gt-add-name:focus { border-color: var(--border-focus); }
.gt-add-name::placeholder { text-transform: none; font-weight: 400; }
.gt-add-btn {
  font-size: 11px;
  padding: 4px 10px;
  min-width: 0;
}
.gt-add-status {
  font-size: 10px;
  min-height: 12px;
}
.gt-add-status.success { color: var(--success); }
.gt-add-status.error { color: var(--error); }

/* ── Admin Trainer Colors (Tränare) ── */
.tc-search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.tc-search-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.tc-search-input:focus { border-color: var(--border-focus); }
.tc-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.tc-search-results:not(:empty) { display: block; }
.tc-search-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.tc-search-item:hover { background: var(--bg-hover); }
.tc-search-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.tc-list {
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tc-row:hover { border-color: var(--border-focus); }
.tc-jersey {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.tc-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.tc-color {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.tc-color:focus { border-color: var(--border-focus); }
.tc-color::-webkit-color-swatch-wrapper { padding: 1px; }
.tc-color::-webkit-color-swatch { border-radius: 2px; border: none; }
.tc-btn-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--error);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  transition: opacity 0.15s;
}
.tc-row:hover .tc-btn-delete { opacity: 1; }

/* ── Admin Models ── */
.ml-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 500px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.ml-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.ml-row:hover { border-color: var(--border-focus); }
.ml-row.ml-disabled { opacity: 0.5; }
.ml-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ml-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.ml-id {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ml-btn-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--error);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  transition: opacity 0.15s;
}
.ml-row:hover .ml-btn-delete { opacity: 1; }
.ml-add-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ml-add-input {
  flex: 1;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono, monospace);
}
.ml-add-input:focus { border-color: var(--border-focus); outline: none; }
.ml-add-btn {
  white-space: nowrap;
  font-size: 12px;
  padding: 7px 14px;
}
.ml-add-status {
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}
.ml-add-status.success { color: var(--success); }
.ml-add-status.error { color: var(--error); }

/* ── Quick actions admin editor ── */
.qa-group { margin-bottom: 24px; }
.qa-group-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle, var(--border));
}
.qa-group-items { display: flex; flex-direction: column; gap: 6px; }
.qa-row { display: flex; align-items: center; gap: 8px; }
.qa-slot {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.qa-label-input { width: 160px; }
.qa-query-input { flex: 1; }
.qa-input {
  padding: 6px 10px;
  background: var(--bg-input, var(--bg-panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans, inherit);
}
.qa-input:focus { outline: none; border-color: var(--border-focus); }

/* ── Settings Model Selector ── */
.settings-model-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-model-select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  min-width: 200px;
  cursor: pointer;
}
.settings-model-select:focus { border-color: var(--border-focus); outline: none; }
.settings-model-status {
  font-size: 12px;
  min-height: 16px;
}
.settings-model-status.success { color: var(--success); }
.settings-model-status.error { color: var(--error); }
/* ── Country toggles ── */
.settings-countries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-country-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.settings-country-toggle:hover { background: var(--bg-hover); }
.settings-country-name { font-size: 14px; color: var(--text); font-weight: 500; }
.settings-countries-status {
  font-size: 12px;
  min-height: 16px;
  margin-top: 4px;
}
.settings-countries-status.success { color: var(--success); }
.settings-countries-status.error { color: var(--error); }

.settings-logout-section {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.btn-logout {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ── Admin Countries ── */
.cl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, opacity 0.15s;
}
.cl-row:hover { border-color: var(--border-focus); }
.cl-row.cl-disabled { opacity: 0.45; }
.cl-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cl-code {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono, monospace);
  min-width: 24px;
  text-align: center;
}
.cl-toggle {
  margin-left: auto;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  /* Horse detail stat cards: stack vertically on small screens */
  .horse-detail-stats {
    flex-direction: column;
    gap: 8px;
  }
  .horse-detail-stat-card {
    flex: none;
    width: 100%;
    padding: 10px;
  }
  .horse-detail-stat-row {
    font-size: 11px;
    gap: 8px;
  }
  .horse-detail-stat-row strong {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 55%;
  }
  .horse-detail-stat-label {
    font-size: 10px;
    margin-bottom: 6px;
  }
  .horse-detail-body { padding: 12px 14px; }
  .horse-detail-section-title { font-size: 11px; }

  /* Info grid: single column on mobile */
  .hd-info-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Results table: smaller text, tighter padding */
  .horse-detail-results th { padding: 4px 5px; font-size: 10px; }
  .horse-detail-results td { padding: 3px 5px; font-size: 11px; }
  .horse-detail-results { min-width: 0; }

  /* Race card header: wrap gracefully */
  .race-card-header { flex-wrap: wrap; gap: 4px 8px; }

  /* Person detail stat cards (driver/trainer) */
  .person-detail-stats { flex-direction: column; }
}
