* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d8e0ea;
  --border-soft: #e6ebf1;
  --text: #1f2937;
  --muted: #64748b;
  --brand: #1f6fb2;
  --brand-dark: #155a91;
  --success: #166534;
  --danger: #991b1b;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  padding: 14px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-size: 13px;
  letter-spacing: 0;
}

.container {
  max-width: 1220px;
  margin: auto;
  padding: 28px 24px 48px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.hero h1 {
  font-size: 34px;
  margin: 0 0 6px;
}

.hero p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  align-items: start;
}

.card,
.table-card {
  background: var(--surface);
  padding: 22px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  display: grid;
  grid-template-columns: 220px minmax(240px, 1fr);
  gap: 12px 18px;
  align-items: center;
}

h2 {
  grid-column: 1 / -1;
  margin-top: 0;
  color: var(--brand);
}

label {
  font-weight: 700;
  color: #334155;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 15px;
  background: white;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.checkbox-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31,111,178,0.18);
}

button {
  display: block;
  margin: 32px auto;
  padding: 13px 26px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

input[type="range"] {
  padding: 0;
}

.slider-control {
  display: grid;
  gap: 8px;
}

.slider-control output {
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 24px auto;
}

.action-row button {
  margin: 0;
}

.export-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.export-button {
  margin: 0;
}

.export-status {
  min-width: 110px;
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
}

.resource-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr 0.85fr;
  gap: 18px;
  margin-top: 28px;
}

.resource-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.resource-card h2 {
  margin-bottom: 12px;
}

.resource-card ul {
  margin: 0;
  padding-left: 20px;
}

.resource-card li {
  margin-bottom: 10px;
}

.suggestions-list {
  display: grid;
  gap: 10px;
  padding-left: 0 !important;
}

.suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 0;
}

.suggestion-status {
  display: block;
  min-height: 18px;
  margin-top: 10px;
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
}

.suggestions-list li {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
}

.suggestion-content {
  display: grid;
  gap: 4px;
}

.suggestion-content small {
  color: var(--muted);
  line-height: 1.4;
}

.suggestion-empty {
  color: var(--muted);
}

.suggestion-remove {
  margin: 0;
  padding: 5px 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: white;
  color: var(--danger);
  border: 1px solid #fecaca;
  font-size: 12px;
}

.suggestion-remove:hover {
  background: #fee2e2;
}

.resource-card p {
  color: var(--muted);
  line-height: 1.5;
}

.resource-note {
  margin-top: -4px;
  margin-bottom: 12px;
  font-size: 14px;
}

.privacy-note {
  margin: -2px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
  font-size: 13px;
}

.resource-card a {
  color: var(--brand);
  font-weight: 700;
}

.donation-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.donation-note-label {
  font-size: 13px;
}

.donation-note-input {
  min-height: 82px;
}

.donation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.donation-button {
  flex: 1 1 120px;
  text-align: center;
}

.donation-signature {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.disabled-link,
.disabled-link:hover {
  cursor: not-allowed;
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--muted);
}

.saved-plans-card {
  align-self: stretch;
}

.saved-plans-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.saved-plans-list {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
}

.saved-plans-empty {
  margin: 0;
  color: var(--muted);
}

.saved-plan-row {
  display: flex;
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
  font-weight: 400;
}

.saved-plan-row input {
  width: auto;
  margin-top: 3px;
}

.saved-plan-row span {
  display: grid;
  gap: 3px;
}

.saved-plan-row small {
  color: var(--muted);
}

.danger-button {
  border-color: #fecaca;
  color: var(--danger);
}

.danger-button:hover {
  background: #fee2e2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: white;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.secondary-button:hover {
  background: #eaf3fb;
}

.compact-button {
  margin: 0;
  flex: 0 0 auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 24px 0 18px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.summary-card strong {
  font-size: 26px;
  color: var(--text);
}

.table-card {
  overflow-x: auto;
}

.chart-card {
  margin-bottom: 22px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chart-header h2 {
  margin-bottom: 0;
}

.chart-header select {
  max-width: 220px;
}

#mileageChart {
  display: block;
  width: 100%;
  height: 260px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
}

th,
td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}

th {
  background: var(--brand);
  color: white;
}

tr:nth-child(even) {
  background: #f8fafc;
}

.role-cell {
  font-weight: 700;
  border-radius: 8px;
}

.easy {
  background: #dcfce7;
  color: #166534;
}

.workout {
  background: #fee2e2;
  color: #991b1b;
}

.mid {
  background: #ede9fe;
  color: #5b21b6;
}

.long {
  background: #dbeafe;
  color: #1e40af;
}

.off {
  background: #e5e7eb;
  color: #374151;
}

.race-day {
  background: #ede9fe;
  color: #5b21b6;
}

.custom-day {
  background: #dcfce7;
  color: #166534;
}

.race-day-cell {
  box-shadow: inset 0 0 0 2px #5b21b6;
}

.custom-day-cell {
  box-shadow: inset 0 0 0 2px #166534;
}

@media (max-width: 900px) {
  .app-grid,
  .summary-grid,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 22px 16px 36px;
  }

  .navbar {
    flex-direction: column;
    gap: 14px;
    padding: 14px 18px;
  }

  .hero {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .chart-header {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-header select {
    max-width: none;
  }

  .card,
  .custom-panel {
    grid-template-columns: 1fr;
  }

  .checkbox-row {
    align-items: start;
  }

  .export-bar,
  .feature-tabs {
    align-items: stretch;
  }

  .export-button,
  .feature-tab {
    width: 100%;
  }
}

.feature-tabs {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.feature-tab {
  margin: 0;
  background: white;
  color: var(--brand);
  border: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 14px;
}

.feature-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.hidden {
  display: none;
}

.custom-panel {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 220px minmax(240px, 1fr);
  gap: 12px 18px;
  align-items: center;
}

.custom-panel.hidden {
  display: none;
}

.race-weeks-list,
.override-list {
  display: grid;
  gap: 16px;
  grid-column: 1 / -1;
}

.race-week-row,
.week-override-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
}

.week-override-row {
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto;
}

.week-day-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 10px;
}

.race-field,
.override-field {
  display: grid;
  gap: 6px;
}

.race-field label,
.override-field label {
  font-size: 13px;
}

.inline-button {
  margin: 0;
  padding: 11px 18px;
  font-size: 14px;
}

.remove-race-button {
  align-self: end;
}

@media (max-width: 900px) {
  .custom-panel {
    grid-template-columns: 1fr;
  }

  .race-week-row {
    grid-template-columns: 1fr;
  }

  .week-override-row {
    grid-template-columns: 1fr;
  }

  .week-day-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }

  .navbar,
  .hero,
  .feature-tabs,
  .app-grid,
  .custom-panel,
  .action-row,
  .export-bar,
  .resource-grid,
  .chart-card {
    display: none !important;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .summary-grid,
  .table-card {
    box-shadow: none;
  }

  .summary-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .summary-card,
  .table-card {
    border: 1px solid #d1d5db;
  }

  table {
    font-size: 11px;
  }

  th,
  td {
    padding: 7px;
  }
}
