:root {
  /* Brand colors */
  --catlap-yellow: #fef100;
  --catlap-blue:   #00a3e6;
  --catlap-pink:   #f4519d;
  --catlap-purple: #9b3de6;
  --catlap-green:  #66c343;
  --catlap-orange: #ff7b25;
  --catlap-brown:  #9c4d18;
  --catlap-black:  #000000;

  /* Dark mode theme */
  --page-bg: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-bg-solid: #1e1e32;
  --card-border: rgba(255, 255, 255, 0.1);
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.9);
  --ink-muted: rgba(255, 255, 255, 0.6);

  --max-width: 1100px;
  --border-radius: 12px;
  
  /* Input styles */
  --input-bg: rgba(255, 255, 255, 0.1);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--ink-soft);
  min-height: 100vh;
}

.crew-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-x: hidden;
}

.crew-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.crew-tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
  background: var(--catlap-yellow);
  color: var(--catlap-black);
  width: fit-content;
}

.crew-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0.2rem 0;
  font-weight: 800;
  text-transform: lowercase;
  color: var(--catlap-yellow);
}

.crew-subtitle {
  margin: 0;
  font-size: 0.9rem;
  max-width: 600px;
  color: var(--ink-muted);
}

.crew-warning {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--catlap-orange);
}

/* Layout */

.crew-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr);
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .crew-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Cards */

.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  overflow: hidden;
  max-width: 100%;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  text-transform: lowercase;
  color: #ffffff;
}

.card small {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Forms */

.inline-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  align-items: flex-end;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
}

.form-field label {
  font-weight: 600;
  color: var(--ink-muted);
}

.form-field input,
.form-field select,
.form-field textarea {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  min-width: 0;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--catlap-yellow);
  box-shadow: 0 0 0 2px rgba(254, 241, 0, 0.2);
}

.form-field textarea {
  min-height: 60px;
  resize: vertical;
}

button {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink-soft);
  box-shadow: none;
  transition: background 0.15s;
}

button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: none;
  box-shadow: none;
}

button:active {
  background: rgba(255, 255, 255, 0.25);
}

button.primary {
  background: var(--catlap-blue);
  border-color: rgba(0, 130, 180, 0.5);
  color: white;
}

button.primary:hover {
  background: #0090c0;
}

button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink-soft);
  border: 1px solid var(--card-border);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Clock / pills */

.time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.time-pill {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
  color: var(--ink-soft);
}

.time-pill strong {
  font-weight: 800;
  color: var(--catlap-yellow);
}

/* Assistance table */

.assist-table-wrapper {
  margin-top: 0.75rem;
  max-height: 380px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

thead {
  position: sticky;
  top: 0;
  background: rgba(30, 30, 50, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1;
}

th, td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--catlap-yellow);
  font-weight: 700;
}

td {
  color: var(--ink-soft);
}

th:nth-child(1),
td:nth-child(1) {
  width: 60px;
  white-space: nowrap;
}

th:nth-child(2),
td:nth-child(2) {
  width: 120px;
  white-space: nowrap;
}

.assist-plan-cell {
  min-width: 240px;
}

.assist-plan-cell[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
}

.assist-plan-cell:focus-visible {
  box-shadow: 0 0 0 2px var(--catlap-pink);
}

.plan-table-wrapper {
  margin-top: 0.75rem;
  max-height: 380px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.plan-table thead {
  position: sticky;
  top: 0;
  background: var(--card-bg-solid);
  z-index: 1;
}

.plan-table th {
  color: var(--catlap-pink);
  font-weight: 600;
}

.plan-table th,
.plan-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: top;
}

.plan-row-current {
  background: rgba(102, 195, 67, 0.25);
}

.plan-row-current td {
  border-bottom-color: rgba(102, 195, 67, 0.4);
  color: #ffffff;
}

/* speed colours */
.plan-speed-slow {
  font-weight: 700;
  color: var(--catlap-green);
}

.plan-speed-average {
  font-weight: 700;
  color: var(--catlap-blue);
}

.plan-speed-fast {
  font-weight: 700;
  color: var(--catlap-orange);
}

.plan-gear-cell {
  white-space: normal;
}

.gear-tag {
  display: inline-block;
  margin: 0 0.15rem 0.15rem 0;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--catlap-pink);
  font-size: 0.7rem;
  background: rgba(244, 81, 157, 0.2);
  color: var(--catlap-pink);
}

.hour-row-current {
  background: rgba(102, 195, 67, 0.2);
}

.hour-row-current td {
  border-bottom-color: rgba(102, 195, 67, 0.4);
}

/* Lap log */

.log-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.log-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.log-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.log-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.log-checkbox-row input[type="checkbox"] {
  width: auto;
}

.log-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  align-items: center;
}

.log-status {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Summary + tables */

.log-summary {
  margin-top: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(254, 241, 0, 0.1);
  border: 1px solid rgba(254, 241, 0, 0.2);
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--ink-soft);
}

.log-summary strong {
  font-weight: 800;
  color: var(--catlap-yellow);
}

.log-table-wrapper {
  margin-top: 0.75rem;
  max-height: 320px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
}

/* =========================
   Fuel buttons
   ========================== */

.fuel-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Base fuel button - rectangular */
.fuel-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink-soft);
  text-align: center;
  transition: background 0.15s;
}

.fuel-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Variants by type */
.fuel-btn.food-fuel {
  background: rgba(102, 195, 67, 0.2);
  border-color: rgba(102, 195, 67, 0.4);
  color: #90ee90;
}

.fuel-btn.food-fuel:hover {
  background: rgba(102, 195, 67, 0.3);
}

.fuel-btn.liquid-fuel {
  background: rgba(0, 163, 230, 0.2);
  border-color: rgba(0, 163, 230, 0.4);
  color: #87ceeb;
}

.fuel-btn.liquid-fuel:hover {
  background: rgba(0, 163, 230, 0.3);
}

.fuel-btn.hybrid-fuel {
  background: rgba(155, 61, 230, 0.2);
  border-color: rgba(155, 61, 230, 0.4);
  color: #dda0dd;
}

.fuel-btn.hybrid-fuel:hover {
  background: rgba(155, 61, 230, 0.3);
}

.fuel-btn.other-fuel {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--ink-muted);
}

.fuel-btn.other-fuel:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Fuel summary text */
.fuel-summary {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* Reset fuel button */
.fuel-reset-btn {
  margin-top: 0.5rem;
  background: rgba(180, 0, 0, 0.2);
  border-color: rgba(180, 0, 0, 0.4);
  color: #ffaaaa;
}

.fuel-reset-btn:hover {
  background: rgba(180, 0, 0, 0.3);
}



.log-table td:nth-child(1) { width: 60px; }
.log-table td:nth-child(2) { width: 80px; }
.log-table td:nth-child(3) { width: 80px; }
.log-table td:nth-child(4) { width: 80px; }
.log-table td:nth-child(5) { width: 80px; }

/* Stats blocks */

/* Stats card layout */

.stats-card {
  margin-top: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem 1.75rem;
  align-items: flex-start;
}

/* Laps full width on wider screens */
.stat-block-wide {
  grid-column: 1 / -1;
}

/* Individual stat blocks */
.stat-block {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Top label + main number */
.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.stat-main {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-unit {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Meta lines inside each block */
.stat-meta {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-line {
  display: flex;
  flex-wrap: wrap;           /* allow wrap so nothing spills */
  align-items: baseline;
  gap: 0.35rem;
}

.stat-line-label {
  font-size: 0.8rem;
  opacity: 0.85;
}

.stat-line-value {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Badges (targets / status) */
.stat-line-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.15);
  white-space: nowrap;       /* stays on one line but small enough now */
}

/* Optional: tweak good/low/high colors if you use them */
.stat-badge-good {
  background: rgba(0, 180, 120, 0.15);
  border-color: rgba(0, 180, 120, 0.6);
}

.stat-badge-low {
  background: rgba(240, 180, 0, 0.15);
  border-color: rgba(240, 180, 0, 0.6);
}

.stat-badge-high {
  background: rgba(220, 80, 80, 0.15);
  border-color: rgba(220, 80, 80, 0.6);
}

/* Mobile tightening */
@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-block {
    padding: 0.9rem 1rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}


/* Charts */

.chart-wrapper {
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  height: 260px;
  overflow: hidden;
  max-width: 100%;
}

.log-mood {
  font-weight: 700;
}

.mood-good { color: var(--catlap-green); }
.mood-ok   { color: var(--catlap-yellow); }
.mood-bad  { color: var(--catlap-pink); }

.crew-footer-note {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: var(--ink-muted);
}

.plan-table-wrapper {
  margin-top: 0.75rem;
}

/* Already defined above - removed duplicate */

/* =========================
   Mobile: pacing plan as cards
   ========================== */

@media (max-width: 700px) {
  /* Hide the table header on mobile */
  .card-clock-plan .plan-table thead {
    display: none;
  }

  /* Treat each row as a card - dark mode */
  .card-clock-plan .plan-table tr {
    display: block;
    margin-bottom: 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    padding: 0.6rem 0.75rem;
  }

  /* Extra pop for current lap - dark green background */
  .card-clock-plan .plan-table tr.plan-row-current {
    background: rgba(102, 195, 67, 0.25);
    border-color: rgba(102, 195, 67, 0.6);
    box-shadow: 0 0 10px rgba(102, 195, 67, 0.3);
  }

  .card-clock-plan .plan-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: none;
    padding: 0.2rem 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
  }

  /* Label on the left, value on the right */
  .card-clock-plan .plan-table td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 0.5rem;
  }

  /* Lap row title gets a bit more weight */
  .card-clock-plan .plan-table td:first-child {
    font-weight: 800;
    font-size: 0.95rem;
    color: #ffffff;
  }

  .card-clock-plan .plan-table td:first-child::before {
    color: var(--catlap-yellow);
  }

  /* Gear actions wrap nicely as chips */
  .card-clock-plan .plan-gear-cell {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .card-clock-plan .plan-gear-cell::before {
    margin-bottom: 0.15rem;
  }

  .card-clock-plan .gear-tag {
    margin: 0 0.2rem 0.2rem 0;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
  }

  /* Give the whole card section a bit more breathing room */
  .card-clock-plan .plan-table-wrapper {
    max-height: none;
    overflow-x: hidden;
  }
  
  /* Ensure table doesn't overflow on mobile */
  .card-clock-plan .plan-table {
    width: 100%;
    table-layout: fixed;
  }
  
  /* Make sure rows don't extend past container */
  .card-clock-plan .plan-table tr {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
}

.plan-controls {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.plan-controls button {
  font-size: 0.85rem;
  border-radius: 6px;
}

/* ========== LAP ALERT BANNERS ========== */
.lap-alert-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  animation: alert-pulse 0.5s ease-in-out 3;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.alert-2min {
  background: var(--catlap-orange);
  color: white;
}

.alert-30sec {
  background: var(--catlap-pink);
  color: white;
  animation: alert-pulse 0.3s ease-in-out 5;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.alert-icon {
  font-size: 2rem;
}

.alert-text {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes alert-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* Alert toggle in settings */
.alert-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.alert-toggle-container label {
  font-size: 0.9rem;
}

.test-alert-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  margin-left: 0.5rem;
  border-radius: 4px;
}

/* Mobile: bigger alert banner */
@media (max-width: 600px) {
  .lap-alert-banner {
    font-size: 1.25rem;
    padding: 0.75rem;
  }
  
  .alert-icon {
    font-size: 1.5rem;
  }
}

/* ========== CURRENT LAP BRIEF PANEL ========== */
.lap-brief {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--catlap-yellow);
  margin-bottom: 1rem;
  overflow: hidden;
  max-width: 100%;
}

.lap-brief-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.lap-brief-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--catlap-yellow);
}

.lap-brief-countdown {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.countdown-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.countdown-time {
  font-size: 2.5rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: var(--catlap-yellow);
  line-height: 1;
}

.countdown-time.urgent {
  color: var(--catlap-pink);
  animation: countdown-pulse 0.5s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.lap-brief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

.lap-brief-section {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.brief-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.brief-speed {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.brief-speed.speed-slow { color: var(--catlap-green); }
.brief-speed.speed-average { color: var(--catlap-blue); }
.brief-speed.speed-fast { color: var(--catlap-orange); }

.brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.brief-action-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--catlap-pink);
  color: white;
  border-radius: 4px;
}

.brief-no-actions {
  font-size: 0.8rem;
  opacity: 0.6;
  font-style: italic;
}

/* Fuel targets */
.fuel-targets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.fuel-target {
  text-align: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.fuel-target-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--catlap-yellow);
}

.fuel-target-unit {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Crew checklist */
.checklist-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.checklist-item:hover {
  background: rgba(255, 255, 255, 0.2);
}

.checklist-item input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.checklist-item input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  opacity: 0.5;
}

.checklist-item.highlight {
  background: var(--catlap-pink);
  font-weight: 600;
}

.checklist-reset-btn {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: white;
  opacity: 0.7;
}

.checklist-reset-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile: stack the grid */
@media (max-width: 800px) {
  .lap-brief-grid {
    grid-template-columns: 1fr;
  }
  
  .countdown-time {
    font-size: 2rem;
  }
  
  .fuel-targets-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .checklist-items {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 500px) {
  .fuel-targets-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .checklist-items {
    grid-template-columns: 1fr 1fr;
  }
}

/* ========== RACE DAY BUTTON ========== */
.race-day-btn {
  background: rgba(255, 107, 53, 0.25);
  color: #ffaa80;
  font-weight: 600;
  border: 1px solid rgba(255, 107, 53, 0.5);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.race-day-btn:hover {
  background: rgba(255, 107, 53, 0.35);
}

.race-day-btn:active {
  background: rgba(255, 107, 53, 0.4);
}

/* ========== UNDO BUTTON ========== */
.undo-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--ink-muted);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.undo-btn:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.4);
  color: #ff6b6b;
}

/* ========== DUPLICATE WARNING ========== */
.duplicate-warning {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 180, 0, 0.15);
  border: 1px solid rgba(255, 180, 0, 0.4);
  border-radius: 8px;
  color: #ffcc00;
  font-size: 0.9rem;
}

.duplicate-warning strong {
  color: #ffdd44;
}

/* ========== UNDO BUTTON & DUPLICATE WARNING ========== */
.log-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.undo-btn {
  background: rgba(255, 107, 107, 0.2);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ff6b6b;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.undo-btn:hover {
  background: rgba(255, 107, 107, 0.3);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

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

.duplicate-warning {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: rgba(255, 180, 0, 0.15);
  border: 1px solid rgba(255, 180, 0, 0.5);
  color: var(--catlap-yellow);
  font-size: 0.85rem;
}

/* ========== LAP HEALTH STRIP ========== */
.lap-health-strip-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.lap-health-strip {
  display: flex;
  gap: 3px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.lap-health-cell {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
}

.lap-health-cell:hover {
  transform: scale(1.15);
  z-index: 10;
}

/* Fuel score fill colors */
.lap-health-good {
  background: var(--catlap-green);
}

.lap-health-warn {
  background: var(--catlap-orange);
}

.lap-health-bad {
  background: var(--catlap-pink);
}

.lap-health-empty {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
}

/* Caffeine indicator - top border */
.lap-health-caffeine {
  box-shadow: inset 0 3px 0 0 var(--catlap-purple);
}

/* Gear action indicator - bottom border */
.lap-health-gear {
  box-shadow: inset 0 -3px 0 0 var(--catlap-blue);
}

/* Both caffeine and gear */
.lap-health-caffeine.lap-health-gear {
  box-shadow: inset 0 3px 0 0 var(--catlap-purple), inset 0 -3px 0 0 var(--catlap-blue);
}

/* Tooltip on hover */
.lap-health-cell::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
}

.lap-health-cell:hover::after {
  opacity: 1;
}

/* Legend */
.lap-health-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-good {
  background: var(--catlap-green);
}

.legend-warn {
  background: var(--catlap-orange);
}

.legend-bad {
  background: var(--catlap-pink);
}

.legend-border-top {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 3px 0 0 var(--catlap-purple);
}

.legend-border-bottom {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 -3px 0 0 var(--catlap-blue);
}

/* Mobile: smaller cells */
@media (max-width: 500px) {
  .lap-health-cell {
    width: 22px;
    height: 22px;
    font-size: 0.55rem;
  }
}

/* ========== PACE COMPLIANCE LADDER ========== */
.pace-ladder-container {
  margin-top: 0.75rem;
}

.pace-ladder {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pace-ladder-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 28px;
}

.pace-ladder-lap {
  width: 35px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: right;
  flex-shrink: 0;
}

.pace-ladder-bar {
  flex: 1;
  height: 100%;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

/* Time scale background markers */
.pace-ladder-scale {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* The connecting line between plan and actual */
.pace-ladder-line {
  position: absolute;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 2px;
}

.pace-line-on-time {
  background: var(--catlap-green);
}

.pace-line-small-miss {
  background: var(--catlap-orange);
}

.pace-line-big-miss {
  background: var(--catlap-pink);
}

/* Plan dot */
.pace-ladder-plan {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--catlap-blue);
  border: 2px solid rgba(255, 255, 255, 0.8);
  z-index: 2;
}

/* Actual dot */
.pace-ladder-actual {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--catlap-yellow);
  border: 2px solid rgba(0, 0, 0, 0.3);
  z-index: 3;
}

/* Time labels */
.pace-ladder-time {
  width: 45px;
  font-size: 0.7rem;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.pace-ladder-time.actual-time {
  color: var(--catlap-yellow);
  font-weight: 600;
}

/* No data state */
.pace-ladder-empty {
  padding: 1rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* Legend */
.pace-ladder-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.legend-plan {
  background: var(--catlap-blue);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.legend-actual {
  background: var(--catlap-yellow);
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.legend-on-time {
  background: var(--catlap-green);
}

.legend-small-miss {
  background: var(--catlap-orange);
}

.legend-big-miss {
  background: var(--catlap-pink);
}

/* Tooltip */
.pace-ladder-row[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  margin-right: 0.5rem;
  z-index: 100;
}

.pace-ladder-row:hover[data-tooltip]::after {
  opacity: 1;
}

/* Mobile */
@media (max-width: 500px) {
  .pace-ladder-lap {
    width: 28px;
    font-size: 0.65rem;
  }
  
  .pace-ladder-time {
    width: 38px;
    font-size: 0.6rem;
  }
}

/* ========== GLOBAL MOBILE OVERFLOW FIX ========== */
@media (max-width: 768px) {
  * {
    max-width: 100vw !important;
  }
  
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
  }
  
  .crew-shell,
  .card,
  .lap-brief,
  table,
  .plan-table-wrapper,
  .chart-wrapper,
  .inline-fields,
  form {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  
  /* Allow log-table-wrapper to scroll horizontally */
  .log-table-wrapper {
    max-width: 100% !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
  }
  
  img, canvas, svg {
    max-width: 100%;
    height: auto;
  }
  
  /* Prevent any element from causing horizontal scroll - except table wrappers */
  .card > *:not(.log-table-wrapper),
  .lap-brief > *:not(.log-table-wrapper) {
    max-width: 100%;
    overflow-x: hidden;
  }
}


/* ========== PAGE NAVIGATION ========== */
.page-nav {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.nav-btn:active {
  transform: translateY(0);
}

/* ========== MOBILE TABLE FIX ========== */
@media (max-width: 600px) {
  /* Make tables horizontally scrollable on mobile */
  .log-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent table from squishing - set minimum widths */
  .log-table-wrapper table {
    min-width: 600px;
    table-layout: auto;
  }
  
  /* Session log table (fewer columns) */
  .log-form + .log-summary + .log-table-wrapper table {
    min-width: 500px;
  }
  
  /* Make sure cells don't wrap awkwardly */
  .log-table-wrapper th,
  .log-table-wrapper td {
    white-space: nowrap;
    padding: 0.4rem 0.6rem;
  }
  
  /* Hint that table is scrollable */
  .log-table-wrapper::after {
    content: '← scroll →';
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--ink-muted);
    padding: 0.25rem;
    opacity: 0.6;
  }
}

/* ========== QUICK WIN #8: BIGGER TAP TARGETS ========== */
#logSubmitBtn {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 56px;
  min-width: 160px;
  border-radius: 8px;
  background: rgba(0, 200, 83, 0.25);
  border: 2px solid rgba(0, 200, 83, 0.5);
  color: #66ff88;
}

#logSubmitBtn:hover {
  background: rgba(0, 200, 83, 0.35);
}

#logSubmitBtn:active {
  background: rgba(0, 200, 83, 0.4);
}

/* Undo button slightly bigger too */
#undoLastBtn {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  min-height: 48px;
  border-radius: 8px;
}

/* Mobile: even bigger */
@media (max-width: 600px) {
  #logSubmitBtn {
    width: 100%;
    padding: 1.25rem 2rem;
    font-size: 1.2rem;
    min-height: 64px;
  }
  
  #undoLastBtn {
    width: 100%;
    margin-top: 0.5rem;
  }
  
  .log-actions {
    flex-direction: column;
  }
}

/* ========== QUICK WIN #9: LAST LAP SUMMARY ========== */
.last-lap-confirmation {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 200, 83, 0.15);
  border: 1px solid rgba(0, 200, 83, 0.3);
  border-radius: 8px;
  font-size: 0.95rem;
  color: #a0ffb0;
  display: none;
}

.last-lap-confirmation.show {
  display: block;
  animation: slideIn 0.3s ease-out;
}

.last-lap-confirmation strong {
  color: #66ff88;
}

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

/* ========== QUICK WIN #7: PRINT SUMMARY ========== */
.print-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--ink-soft);
}

.print-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Print styles */
@media print {
  /* Hide non-essential elements */
  .page-nav,
  .chart-wrapper,
  canvas,
  button,
  .nav-btn,
  .inline-fields,
  .pace-ladder-container,
  .intake-legend {
    display: none !important;
  }
  
  /* Reset dark mode for printing */
  body {
    background: white !important;
    color: black !important;
  }
  
  .crew-shell {
    max-width: 100% !important;
    padding: 0.5in !important;
  }
  
  .card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 1rem !important;
  }
  
  .card h2 {
    color: black !important;
    border-bottom: 2px solid black;
    padding-bottom: 0.25rem;
  }
  
  .stat-value {
    color: black !important;
  }
  
  .stat-label,
  .stat-line-label {
    color: #333 !important;
  }
  
  .stat-line-value {
    color: black !important;
  }
  
  .stat-line-badge {
    background: #eee !important;
    color: #333 !important;
  }
  
  .crew-tag {
    background: black !important;
    color: white !important;
  }
  
  .crew-title {
    color: black !important;
  }
  
  /* Show print timestamp */
  .stats-card::after {
    content: "Printed: " attr(data-print-time);
    display: block;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #666;
  }
}