/* ==========================================================================
   Bauhaus Design System — Design Tokens
   ========================================================================== */

:root {
  /* Bauhaus Primary Triad */
  --red: #D42828;
  --blue: #1A3A8F;
  --yellow: #F2C12E;

  /* Neutrals */
  --black: #1A1A1A;
  --white: #F5F2EB;
  --warm-gray: #E8E4DB;
  --mid-gray: #706E68;
  --mid-gray-light: #B8B4AB;
  --dark-gray: #3A3A3A;

  /* Semantic */
  --correct: #2D8F3E;

  /* Tinted backgrounds */
  --bg-error: #FEF0F0;
  --bg-correct: #F0F7F1;
  --bg-pending: #FFFFF0;
  --bg-phase: rgba(242, 193, 46, 0.2);

  /* Legacy aliases for compatibility */
  --bg: var(--white);
  --bg-elevated: var(--white);
  --text: var(--black);
  --text-muted: var(--mid-gray);
  --text-faint: var(--mid-gray);
  --border: var(--mid-gray-light);
  --border-strong: var(--black);
  --card-bg: var(--white);
  --accent: var(--blue);
  --success: var(--correct);
  --warning: var(--yellow);
  --error: var(--red);
  --primary: var(--blue);

  /* Semantic colors (legacy compat) */
  --color-primary: var(--blue);
  --color-primary-hover: #223FA8;
  --color-success: var(--correct);
  --color-success-bg: var(--bg-correct);
  --color-success-border: var(--correct);
  --color-warning: var(--yellow);
  --color-warning-bg: var(--bg-pending);
  --color-warning-border: var(--yellow);
  --color-error: var(--red);
  --color-error-bg: var(--bg-error);
  --color-error-border: var(--red);
  --color-info: var(--blue);
  --color-info-bg: rgba(26, 58, 143, 0.08);
  --color-info-border: var(--blue);

  --color-slate-50: var(--warm-gray);
  --color-slate-100: var(--white);
  --color-slate-200: var(--warm-gray);
  --color-slate-300: var(--mid-gray-light);
  --color-slate-400: var(--mid-gray-light);
  --color-slate-500: var(--mid-gray);
  --color-slate-600: var(--dark-gray);
  --color-slate-700: var(--dark-gray);
  --color-slate-800: var(--black);
  --color-slate-900: var(--black);

  /* Phase Colors */
  --color-phase-opening: var(--blue);
  --color-phase-middlegame: var(--yellow);
  --color-phase-endgame: var(--dark-gray);
  --color-phase-unknown: var(--mid-gray);

  /* Tactical Pattern Colors */
  --color-tactic-fork: #ef4444;
  --color-tactic-pin: var(--mid-gray-light);
  --color-tactic-skewer: #06b6d4;
  --color-tactic-discovered: #f59e0b;
  --color-tactic-hanging: #ec4899;
  --color-tactic-back-rank: #10b981;
  --color-tactic-other: #6b7280;

  /* Difficulty Colors */
  --color-diff-easy: var(--blue);
  --color-diff-medium: #f59e0b;
  --color-diff-hard: #ef4444;
  --color-diff-unscored: #6b7280;

  /* Game Type Colors */
  --color-gametype-ultrabullet: var(--dark-gray);
  --color-gametype-bullet: var(--red);
  --color-gametype-blitz: #C4A826;
  --color-gametype-rapid: var(--blue);
  --color-gametype-classical: var(--correct);
  --color-gametype-correspondence: var(--mid-gray-light);

  /* Focus ring */
  --focus-ring: 0 0 0 2px rgba(26, 58, 143, 0.25);

  /* No shadows in Bauhaus */
  --shadow-sm: none;
  --shadow: none;
  --shadow-md: none;
  --shadow-lg: none;

  /* Spacing Scale (power-of-two, 4px base) */
  --s-xs: 4px;
  --s-sm: 8px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-2xl: 48px;

  /* Legacy spacing aliases */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* No border-radius — sharp corners everywhere */
  --radius-sm: 0;
  --radius: 0;
  --radius-md: 0;
  --radius-lg: 0;

  /* Typography */
  --font-ui: 'Jost', sans-serif;
  --font-sans: 'DM Sans', sans-serif;

  /* Letter-spacing scale */
  --ls-tight: 0;
  --ls-normal: 1px;
  --ls-wide: 2px;

  --text-xs: 0.6875rem;   /* 11px — micro labels, badges */
  --text-sm: 0.8125rem;   /* 13px — secondary text, captions */
  --text-base: 0.875rem;  /* 14px — body text */
  --text-lg: 1.0625rem;   /* 17px — sub-headings */
  --text-xl: 1.25rem;     /* 20px — section headings, stat values */
  --text-2xl: 1.375rem;   /* 22px — page titles */
  --text-3xl: 1.75rem;    /* 28px — hero text */

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition: 0.15s ease;
  --transition-slow: 0.25s ease;

  /* Board colors */
  --board-light: #E0E0E0;
  --board-dark: #A0A0A0;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--black);
  background: var(--white);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.3;
  color: var(--black);
  letter-spacing: var(--ls-tight);
}

h1 {
  font-size: var(--text-xl);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  margin-bottom: var(--s-lg);
}

h2 {
  font-size: var(--text-lg);
  letter-spacing: var(--ls-tight);
  text-transform: uppercase;
  margin-bottom: var(--s-md);
}

h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--s-sm);
}

p {
  margin: 0 0 var(--s-md);
  font-family: var(--font-sans);
}

.subtitle {
  margin: 0 0 var(--s-xl);
  color: var(--mid-gray);
  font-size: var(--text-base);
  font-family: var(--font-sans);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--s-lg) var(--s-lg);
}

/* ==========================================================================
   Navigation — Bauhaus style
   ========================================================================== */

nav {
  display: flex;
  gap: var(--s-sm);
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

nav a {
  text-decoration: none;
  color: var(--dark-gray);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: var(--text-sm);
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  padding: var(--s-sm) var(--s-md);
  transition: all 0.15s ease;
  border: none;
}

nav a:hover {
  color: var(--black);
  background: none;
  border-bottom: 2px solid var(--black);
  text-decoration: none;
}

nav a.active {
  color: var(--white);
  background: var(--black);
  border: none;
}

/* Top-right nav style */
.nav-top-right {
  position: static;
  display: flex;
  gap: var(--s-sm);
  border: none;
  padding: 0;
  margin: 0;
}

.nav-top-right a {
  padding: var(--s-sm) var(--s-md);
  border: none;
  background: none;
}

.nav-top-right a:hover {
  background: none;
  border-bottom: 2px solid var(--black);
}

/* ==========================================================================
   Cards — Bauhaus: no shadows, structural borders
   ========================================================================== */

.card {
  background: var(--white);
  border: none;
  border-top: 2px solid var(--black);
  border-radius: 0;
  padding: var(--s-lg) 0;
  box-shadow: none;
  margin-bottom: 0;
}

.card:last-child {
  border-bottom: 2px solid var(--black);
}

.card-header {
  margin-bottom: var(--s-md);
}

.card-title {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--black);
  margin: 0 0 var(--s-xs);
}

.card-description {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--mid-gray);
  margin: 0;
}

/* ==========================================================================
   Buttons — Bauhaus system
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  line-height: 1.5;
  border-radius: 0;
  border: 2px solid var(--black);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  background: transparent;
  color: var(--black);
}

.btn:hover:not(:disabled) {
  background: var(--black);
  color: var(--white);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary CTA (yellow) */
.btn-primary {
  background: var(--yellow);
  border: 2px solid var(--yellow);
  color: var(--black);
}

.btn-primary:hover:not(:disabled) {
  background: #E0B020;
  border-color: #E0B020;
  color: var(--black);
}

/* Secondary (outlined) */
.btn-secondary {
  background: transparent;
  color: var(--black);
  border: 2px solid var(--black);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--black);
  color: var(--white);
}

/* Success */
.btn-success {
  background: var(--correct);
  color: var(--white);
  border: 2px solid var(--correct);
}

.btn-success:hover:not(:disabled) {
  background: #247A33;
  border-color: #247A33;
}

/* Danger */
.btn-danger {
  background: var(--red);
  color: var(--white);
  border: 2px solid var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: #B81E1E;
  border-color: #B81E1E;
  color: var(--white);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--mid-gray);
  border: none;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 400;
  text-transform: none;
  letter-spacing: var(--ls-tight);
}

.btn-ghost:hover:not(:disabled) {
  background: transparent;
  color: var(--dark-gray);
}

/* Small Button */
.btn-sm {
  padding: var(--s-xs) var(--s-sm);
  font-size: var(--text-xs);
}

/* Button Row */
.btn-row {
  display: flex;
  gap: var(--s-sm);
  flex-wrap: wrap;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: var(--s-md);
}

label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--mid-gray);
  margin-bottom: var(--s-xs);
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: var(--s-sm) var(--s-sm);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--black);
  background: var(--white);
  border: 2px solid var(--black);
  border-radius: 0;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--black);
  cursor: pointer;
  border-radius: 0;
}

.help-text {
  margin-top: var(--s-xs);
  font-size: var(--text-xs);
  color: var(--mid-gray);
  font-family: var(--font-sans);
}

.section-divider {
  margin: var(--s-xl) 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th, td {
  padding: var(--s-sm) var(--s-md);
  text-align: left;
  border-bottom: 1px solid var(--warm-gray);
}

th {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--mid-gray);
  background: var(--white);
}

tr:hover td {
  background: var(--warm-gray);
}

/* ==========================================================================
   Alerts & Messages
   ========================================================================== */

.alert,
.message {
  padding: var(--s-md);
  border-radius: 0;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  margin-bottom: var(--s-md);
  display: none;
  border-left: 4px solid;
}

.alert.visible,
.message.visible {
  display: block;
}

.alert-success,
.message.success {
  background: var(--bg-correct);
  border-left-color: var(--correct);
  color: var(--black);
}

.alert-error,
.message.error {
  background: var(--bg-error);
  border-left-color: var(--red);
  color: var(--black);
}

.alert-warning {
  background: var(--bg-pending);
  border-left-color: var(--yellow);
  color: var(--black);
}

.alert-info {
  background: var(--color-info-bg);
  border-left-color: var(--blue);
  color: var(--black);
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.status {
  display: inline-flex;
  align-items: center;
  padding: var(--s-xs) var(--s-sm);
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
}

.status.pending {
  background: var(--bg-pending);
  color: var(--black);
}

.status.running {
  background: var(--color-info-bg);
  color: var(--blue);
}

.status.completed {
  background: var(--bg-correct);
  color: var(--correct);
}

.status.failed {
  background: var(--bg-error);
  color: var(--red);
}

/* ==========================================================================
   Progress Bars
   ========================================================================== */

.progress-bar {
  height: 8px;
  background: var(--warm-gray);
  border-radius: 0;
  overflow: hidden;
  margin-top: var(--s-sm);
}

.progress-fill {
  height: 100%;
  background: var(--correct);
  border-radius: 0;
  transition: width 0.3s ease;
}

.progress-text {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--mid-gray);
  margin-top: var(--s-xs);
}

/* ==========================================================================
   Stat Cards
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-md);
  margin-bottom: var(--s-lg);
}

.stat-card {
  background: var(--white);
  border: 2px solid var(--black);
  border-radius: 0;
  padding: var(--s-lg);
  box-shadow: none;
}

.stat-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--ls-normal);
  color: var(--dark-gray);
  margin-bottom: var(--s-sm);
}

.stat-value {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--black);
  line-height: 1;
}

.stat-value.success {
  color: var(--correct);
}

.stat-value.error {
  color: var(--red);
}

/* ==========================================================================
   Chart Container
   ========================================================================== */

.chart-container {
  background: var(--white);
  border: 2px solid var(--black);
  border-radius: 0;
  padding: var(--s-xl);
  box-shadow: none;
  margin-bottom: var(--s-lg);
}

.chart-title {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: var(--s-md);
}

/* ==========================================================================
   Phase Cards
   ========================================================================== */

.phase-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-md);
  margin-top: var(--s-md);
}

.phase-card {
  background: var(--white);
  border: 2px solid var(--warm-gray);
  border-radius: 0;
  padding: var(--s-md);
  text-align: center;
  border-left: 4px solid var(--mid-gray);
}

.phase-card.opening { border-left-color: var(--blue); }
.phase-card.middlegame { border-left-color: var(--yellow); }
.phase-card.endgame { border-left-color: var(--dark-gray); }
.phase-card.unknown { border-left-color: var(--mid-gray); }

.phase-name {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--mid-gray);
  margin-bottom: var(--s-sm);
}

.phase-count {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--black);
}

.phase-percent {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-top: var(--s-xs);
}

.phase-cpl {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-top: var(--s-sm);
}

/* Phase Bar */
.phase-bar-container { margin-top: var(--s-md); }

.phase-bar {
  display: flex;
  height: 24px;
  border-radius: 0;
  overflow: hidden;
  background: var(--warm-gray);
}

.phase-bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  color: white;
  transition: width 0.3s ease;
}

.phase-bar-segment.opening { background: var(--blue); }
.phase-bar-segment.middlegame { background: var(--yellow); color: var(--black); }
.phase-bar-segment.endgame { background: var(--dark-gray); }
.phase-bar-segment.unknown { background: var(--mid-gray); }

.phase-legend {
  display: flex;
  justify-content: center;
  gap: var(--s-lg);
  margin-top: var(--s-sm);
  flex-wrap: wrap;
}

.phase-legend-item {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--mid-gray);
}

.phase-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 0;
}

.phase-legend-color.opening { background: var(--blue); }
.phase-legend-color.middlegame { background: var(--yellow); }
.phase-legend-color.endgame { background: var(--dark-gray); }

/* ==========================================================================
   Color Breakdown
   ========================================================================== */

.color-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-md);
  margin-top: var(--s-md);
}

.color-card {
  background: var(--white);
  border: 2px solid var(--warm-gray);
  border-radius: 0;
  padding: var(--s-lg);
  text-align: center;
  position: relative;
}

.color-card.white { border-left: 4px solid var(--mid-gray); }
.color-card.black { border-left: 4px solid var(--black); }

.color-card.white::before,
.color-card.black::before {
  position: absolute;
  right: var(--s-sm);
  top: var(--s-sm);
  font-size: var(--text-xl);
  opacity: 0.15;
}

.color-card.white::before { content: '♔'; }
.color-card.black::before { content: '♚'; }

.color-name {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--mid-gray);
  margin-bottom: var(--s-sm);
}

.color-count {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--black);
}

.color-percent {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-top: var(--s-xs);
}

.color-cpl {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-top: var(--s-sm);
}

/* Color Bar */
.color-bar {
  display: flex;
  height: 28px;
  border-radius: 0;
  overflow: hidden;
  background: var(--warm-gray);
}

.color-bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  transition: width 0.3s ease;
}

.color-bar-segment.white {
  background: var(--white);
  color: var(--black);
  border-right: 2px solid var(--black);
}

.color-bar-segment.black {
  background: var(--black);
  color: var(--white);
}

.color-legend {
  display: flex;
  justify-content: center;
  gap: var(--s-lg);
  margin-top: var(--s-sm);
}

.color-legend-item {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--mid-gray);
}

.color-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 0;
  border: 2px solid var(--black);
}

.color-legend-swatch.white { background: var(--white); }
.color-legend-swatch.black { background: var(--black); }

/* ==========================================================================
   ECO Table
   ========================================================================== */

.eco-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.eco-table th,
.eco-table td {
  padding: var(--s-sm);
  text-align: left;
  border-bottom: 1px solid var(--warm-gray);
}

.eco-table th {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: var(--text-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--mid-gray);
}

.eco-code {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--warm-gray);
  padding: 2px 6px;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
}

.eco-code:hover { background: var(--mid-gray); color: var(--white); }

.eco-name-link { text-decoration: none; color: inherit; }
.eco-name-link:hover { color: var(--blue); }
.eco-name-base { font-weight: 700; }
.eco-name-variation { font-weight: 400; }
.eco-name-subvariation { font-weight: 400; font-size: var(--text-xs); color: var(--mid-gray); }

.eco-external-icon {
  font-size: var(--text-xs);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.eco-name-link:hover .eco-external-icon { opacity: 1; }

.eco-percent { color: var(--mid-gray); font-size: 0.75rem; }
.eco-group-header { background: var(--white); cursor: pointer; }
.eco-group-header:hover { background: var(--warm-gray); }

.eco-group-toggle {
  display: inline-block;
  width: 1em;
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-right: var(--s-sm);
  user-select: none;
}

.eco-variations-badge {
  font-size: var(--text-xs);
  color: var(--mid-gray);
  margin-left: var(--s-sm);
}

.eco-child-indent { padding-left: calc(var(--s-sm) + 1.5em) !important; }
.eco-group-child { font-size: var(--text-xs); }

/* ==========================================================================
   Dashboard Filter Bar — unified filter strip
   ========================================================================== */

.dashboard-filter-bar {
  border: 2px solid var(--black);
  margin-bottom: var(--s-lg);
}

.filter-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-sm) var(--s-md);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.filter-bar-header:hover {
  background: var(--warm-gray);
}

.filter-bar-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--dark-gray);
}

.filter-bar-body {
  border-top: 1px solid var(--warm-gray);
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

.filter-bar-body.collapsed {
  max-height: 0;
  opacity: 0;
  border-top-color: transparent;
}

.filter-bar-row {
  padding: var(--s-md);
}

.filter-bar-row + .filter-bar-row {
  border-top: 1px solid var(--warm-gray);
}

/* Presets row */
.filter-bar-presets {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  flex-wrap: wrap;
}

.filter-presets {
  display: flex;
  gap: var(--s-xs);
}

.filter-presets button {
  padding: var(--s-xs) var(--s-md);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--ls-normal);
  background: transparent;
  border: 2px solid var(--mid-gray);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--dark-gray);
}

.filter-presets button:hover {
  border-color: var(--black);
  color: var(--black);
  background: var(--warm-gray);
}

.filter-presets button.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* Custom date toggle button — styled like a preset */
.filter-bar-custom-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  color: var(--dark-gray);
  padding: var(--s-xs) var(--s-md);
  border: 2px solid var(--mid-gray);
  border-radius: 0;
  background: transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.filter-bar-custom-toggle:hover {
  border-color: var(--black);
  color: var(--black);
  background: var(--warm-gray);
}

.filter-bar-custom-toggle.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

.filter-bar-custom-toggle.active svg {
  stroke: var(--white);
}

/* Custom date row (collapsible) */
.filter-bar-dates {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  overflow: hidden;
  max-height: 60px;
  transition: max-height 0.2s ease, padding 0.2s ease, opacity 0.15s ease;
  opacity: 1;
}

.filter-bar-dates.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-top-width: 0;
}

.filter-bar-dates .btn {
  height: 36px;
  box-sizing: border-box;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

.filter-group label {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: var(--text-xs);
  letter-spacing: var(--ls-wide);
  color: var(--mid-gray);
  margin: 0;
}

.filter-group input[type="date"] {
  padding: var(--s-sm);
  font-size: var(--text-sm);
  width: auto;
  box-sizing: border-box;
  height: 36px;
}

/* Chip filters row */
.filter-bar-chips {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  flex-wrap: wrap;
}

.filter-chip-group {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

.filter-chip-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--mid-gray);
  margin: 0;
  margin-right: var(--s-xs);
  white-space: nowrap;
  padding: var(--s-xs) 0;
  border: 2px solid transparent;
  line-height: 1.5;
}

.filter-chip-divider {
  width: 1px;
  height: 20px;
  background: var(--mid-gray-light);
  flex-shrink: 0;
}

/* Chip-style checkbox labels (shared with trainer) */
.filter-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--dark-gray);
  cursor: pointer;
  user-select: none;
  padding: var(--s-xs) var(--s-md);
  margin: 0;
  border: 2px solid var(--mid-gray);
  border-radius: 0;
  transition: all 0.15s ease;
  letter-spacing: var(--ls-normal);
}

.filter-checkbox-label:hover {
  border-color: var(--black);
  color: var(--black);
}

.filter-checkbox-label:has(input:checked) {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

.filter-checkbox-label input[type="checkbox"] {
  display: none;
}

/* ==========================================================================
   Delete Button
   ========================================================================== */

.btn-delete {
  background: none;
  border: none;
  color: var(--mid-gray);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: var(--s-xs) var(--s-sm);
  border-radius: 0;
  transition: all 0.15s ease;
}

.btn-delete:hover {
  background: var(--bg-error);
  color: var(--red);
}

/* ==========================================================================
   Links
   ========================================================================== */

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  border-bottom: 1px solid var(--blue);
  text-decoration: none;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  margin-bottom: var(--s-md);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  color: var(--mid-gray);
}

.back-link:hover {
  color: var(--blue);
  border-bottom: none;
}

/* ==========================================================================
   HTMX Loading States
   ========================================================================== */

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.htmx-swapping {
  opacity: 0.5;
  transition: opacity 0.1s ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.15s ease-in;
}

/* ==========================================================================
   Keyboard Shortcuts
   ========================================================================== */

kbd {
  display: inline-block;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  background: var(--warm-gray);
  border: 1px solid currentColor;
  border-radius: 0;
  color: inherit;
  opacity: 0.5;
  box-shadow: none;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-muted { color: var(--mid-gray); }
.text-primary { color: var(--primary); }

.section-description {
  color: var(--text-muted);
  font-size: var(--text-base);
}
.text-success { color: var(--correct); }
.text-error { color: var(--red); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-ui { font-family: var(--font-ui); }

.mt-2 { margin-top: var(--s-sm); }
.mt-4 { margin-top: var(--s-md); }
.mb-2 { margin-bottom: var(--s-sm); }
.mb-4 { margin-bottom: var(--s-md); }

.progress-section {
  margin-top: var(--s-lg);
}

.danger-title { color: var(--error); }
.table-placeholder { text-align: center; color: var(--text-muted); }
.table-scroll { overflow-x: auto; }
.progress-fill.danger { background: var(--red); }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-3 { margin-top: 12px; }
.mt-8 { margin-top: var(--s-xl); }

.inline-spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid var(--mid-gray-light);
  border-top-color: var(--mid-gray);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Compact Link Navigation
   ========================================================================== */

.nav-link-compact {
  display: flex;
  gap: var(--s-sm);
  align-items: center;
  margin-bottom: 0;
}

.nav-link-compact-item {
  color: var(--dark-gray);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  border: none;
  border-radius: 0;
  transition: all 0.15s ease;
}

.nav-link-compact-item:hover {
  color: var(--black);
  border-bottom: none;
}

/* Demo mode banner */
.demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--yellow);
  color: var(--black);
  text-align: center;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  border-bottom: 3px solid var(--black);
}

.demo-banner a {
  color: inherit;
  font-weight: 700;
  border-bottom: 1px solid var(--black);
}

body:has(.demo-banner) {
  padding-top: 38px;
}

/* ==========================================================================
   Shared Bauhaus Header
   ========================================================================== */

.trainer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-md) var(--s-lg);
  border-bottom: 2px solid var(--black);
  margin-bottom: var(--s-lg);
}

.trainer-header-left {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

.trainer-logo {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--black);
  margin: 0;
}

.trainer-logo-icon {
  width: 20px;
  height: 20px;
  background: var(--red);
  flex-shrink: 0;
}

.trainer-nav {
  display: flex;
  gap: 0;
  align-items: center;
  border: none;
  padding: 0;
  margin: 0;
}

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

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: 2px solid var(--black);
  padding: 6px 8px;
  cursor: pointer;
  width: 36px;
  height: 32px;
}

.nav-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--black);
  transition: transform var(--transition), opacity var(--transition);
}

@media (max-width: 768px) {
  .nav-hamburger {
    display: flex;
  }

  .trainer-nav {
    position: relative;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    flex-direction: column;
    background: var(--white);
    border: 2px solid var(--black);
    z-index: 100;
    min-width: 180px;
    margin-top: var(--s-xs);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links .trainer-nav-link {
    width: 100%;
    padding: var(--s-sm) var(--s-md);
    border-bottom: 1px solid var(--warm-gray);
  }

  .nav-links .trainer-nav-link:last-child {
    border-bottom: none;
  }

  .trainer-header {
    flex-wrap: wrap;
  }
}

.trainer-nav-link {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  color: var(--dark-gray);
  text-decoration: none;
  padding: var(--s-sm) var(--s-md);
  transition: all 0.15s ease;
  border: none;
}

.trainer-nav-link:hover {
  color: var(--black);
  background: var(--warm-gray);
  border-bottom: none;
  text-decoration: none;
}

.trainer-nav-link.active {
  background: var(--black);
  color: var(--white);
}

/* ==========================================================================
   Modal Overlay — shared pattern
   ========================================================================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--white);
  border: 3px solid var(--black);
  border-radius: 0;
  padding: var(--s-xl);
  min-width: 320px;
  max-width: 480px;
  box-shadow: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-md);
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--text-xl);
  cursor: pointer;
  color: var(--mid-gray);
  padding: 0 var(--s-xs);
  line-height: 1;
}

.modal-close:hover {
  color: var(--black);
}

/* ==========================================================================
   Empty State — shared pattern
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--s-2xl) var(--s-xl);
  max-width: 500px;
  margin: 0 auto;
}

.empty-state-icon {
  color: var(--mid-gray);
  margin-bottom: var(--s-lg);
  opacity: 0.5;
}

.empty-state-title {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--black);
  margin: 0 0 var(--s-sm) 0;
}

.empty-state-message {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--mid-gray);
  margin: 0 0 var(--s-lg) 0;
  line-height: 1.6;
}

.empty-state-actions {
  display: flex;
  gap: var(--s-sm);
  justify-content: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   Filter Chips — unified toggle pattern
   ========================================================================== */

.chip {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--ls-normal);
  padding: var(--s-xs) var(--s-md);
  border: 2px solid var(--mid-gray);
  background: transparent;
  color: var(--dark-gray);
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--black);
  color: var(--black);
}

.chip.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* Chip as label wrapping a hidden input */
.chip-label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-sm);
  cursor: pointer;
  user-select: none;
}

.chip-label input[type="checkbox"],
.chip-label input[type="radio"] {
  display: none;
}

.chip-label:has(input:checked) .chip {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* ==========================================================================
   Additional Utility Classes
   ========================================================================== */

.hidden { display: none !important; }
.gap-sm { gap: var(--s-sm); }
.gap-md { gap: var(--s-md); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ==========================================================================
   Field Validation Indicators
   ========================================================================== */

.field-validation {
  display: block;
  min-height: 1.25em;
  font-size: var(--text-sm);
  margin-top: 4px;
}

.field-validation:empty { display: none; }
.field-validation.checking { color: var(--text-muted, var(--mid-gray)); }
.field-validation.valid { color: var(--success, var(--correct)); }
.field-validation.invalid { color: var(--error, var(--red)); }

.field-validation.checking::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-muted, var(--mid-gray));
  border-top-color: transparent;
  border-radius: 50%;
  animation: field-validation-spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

.field-validation.valid::before { content: '✓ '; }
.field-validation.invalid::before { content: '✗ '; }

@keyframes field-validation-spin {
  to { transform: rotate(360deg); }
}
