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

  --page-bg: var(--catlap-yellow);
  --ink: var(--catlap-black);
  --ink-soft: #222222;

  --max-width: 1100px;
  --card-bg: #fffdf1;
  --border-radius: 10px;
}

* {
  box-sizing: border-box;
}

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

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

.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-black);
  color: var(--catlap-yellow);
  width: fit-content;
}

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

.crew-subtitle {
  margin: 0;
  font-size: 0.9rem;
  max-width: 600px;
}

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

/* 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);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 0 var(--catlap-black);
  border: 2px solid var(--catlap-black);
}

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

.card small {
  font-size: 0.8rem;
  color: #555;
}

/* 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;
}

.form-field input,
.form-field select,
.form-field textarea {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #bbb;
  min-width: 0;
}

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

button {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid var(--catlap-black);
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  background: var(--catlap-blue);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--catlap-black);
  white-space: nowrap;
}

button:hover {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--catlap-black);
}

button.secondary {
  background: #fff;
}

/* 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(--catlap-black);
  background: #fff;
  font-weight: 600;
}

.time-pill strong {
  font-weight: 800;
}

/* Assistance table */

.assist-table-wrapper {
  margin-top: 0.75rem;
  max-height: 380px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fffef5;
}

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

thead {
  position: sticky;
  top: 0;
  background: #fceea9;
  z-index: 1;
}

th, td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eee;
  vertical-align: top;
  text-align: left;
}

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 #ccc;
  background: #fffef5;
}

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

.plan-table thead {
  position: sticky;
  top: 0;
  background: #fceea9;
  z-index: 1;
}

.plan-table th,
.plan-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}

.plan-row-current {
  background: #e5ffe0;
}

.plan-row-current td {
  border-bottom-color: #b7f3a6;
}

/* speed colours */
.plan-speed-slow {
  font-weight: 700;
  color: #b40000;
}

.plan-speed-average {
  font-weight: 700;
  color: #c17d00;
}

.plan-speed-fast {
  font-weight: 700;
  color: #1b7c2b;
}

.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-black);
  font-size: 0.7rem;
  background: #fff;
}

/* pacing plan speed colors */
.plan-speed-slow {
  color: #b40000;      /* red */
  font-weight: 700;
}

.plan-speed-average {
  color: #c17d00;      /* yellow / amber */
  font-weight: 700;
}

.plan-speed-fast {
  color: #1b7c2b;      /* green */
  font-weight: 700;
}

.hour-row-current {
  background: #e5ffe0;
}

.hour-row-current td {
  border-bottom-color: #b7f3a6;
}

/* 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;
}

/* Summary + tables */

.log-summary {
  margin-top: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: #fff7d4;
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.log-summary strong {
  font-weight: 800;
}

.log-table-wrapper {
  margin-top: 0.75rem;
  max-height: 320px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fffef5;
}

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

.fuel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

/* Base fuel pill */
.fuel-btn {
  font: inherit;
  font-size: 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--catlap-black);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--catlap-black);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  text-align: center;
}

.fuel-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--catlap-black);
}

/* Variants by type */
.fuel-btn.food-fuel {
  background: var(--catlap-green);
}

.fuel-btn.liquid-fuel {
  background: var(--catlap-blue);
}

.fuel-btn.hybrid-fuel {
  background: var(--catlap-purple);
}

/* Optional: make "other" a neutral pill */
.fuel-btn.other-fuel {
  background: #fffdf1;
}

/* Fuel summary text */
.fuel-summary {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: #555;
}

/* Reset fuel button – visually distinct but related */
.fuel-reset-btn {
  margin-top: 0.5rem;
  background: #ffe5e5;
  border-color: #b40000;
}

.fuel-reset-btn:hover {
  background: #ffd0d0;
}



.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: #fffef5;
  border-radius: 10px;
  border: 1px solid #e0c869;
  padding: 0.5rem;
  height: 260px;
}

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

.mood-good { color: #1b7c2b; }
.mood-ok   { color: #c17d00; }
.mood-bad  { color: #b40000; }

.crew-footer-note {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0.8;
}

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

.plan-row-current {
  background: #e5ffe0;
}

.plan-row-current td {
  border-bottom-color: #b7f3a6;
}

/* =========================
   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 */
  .card-clock-plan .plan-table tr {
    display: block;
    margin-bottom: 0.75rem;
    border-radius: 10px;
    border: 2px solid var(--catlap-black);
    background: #fffef5;
    box-shadow: 0 2px 0 var(--catlap-black);
    padding: 0.4rem 0.55rem;
  }

  /* Extra pop for current lap */
  .card-clock-plan .plan-table tr.plan-row-current {
    background: #e5ffe0;
    border-color: #1b7c2b;
    box-shadow: 0 2px 0 #1b7c2b;
  }

  .card-clock-plan .plan-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: none;
    padding: 0.15rem 0;
    font-size: 0.8rem;
  }

  /* 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: #666;
    margin-right: 0.4rem;
  }

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

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

  /* 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;
  }

  /* Give the whole card section a bit more breathing room */
  .card-clock-plan .plan-table-wrapper {
    max-height: none;
  }
}

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

.plan-controls button {
  font-size: 0.8rem;
}

/* Make fuel buttons a bit bigger and easier to hit */
.fuel-buttons {
  gap: 0.5rem;
}

.fuel-btn {
  font-size: 0.9rem;
  padding: 0.35rem 0.9rem;
}

/* Reset button visually distinct */
.fuel-reset-btn {
  margin-top: 0.5rem;
  background: #ffe5e5;
  border-color: #b40000;
}

.fuel-reset-btn:hover {
  background: #ffd0d0;
}
