body {
  font-family: sans-serif;
  margin: 40px;
  line-height: 1.5;
}

h1,
h2 {
  margin-top: 32px;
}

/* ── Day wrapper: rotated label + table side-by-side ── */
.day-wrapper {
  display: flex;
  align-items: stretch;
  margin-bottom: 24px;
  border: 2px solid #999;
}

.day-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  font-weight: bold;
  font-size: 1rem;
  padding: 8px 6px;
  background: #d9d9d9;
  border-right: 2px solid #999;
  white-space: nowrap;
  min-width: 28px;
}

/* ── Column widths ── */
col.col-exercise  { width: auto; }
col.col-sets      { width: 42px; }
col.col-reps      { width: 70px; }
col.col-weight    { width: 60px; }
col.col-set       { width: 80px; }
col.col-notes     { width: 220px; }
col.col-increment { width: 72px; }

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  flex: 1;
}

thead tr {
  background: #d9d9d9;
}

th {
  border: 1px solid #999;
  padding: 6px 10px;
  text-align: center;
  font-weight: bold;
  font-size: 0.85rem;
}

th:first-child {
  text-align: left;
}

td {
  border: 1px solid #ccc;
  padding: 6px 10px;
  text-align: left;
  font-size: 0.85rem;
}

td.center {
  text-align: center;
}

td.inactive {
  background: #c0c0c0;
}

/* Alternate row shading */
tbody tr:nth-child(even) td:not(.inactive):not(.cell-good):not(.cell-bad) {
  background: #f2f2f2;
}

/* ── Index table ── */
.index-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.index-table th,
.index-table td {
  border: 1px solid #999;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.index-table thead tr:first-child th {
  background: #d9d9d9;
  font-weight: bold;
  text-align: center;
}

.index-table thead tr:first-child th:first-child {
  text-align: left;
}

.index-table th.subheader {
  background: #ebebeb;
  font-weight: normal;
  font-size: 0.75rem;
  text-align: center;
  color: #555;
}

.index-table th.sorted-asc::after  { content: " ↑"; }
.index-table th.sorted-desc::after { content: " ↓"; }

.cell-good,
.targets-table td.cell-good { background: #d4edda; }
.cell-bad,
.targets-table td.cell-bad  { background: #f8d7da; }

/* ── Filter panel ── */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.filter-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-weight: bold;
  gap: 4px;
}

.filter-panel input,
.filter-panel select {
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 90px;
}

.filter-panel input[type="text"] {
  width: 140px;
}

/* ── Nav link ── */
.nav-link {
  font-size: 0.85rem;
  font-weight: normal;
  margin-left: 16px;
  text-decoration: none;
  color: #555;
}

.nav-link:hover {
  text-decoration: underline;
}

/* ── Builder ── */
.builder-section {
  margin-bottom: 32px;
}

.builder-section h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.hint {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 10px;
}

.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: bold;
  gap: 4px;
}

.field-row input {
  font-size: 0.9rem;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 220px;
}

.day-block {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fafafa;
}

.day-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.day-name {
  font-size: 0.9rem;
  font-weight: bold;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 200px;
}

.exercise-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.ex-select {
  width: 200px;
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.ex-custom-name {
  width: 160px;
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.unknown-exercise .ex-custom-name {
  border-color: #e8a000;
  background: #fffbe6;
}

.ex-sets {
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 70px;
}

.ex-reps {
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 110px;
}

.btn-add,
.btn-add-exercise {
  font-size: 0.85rem;
  padding: 5px 12px;
  border: 1px dashed #999;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  margin-top: 4px;
}

.btn-add:hover,
.btn-add-exercise:hover {
  background: #f0f0f0;
}

.btn-remove {
  font-size: 1rem;
  line-height: 1;
  padding: 2px 7px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  color: #888;
}

.btn-remove:hover {
  background: #fee;
  color: #c00;
  border-color: #c00;
}

.targets-table {
  border-collapse: collapse;
  font-size: 0.85rem;
}

.targets-table th,
.targets-table td {
  border: 1px solid #ccc;
  padding: 5px 10px;
}

.targets-table thead th {
  background: #d9d9d9;
  font-weight: bold;
}

.targets-table input[type="number"] {
  width: 60px;
  padding: 3px 5px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.85rem;
}

.targets-table input[disabled] {
  background: #f0f0f0;
  color: #aaa;
}

.btn-download {
  font-size: 1rem;
  padding: 10px 24px;
  background: #2a6;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.btn-download:hover {
  background: #1e8a50;
}

/* ── Preview page ── */
#yaml-input {
  display: block;
  width: 100%;
  height: 260px;
  font-family: monospace;
  font-size: 0.85rem;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  resize: vertical;
  margin-bottom: 12px;
}

.preview-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.parse-error {
  color: #c00;
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ── Print ── */
@page {
  size: letter portrait;
  margin: 0.4in 0.6in;
}

@media print {
  body {
    margin: 0;
    font-size: 9pt;
  }

  h1 {
    font-size: 13pt;
    margin-top: 0;
    margin-bottom: 10pt;
  }

  .day {
    page-break-after: avoid;
    break-after: avoid;
  }

  .day-wrapper {
    page-break-inside: avoid;
  }

  tr {
    page-break-inside: avoid;
  }

  input {
    border: none;
  }

  button {
    display: none;
  }

  /* Fit 7-day programs onto one portrait page */
  #app.compact-print {
    font-size: 8pt;
  }

  #app.compact-print h1 {
    font-size: 12pt;
    margin-bottom: 16pt;
  }

  #app.compact-print .day-wrapper {
    margin-bottom: 16px;
  }

  #app.compact-print th,
  #app.compact-print td {
    padding: 3px 6px;
    font-size: 8pt;
    white-space: nowrap;
  }

  #app.compact-print .day-label {
    padding: 4px 4px;
    min-width: 22px;
  }

  #app.compact-print col.col-notes     { width: 130px; }
  #app.compact-print col.col-increment { width: 55px; }
  #app.compact-print col.col-set       { width: 55px; }
  #app.compact-print col.col-weight    { width: 48px; }
  #app.compact-print col.col-reps      { width: 48px; }
  #app.compact-print col.col-sets      { width: 32px; }
}
