/* ═══════════════════════════════════════════════════════════════
   IMPULSE-TRI HUB — Global Styles
   Dark Sports Premium Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@300;400;500;600;700;800&family=Barlow:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg-deep:      #060a14;
  --bg-main:      #0a0e1a;
  --bg-card:      #0f1525;
  --bg-card2:     #131929;
  --bg-hover:     #1a2240;
  --border:       rgba(30, 92, 255, 0.15);
  --border-light: rgba(255,255,255,0.06);

  --accent:       #1e5cff;
  --accent-glow:  rgba(30, 92, 255, 0.25);
  --accent-dim:   rgba(30, 92, 255, 0.12);
  --cyan:         #00c8ff;
  --cyan-dim:     rgba(0, 200, 255, 0.12);
  --cyan-glow:    rgba(0, 200, 255, 0.2);

  --text:         #e8eaf0;
  --text-muted:   #8892aa;
  --text-dim:     #4a5570;

  --success:      #00e676;
  --warning:      #ffd600;
  --danger:       #ff4060;
  --danger-dim:   rgba(255, 64, 96, 0.12);

  --font-racing:  'Racing Sans One', 'Barlow Condensed', sans-serif;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body:    'Barlow', 'Arial', sans-serif;

  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 24px var(--accent-glow);
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(30,92,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,92,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  position: relative;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 36px;
  height: 36px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-name {
  font-family: var(--font-racing);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
}

.logo-sub {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

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

.sidebar-footer form { margin: 0; }

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-dim);
}

/* ── Main Content ──────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 28px 32px 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  color: #fff;
}

.page-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.page-content {
  padding: 24px 32px 40px;
  flex: 1;
}

/* ── Mobile nav toggle ─────────────────────────────────────────── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s;
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Stat Cards ────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.stat-card.cyan::after {
  background: radial-gradient(circle, var(--cyan-glow) 0%, transparent 70%);
}

.stat-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.cyan .stat-value   { color: var(--cyan); }

.stat-detail {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Quick Actions ─────────────────────────────────────────────── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.2s;
  cursor: pointer;
}

.quick-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.quick-btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--bg-deep);
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); cursor: pointer; }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.td-name {
  font-weight: 600;
  color: #fff;
}

.td-muted { color: var(--text-muted); }
.td-num {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-active  { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.badge-pause   { background: rgba(255, 214, 0, 0.15);  color: var(--warning); }
.badge-archive { background: rgba(255,255,255,0.08);   color: var(--text-dim); }
.badge-m       { background: rgba(30,92,255,0.15);     color: var(--accent); }
.badge-f       { background: rgba(0,200,255,0.15);     color: var(--cyan); }
.badge-type    { background: rgba(255,255,255,0.06);   color: var(--text-muted); }

/* ── Filters ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}

.filter-select,
.filter-input {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 120px;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent);
}

.filter-input::placeholder { color: var(--text-dim); }

.filter-spacer { flex: 1; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #3571ff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-cyan {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
}
.btn-cyan:hover {
  background: var(--cyan-dim);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(255,64,96,0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-dim);
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
}

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

/* ── Panels / Modals ────────────────────────────────────────────── */
.side-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.side-panel.open { right: 0; }

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.panel-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.panel-meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.panel-close:hover { color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.panel-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ── Profile Fields ─────────────────────────────────────────────── */
.profile-section {
  margin-bottom: 20px;
}

.profile-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent-dim);
}

.profile-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

.profile-field:last-child { border-bottom: none; }

.profile-field-key {
  flex-shrink: 0;
  width: 110px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-field-val {
  color: var(--text);
  flex: 1;
}

/* Race item in panel */
.race-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.race-item:last-child { border-bottom: none; }

.race-title {
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.race-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.race-time {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

/* ── Chat Interface ─────────────────────────────────────────────── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 500px;
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-msg.agent {
  align-self: flex-start;
  background: var(--bg-card2);
  color: var(--text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border-light);
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
}

.chat-input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  padding: 9px 14px;
  outline: none;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  transition: border-color 0.15s;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-dim); }

/* ── Content Editor ─────────────────────────────────────────────── */
.content-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: start;
}

.editor-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.editor-toolbar {
  padding: 10px 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.editor-textarea {
  width: 100%;
  min-height: 400px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  line-height: 1.7;
  padding: 20px;
  resize: vertical;
  outline: none;
}

.editor-textarea::placeholder { color: var(--text-dim); }

.editor-result {
  margin-top: 0;
  padding: 20px;
  background: var(--bg-card2);
  border-top: 1px solid var(--border-light);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  display: none;
}

.editor-result.visible { display: block; }

.agent-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.agent-panel-title {
  padding: 14px 18px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.agent-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.agent-action-btn:last-child { border-bottom: none; }

.agent-action-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.agent-action-icon { font-size: 16px; }

.topic-input-wrap {
  padding: 10px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-deep);
}

.topic-input-wrap input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  font-family: var(--font-body);
}

.topic-input-wrap input:focus { border-color: var(--accent); }
.topic-input-wrap input::placeholder { color: var(--text-dim); }

/* ── Agents Grid ─────────────────────────────────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.agent-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.agent-card:hover::before,
.agent-card.selected::before { opacity: 1; }

.agent-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.agent-card.selected {
  border-color: var(--accent);
  background: var(--bg-card2);
}

.agent-emoji {
  font-size: 28px;
  margin-bottom: 10px;
  display: block;
}

.agent-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

.agent-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Loading spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Toast notifications ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease forwards;
  pointer-events: all;
  max-width: 340px;
}

.toast-success { background: #0d2f1a; border: 1px solid rgba(0,230,118,0.3); color: var(--success); }
.toast-error   { background: #2f0d14; border: 1px solid rgba(255,64,96,0.3); color: var(--danger); }
.toast-info    { background: var(--bg-card2); border: 1px solid var(--border); color: var(--text); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Rating specific ─────────────────────────────────────────────── */
.rating-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-deep);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border-light);
  border-bottom: none;
}

.rating-section-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.label-m { color: var(--accent); }
.label-f { color: var(--cyan); }

.rating-block { margin-bottom: 28px; }
.rating-block .table-wrap {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Empty states ────────────────────────────────────────────────── */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 14px; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Login page ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* Radial glow behind login card */
.login-page::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(30,92,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow);
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--cyan) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
}

.login-logo-name {
  font-family: var(--font-racing);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
}

.login-logo-sub {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-top: 2px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--danger-dim);
  border: 1px solid rgba(255,64,96,0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Pagination / Count info ─────────────────────────────────────── */
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Section heading inside page ─────────────────────────────────── */
.section-heading {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading span {
  display: block;
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* ── Progress bar ────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--cyan) 100%);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stat-grid   { grid-template-columns: repeat(2, 1fr); }
  .quick-grid  { grid-template-columns: repeat(2, 1fr); }
  .agents-grid { grid-template-columns: repeat(2, 1fr); }
  .content-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .nav-toggle { display: flex; }
  .page-header { padding: 68px 16px 0; }
  .page-content { padding: 16px 16px 40px; }
  .stat-grid   { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-grid  { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .agents-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .side-panel  { width: 100%; right: -100%; }
  .page-title  { font-size: 24px; }
}

@media (max-width: 480px) {
  .stat-grid   { grid-template-columns: 1fr 1fr; }
  .quick-grid  { grid-template-columns: 1fr 1fr; }
  .agents-grid { grid-template-columns: 1fr; }
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--accent-dim);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── TrainingPeaks nav item (disabled) ────────────────────────────── */
.nav-item-disabled {
  opacity: 0.45;
  cursor: pointer;
  user-select: none;
}

.nav-item-disabled:hover {
  opacity: 0.65;
  background: var(--accent-dim);
  color: var(--text-muted);
}

.nav-lock-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 100px;
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.modal-race-info { margin-bottom: 8px; }

.modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  background: var(--bg-deep);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.modal-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.modal-info-key {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.modal-info-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ── Projects grid ────────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.project-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.project-type-icon { font-size: 18px; }

.project-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.3;
}

.project-card-preview {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.project-card-date {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Digest items ─────────────────────────────────────────────────── */
.digest-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.digest-item:last-child { border-bottom: none; }

.digest-item-content { flex: 1; }

.digest-item-topic {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.4;
}

.digest-item-source {
  font-size: 12px;
  color: var(--text-dim);
}

.digest-item-source a { color: var(--accent); text-decoration: none; }
.digest-item-source a:hover { text-decoration: underline; }

/* ── Calculator ───────────────────────────────────────────────────── */
.calc-disc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}

.calc-disc-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.calc-disc-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.calc-result {
  background: var(--bg-deep);
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border-light);
}

.calc-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.calc-result-key {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.calc-result-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
}

.form-unit {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ── Mobile: additional responsive fixes ─────────────────────────── */
@media (max-width: 1024px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .projects-grid { grid-template-columns: 1fr; }
  .modal-info-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tabs { flex-wrap: wrap; }
  .tab-btn { flex: 1; justify-content: center; font-size: 12px; padding: 8px 10px; }
  /* Calculator grids on mobile */
  #tab-pace > div[style*="grid-template-columns:repeat(3"] { grid-template-columns: 1fr !important; }
  .calc-disc-btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-box { margin: 10px; max-height: 95vh; }
  .page-title { font-size: 22px; }
}
