/* ============================================================
   PLAYER ANALYTICS DASHBOARD — SHARED STYLESHEET
   Psychology Research Platform
   ============================================================ */


/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */

:root {
  /* -- Background layers -- */
  --bg:       #f5f3ef;
  --surface:  #ffffff;
  --surface2: #f9f8f5;
  --surface3: #eef1f4;

  /* -- Borders -- */
  --border:        #e4e0d8;
  --border-strong: #ccc8bf;

  /* -- Accent palette -- */
  --accent:       #4a7c6f;
  --accent-light: #eaf2ef;
  --accent-mid:   #d0e7e2;

  --red:       #c0392b;
  --red-light: #fdf2f0;

  --amber:       #b8860b;
  --amber-light: #fdf8ec;

  --purple:       #7c3aed;
  --purple-light: #ede9fe;

  /* -- Text -- */
  --text:        #2c2a26;
  --text-mid:    #5a5650;
  --text-muted:  #928e86;
  --text-invert: #ffffff;

  /* -- Typography -- */
  --serif: 'Lora', Georgia, serif;
  --sans:  'DM Sans', 'Source Sans 3', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'Fira Code', monospace;

  /* -- Backwards-compat aliases (old variable names -> new values) -- */
  --font-body:     var(--sans);
  --font-heading:  var(--sans);
  --font-mono:     var(--mono);
  --accent2:       var(--red);
  --accent2-light: var(--red-light);
  --accent3:       var(--accent);
  --accent3-light: var(--accent-light);
  --accent4:       var(--purple);
  --accent4-light: var(--purple-light);
  --gold:          var(--amber);
  --gold-light:    var(--amber-light);
  --text-faint:    var(--text-muted);

  /* -- Spacing scale -- */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;
  --space-2xl: 64px;

  /* -- Border radius -- */
  --radius:    8px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* -- Shadows -- */
  --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-focus: 0 0 0 3px rgba(74,124,111,0.25);

  /* -- Transition -- */
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg:       #161714;
  --surface:  #1e201d;
  --surface2: #252721;
  --surface3: #2a2d27;
  --border:        #333530;
  --border-strong: #4a4d45;

  --accent:       #6aab98;
  --accent-light: #1a2e28;
  --accent-mid:   #243d36;

  --red:       #e06c5e;
  --red-light: #2a1a18;

  --amber:       #d4a843;
  --amber-light: #2a2210;

  --purple:       #9f7aea;
  --purple-light: #2d2040;

  --text:        #e8e5de;
  --text-mid:    #a8a49c;
  --text-muted:  #6b6860;
  --text-invert: #0f1117;

  --shadow:    0 1px 3px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-focus: 0 0 0 3px rgba(106,171,152,0.3);
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.75;
  min-height: 100vh;
}

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

img, svg { display: block; max-width: 100%; }


/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { color: var(--text-mid); }

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}


/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */

.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.wrap   { flex-wrap: wrap; }


/* ============================================================
   5. HEADER & NAVIGATION
   ============================================================ */

body::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--purple) 100%);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  height: 70px;
  position: sticky;
  top: 3px;
  z-index: 100;
  box-shadow: var(--shadow);
}

/* Analytics logo badge */
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-invert);
  flex-shrink: 0;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background var(--transition);
}
.logo-mark:hover {
  background: #3d6b5f;
  text-decoration: none;
}

/* Cross-project wordmark header elements */
.logo          { display: flex; align-items: baseline; gap: 10px; }
.logo-name     { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--accent); letter-spacing: 0.3px; }
.logo-divider  { width: 1px; height: 16px; background: var(--border-strong); align-self: center; }
.logo-sub      { font-size: 12px; color: var(--text-muted); font-weight: 400; letter-spacing: 0.3px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.header-center {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header h1 span { color: var(--accent); }

.sub-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav {
  display: flex;
  gap: 2px;
  align-items: center;
}

.nav-link {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-mid);
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-link:hover:not(.disabled) {
  color: var(--accent);
  background: var(--accent-light);
  border-color: rgba(74,124,111,0.2);
  text-decoration: none;
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: rgba(74,124,111,0.3);
  font-weight: 500;
}
.nav-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nav-link.disabled::after {
  content: ' .';
  color: var(--red);
  font-size: 0.9em;
}


/* ============================================================
   6. HERO SECTION (home page)
   ============================================================ */

.hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl) var(--space-xl);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}
.hero-eyebrow::before,
.hero-eyebrow::after {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--border-strong);
}

.hero h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}
.hero h2 span { color: var(--accent); }

.hero p {
  font-size: 0.95rem;
  color: var(--text-mid);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}


/* ============================================================
   7. STATUS BAR
   ============================================================ */

.status-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-mid);
  letter-spacing: 0.01em;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
  animation: pulse-dot 2.4s infinite;
}
.status-dot.pending {
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-light);
}
.status-dot.offline { background: var(--text-muted); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}


/* ============================================================
   8. MODULE GRID & CARDS (home page)
   ============================================================ */

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.module-card.available:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}
.module-card.coming-soon {
  opacity: 0.55;
  cursor: not-allowed;
}

.module-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.module-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.module-icon.blue   { background: var(--accent-light);  border-color: rgba(74,124,111,0.2); }
.module-icon.green  { background: var(--accent-light);  border-color: rgba(74,124,111,0.2); }
.module-icon.orange { background: var(--red-light);     border-color: rgba(192,57,43,0.15); }
.module-icon.purple { background: var(--purple-light);  border-color: rgba(124,58,237,0.2); }
.module-icon.yellow { background: var(--amber-light);   border-color: rgba(184,134,11,0.2); }

.module-name {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.module-desc {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.65;
  margin-bottom: var(--space-md);
}

.module-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mid);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.01em;
  transition: color var(--transition), background var(--transition);
}
.module-card.available:hover .metric-pill {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(74,124,111,0.2);
}

.module-arrow {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  font-size: 1rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--transition), transform var(--transition);
}
.module-card.available:hover .module-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

.module-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  border: 1px solid;
}
.module-badge.live {
  background: var(--accent-light);
  border-color: rgba(74,124,111,0.3);
  color: var(--accent);
}
.module-badge.soon {
  background: var(--amber-light);
  border-color: rgba(184,134,11,0.25);
  color: var(--amber);
}


/* ============================================================
   9. UPLOAD ZONE
   ============================================================ */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-icon {
  font-size: 40px;
  margin-bottom: var(--space-md);
  opacity: 0.7;
}

.upload-zone h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-mid);
  font-family: var(--mono);
}

input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.btn-analyse {
  margin-top: var(--space-lg);
  background: var(--accent);
  border: none;
  color: var(--text-invert);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}
.btn-analyse:hover {
  background: #3d6b5f;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-analyse:active { transform: translateY(0); }


/* ============================================================
   10. SESSION CARDS
   ============================================================ */

.session-card {
  margin-top: var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.35s ease forwards;
}

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

.session-header {
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(90deg, var(--accent-light) 0%, transparent 70%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.session-title {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
  animation: pulse-dot 2.4s infinite;
  flex-shrink: 0;
}


/* ============================================================
   11. STATS GRID & CELLS (analytics)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-cell {
  background: var(--surface);
  padding: var(--space-lg);
  transition: background var(--transition);
}
.stat-cell:hover { background: var(--surface3); }

.stat-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mid);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--sans);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-value.accent  { color: var(--accent); }
.stat-value.green   { color: var(--accent); }
.stat-value.orange  { color: var(--red); }
.stat-value.teal    { color: var(--accent); }
.stat-value.purple  { color: var(--purple); }
.stat-value.gold    { color: var(--amber); }
.stat-value.blue    { color: var(--accent); }
.stat-value.red     { color: var(--red); }

.stat-unit {
  font-size: 0.78rem;
  color: var(--text-mid);
  margin-top: 5px;
  font-family: var(--mono);
}


/* ============================================================
   12. PHASE TIMELINE BAR
   ============================================================ */

.phase-bar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  overflow: hidden;
}

.phase-seg {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-right: 1px solid var(--border);
}
.phase-seg:last-child { border-right: none; }

.phase-seg.collect { background: rgba(74,124,111,0.05); }
.phase-seg.ret     { background: rgba(74,124,111,0.03); }
.phase-seg.total   { background: var(--surface3); flex: 1; }

.phase-name {
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.phase-value {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.phase-value span {
  font-size: 0.8rem;
  color: var(--text-mid);
  font-weight: 400;
}


/* ============================================================
   13. MEMORY ORDER DISPLAY
   ============================================================ */

.memory-section {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.memory-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-mid);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-md);
}

.order-rows { display: flex; flex-direction: column; gap: var(--space-sm); }

.order-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.order-title {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-mid);
  width: 130px;
  flex-shrink: 0;
}

.order-coins {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.coin-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px solid;
}
.coin-badge.collect {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.coin-badge.ret {
  background: var(--accent-mid);
  border-color: var(--accent);
  color: var(--accent);
}

.order-arrow { color: var(--text-mid); font-size: 1rem; }

.match-badge {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  margin-left: var(--space-sm);
  border: 1px solid;
}
.match-yes {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(74,124,111,0.3);
}
.match-no {
  background: var(--red-light);
  color: var(--red);
  border-color: rgba(192,57,43,0.3);
}


/* ============================================================
   14. CHARTS SECTION
   ============================================================ */

.charts-section { padding: var(--space-lg); }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.charts-row.wide   { grid-template-columns: 3fr 2fr; }
.charts-row.single { grid-template-columns: 1fr; }
.charts-row.thirds { grid-template-columns: 1fr 1fr 1fr; }

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  overflow: hidden;
}

.chart-title {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.01em;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}


/* ============================================================
   15. TABLES
   ============================================================ */

.table-section { padding: 0 var(--space-lg) var(--space-lg); }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow);
}

/* Alias used by cross-project templates */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
}

thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 12px var(--space-md);
  text-align: left;
  color: var(--text-mid);
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
  font-weight: 600;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .sort-icon { margin-left: 4px; opacity: 0.4; font-style: normal; }
th.sort-asc .sort-icon,
th.sort-desc .sort-icon { opacity: 1; color: var(--accent); }

td {
  padding: 10px var(--space-md);
  color: var(--text);
  border-bottom: 1px solid rgba(228,224,216,0.6);
  white-space: nowrap;
  line-height: 1.5;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

.td-num    { color: var(--accent); font-weight: 500; }
.td-sprint { color: var(--red); }
.td-jump   { color: var(--accent); }

.dist-close  { color: var(--accent); font-weight: 600; }
.dist-medium { color: var(--amber); }
.dist-far    { color: var(--red); }

.rt-fast { color: var(--accent); font-weight: 600; }
.rt-med  { color: var(--accent); }
.rt-slow { color: var(--red); }
.rt-none { color: var(--text-muted); }

.table-note {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-mid);
  padding: 10px var(--space-md);
  text-align: right;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Cross-project table cell helpers */
.resp-id       { font-weight: 500; color: var(--accent); font-size: 13px; }
.resp-id-raw   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.datetime      { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.answers-count { font-size: 13px; color: var(--text-mid); }


/* ============================================================
   16. BADGES & TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--mono);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-success,
.badge-valid,
.badge-correct { background: var(--accent-light); color: var(--accent);  border-color: rgba(74,124,111,0.25); }

.badge-fail,
.badge-invalid  { background: var(--red-light);    color: var(--red);    border-color: rgba(192,57,43,0.2); }

.badge-reset   { background: var(--amber-light);  color: var(--amber);  border-color: rgba(184,134,11,0.2); }
.badge-done    { background: var(--accent-light);  color: var(--accent); border-color: rgba(74,124,111,0.2); }
.badge-start   { background: var(--purple-light);  color: var(--purple); border-color: rgba(124,58,237,0.2); }
.badge-on      { background: var(--accent-light);  color: var(--accent); border-color: rgba(74,124,111,0.25); }
.badge-off     { background: var(--surface2);      color: var(--text-muted); border-color: var(--border); }
.badge-color   { background: var(--purple-light);  color: var(--purple); border-color: rgba(124,58,237,0.2); }
.badge-std     { background: var(--accent-light);  color: var(--accent); border-color: rgba(74,124,111,0.2); }
.badge-early   { background: var(--red-light);     color: var(--red);    border-color: rgba(192,57,43,0.2); }
.badge-wrong   { background: var(--amber-light);   color: var(--amber);  border-color: rgba(184,134,11,0.2); }

/* Sync-status badges (cross-project) */
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.synced  { background: var(--accent-light); color: var(--accent); }
.badge.synced  .badge-dot { background: var(--accent); }
.badge.pending { background: var(--amber-light);  color: var(--amber); }
.badge.pending .badge-dot { background: var(--amber); }

.meta-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  background: var(--accent-light);
  border: 1px solid rgba(74,124,111,0.2);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
}
.tag.green  { background: var(--accent-light);  border-color: rgba(74,124,111,0.2);  color: var(--accent); }
.tag.orange { background: var(--red-light);     border-color: rgba(192,57,43,0.2);   color: var(--red); }
.tag.gold   { background: var(--amber-light);   border-color: rgba(184,134,11,0.2);  color: var(--amber); }
.tag.purple { background: var(--purple-light);  border-color: rgba(124,58,237,0.2);  color: var(--purple); }
.tag.blue   { background: var(--accent-light);  border-color: rgba(74,124,111,0.2);  color: var(--accent); }

.color-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}


/* ============================================================
   17. SOLVE / ATTEMPT SECTIONS
   ============================================================ */

.solve-section {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.move-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.move-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 11px;
  font-family: var(--mono);
  font-size: 0.8rem;
  transition: border-color var(--transition);
}
.move-chip:hover { border-color: var(--accent); }

.move-num       { color: var(--text-muted); font-size: 0.72rem; min-width: 16px; }
.move-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.move-text      { color: var(--text); }
.move-time      { color: var(--text-muted); font-size: 0.72rem; }
.move-arrow     { color: var(--text-muted); font-size: 1rem; }

.attempt-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.85rem;
}
.attempt-row:last-child { border-bottom: none; }

.attempt-num {
  color: var(--text-muted);
  width: 60px;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.attempt-bar-wrap {
  flex: 1;
  height: 26px;
  background: var(--surface3);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.attempt-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 8px;
}
.attempt-bar-fill.solved {
  background: linear-gradient(90deg, rgba(74,124,111,0.2), rgba(74,124,111,0.06));
  border-left: 3px solid var(--accent);
}
.attempt-bar-fill.reset {
  background: linear-gradient(90deg, rgba(192,57,43,0.15), rgba(192,57,43,0.04));
  border-left: 3px solid var(--red);
}

.attempt-bar-text { font-size: 0.75rem; color: var(--text-mid); white-space: nowrap; }
.attempt-meta     { color: var(--text-muted); font-size: 0.75rem; min-width: 80px; text-align: right; }


/* ============================================================
   18. COMPLETE BANNER
   ============================================================ */

.complete-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--accent-light);
  border-bottom: 1px solid rgba(74,124,111,0.2);
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--accent);
}
.complete-banner .icon  { font-size: 1.2rem; }
.complete-banner strong { font-weight: 600; color: var(--accent); }


/* ============================================================
   19. EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  color: var(--text-mid);
}
.empty-state .big-icon {
  font-size: 52px;
  opacity: 0.3;
  margin-bottom: var(--space-md);
}
.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 0.9rem;
  font-family: var(--mono);
  color: var(--text-mid);
}
.empty-icon { font-size: 28px; margin-bottom: 10px; opacity: 0.4; }


/* ============================================================
   20. ERROR BAR
   ============================================================ */

.error-bar {
  background: var(--red-light);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  color: var(--red);
  font-family: var(--sans);
  font-size: 0.9rem;
}


/* ============================================================
   21. SECTION LABELS
   ============================================================ */

.section-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}


/* ============================================================
   22. INFO / REFERENCE CARDS (home page)
   ============================================================ */

.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}
.info-card h3 {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.csv-schema {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.9;
}
.schema-row {
  display: flex;
  gap: var(--space-md);
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(228,224,216,0.4);
}
.schema-row:last-child { border-bottom: none; }
.schema-col  { color: var(--accent); min-width: 120px; font-weight: 500; }
.schema-type { color: var(--amber); font-size: 0.75rem; min-width: 58px; }
.schema-desc { color: var(--text-mid); font-size: 0.8rem; }


/* ============================================================
   23. CHANGELOG
   ============================================================ */

.changelog { font-family: var(--sans); font-size: 0.88rem; }

.changelog-item {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(228,224,216,0.4);
}
.changelog-item:last-child { border-bottom: none; }

.cl-version {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--accent-light);
  border: 1px solid rgba(74,124,111,0.2);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.cl-text        { color: var(--text-mid); font-size: 0.88rem; line-height: 1.6; }
.cl-text strong { color: var(--text); font-weight: 600; }


/* ============================================================
   24. BUTTONS
   ============================================================ */

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
  background: var(--surface);
  color: var(--text-mid);
}
.btn:hover:not(:disabled)     { border-color: var(--border-strong); background: var(--surface2); color: var(--text); text-decoration: none; }
.btn:disabled                 { opacity: 0.45; cursor: not-allowed; }
.btn-primary                  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #3d6b5f; border-color: #3d6b5f; color: #fff; }
.btn-secondary                { color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-light); }
.btn-danger                   { color: var(--red); border-color: rgba(192,57,43,0.3); }
.btn-danger:hover:not(:disabled)    { background: var(--red-light); border-color: rgba(192,57,43,0.5); }

.btn-csv {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-mid);
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-csv:hover            { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-csv.primary          { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-csv.primary:hover    { background: #3d6b5f; }

.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text-mid);
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: rgba(74,124,111,0.3);
}


/* ============================================================
   25. SEARCH BAR & FILTERS (cross-project)
   ============================================================ */

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  flex: 1;
  min-width: 200px;
  transition: border-color 0.15s;
}
.search-input-wrap:focus-within { border-color: var(--accent); }
.search-input-wrap input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.search-input-wrap input::placeholder { color: var(--text-muted); }
.search-clear       { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 0; }
.search-clear:hover { color: var(--text); }

.filter-select {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.filter-select:focus { border-color: var(--accent); }
.filter-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; margin-left: 4px; }


/* ============================================================
   26. PAGINATION (cross-project)
   ============================================================ */

.pagination { display: flex; align-items: center; gap: 8px; }
.pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-mid);
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--sans);
  transition: all 0.12s;
}
.pagination button:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface2); }
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination span { font-size: 12px; color: var(--text-muted); }


/* ============================================================
   27. TOAST (cross-project)
   ============================================================ */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 18px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s ease;
  z-index: 999;
  color: var(--text-mid);
}
#toast.show    { opacity: 1; transform: translateY(0); }
#toast.success { border-left: 3px solid var(--accent); color: var(--accent); }
#toast.error   { border-left: 3px solid var(--red);    color: var(--red); }
#toast.info    { border-left: 3px solid var(--amber);  color: var(--amber); }


/* ============================================================
   28. LOADING OVERLAY (cross-project)
   ============================================================ */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(245,243,239,0.8);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(2px);
}
.loading-overlay.show                { display: flex; }
[data-theme="dark"] .loading-overlay { background: rgba(22,23,20,0.85); }

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-muted); font-family: var(--sans); }


/* ============================================================
   29. AUTO-SYNC BAR & TOGGLE (cross-project)
   ============================================================ */

.autosync-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.autosync-label { font-size: 12px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

.toggle-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle {
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on::after { left: 19px; }
.toggle-text { font-size: 12px; font-weight: 500; color: var(--text-mid); min-width: 24px; }

.autosync-sep { width: 1px; height: 18px; background: var(--border); }
.interval-wrap { display: flex; align-items: center; gap: 8px; }
.interval-wrap label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.interval-select {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.interval-select:focus    { border-color: var(--accent); }
.interval-select:disabled { opacity: 0.4; cursor: not-allowed; }
.next-sync-text { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

.sync-progress-wrap { display: none; align-items: center; gap: 10px; margin-left: 4px; }
.sync-progress-wrap.show { display: flex; }
.sync-progress-track { width: 120px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sync-progress-fill  { height: 100%; width: 0%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.sync-progress-fill.indeterminate { width: 40%; animation: indeterminate 1.2s ease-in-out infinite; }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.sync-progress-label { font-size: 11px; color: var(--accent); white-space: nowrap; font-weight: 500; }


/* ============================================================
   30. CROSS-PROJECT STAT CARDS & SECTIONS
   ============================================================ */

.stats-section {
  padding: 24px 32px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 11px; }
.stat-card .stat-value {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

main { padding: 24px 32px 40px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title  { font-family: var(--serif); font-size: 16px; font-weight: 500; color: var(--text); }


/* ============================================================
   31. RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .charts-row.thirds { grid-template-columns: 1fr 1fr; }
  .stats-section     { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .container { padding: var(--space-md); }

  header {
    padding: 0 var(--space-md);
    height: auto;
    min-height: 70px;
    flex-wrap: wrap;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .top-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .hero          { padding: var(--space-xl) var(--space-md) var(--space-lg); }
  .status-bar    { gap: var(--space-md); padding: var(--space-md); }
  .info-row      { grid-template-columns: 1fr; }
  .charts-row,
  .charts-row.wide,
  .charts-row.thirds { grid-template-columns: 1fr; }
  .phase-bar     { flex-wrap: wrap; }
  .module-grid   { grid-template-columns: 1fr 1fr; }
  main, .stats-section { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 580px) {
  .module-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
}
