.training-table-wrap {
  touch-action: none !important;
  overscroll-behavior: contain;
  scroll-behavior: auto !important;
  will-change: scroll-position;
}

.training-table .id-shared {
  background: #eef2f1 !important;
  border-right: 2px solid #b7c5c0 !important;
  padding: 6px 4px !important;
}

.training-table .exercise-shared {
  background: #e7f5ec !important;
  border-left: 2px solid #fff !important;
  border-right: 2px solid #9fc7b0 !important;
}

.training-table .id-shared .readonly,
.training-table .exercise-shared .readonly {
  background: transparent !important;
}

.training-table .id-shared .readonly {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  padding: 4px 2px !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  text-align: center;
}

.training-table tbody tr td {
  background: #fff !important;
}

.training-table tbody tr.routine-row-active td {
  background: #fff4e8 !important;
  border-top-color: #f28c28;
  border-bottom-color: #f28c28;
}

.training-table tbody tr.routine-row-complete td {
  background: #f3f7f5 !important;
  color: #52605b;
}

.training-table tbody tr.routine-row-locked td {
  background: #fff !important;
  color: #87918e;
}

.training-table .cell-input,
.training-table input,
.training-table textarea,
.training-table select {
  pointer-events: none;
}

.quick-progress-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.quick-progress-strip span,
.quick-rest-card {
  border: 1px solid #dce3df;
  background: #f7faf8;
  padding: 10px;
  font-weight: 800;
}

.quick-rest-card {
  display: grid;
  gap: 8px;
}

.quick-timer-actions {
  margin: 0;
}

.quick-note-field,
.quick-reason-field {
  grid-column: 1 / -1;
}

.quick-note-field textarea,
.quick-reason-field select {
  width: 100%;
}

.app-notice {
  pointer-events: none;
}

@media (max-width: 720px) {
  .quick-progress-strip {
    grid-template-columns: 1fr;
  }
}

/* Compact table: detailed sets open only when the PR control is pressed. */
.training-table.series-collapsed .series-detail-column {
  display: none !important;
}

.pr-header-toggle {
  display: grid;
  width: 100%;
  min-width: 104px;
  gap: 4px;
  justify-items: center;
  border: 1px solid #6eb695;
  border-radius: 4px;
  background: #173d39;
  color: #fff;
  padding: 6px 4px;
  cursor: pointer;
}

.pr-header-toggle small {
  color: #dcebe5;
  font-size: 9px;
  line-height: 1.2;
  text-transform: none;
}

.pr-toggle-cell {
  min-width: 112px;
  background: #edf8f1 !important;
}


/* Collapsible body-measure evolution. */
.measure-evolution-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.measure-evolution-panel > summary,
.measure-chart-card > summary {
  cursor: pointer;
  list-style-position: inside;
}

.measure-evolution-panel > summary h2,
.measure-evolution-panel > summary p {
  margin: 0;
}

.measure-evolution-panel > .measure-chart-grid {
  margin-top: 12px;
}

.measure-chart-card {
  display: block !important;
  min-width: 0;
  padding: 0 !important;
  overflow: hidden;
}

.measure-chart-card > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.measure-chart-card > summary small {
  color: var(--muted);
  text-align: right;
}

.measure-chart-content {
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.measure-chart-content svg {
  display: block;
  width: 100%;
  max-height: 180px;
}

.measure-record-list {
  display: grid;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.measure-record-list span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
}

.measure-record-list time {
  color: var(--muted);
}

@media (max-width: 720px) {
  .measure-chart-grid {
    grid-template-columns: 1fr !important;
  }

  .measure-chart-card > summary {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .measure-chart-card > summary small {
    text-align: left;
  }
}

/* Keep every table header visible inside its own scrollable viewport. */
.table-wrap,
.training-table-wrap,
.progress-table-wrap {
  position: relative !important;
  width: 100%;
  max-width: 100%;
  max-height: min(70vh, 720px) !important;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: auto;
  touch-action: none !important;
  scroll-behavior: auto !important;
}

/* Compact structural columns. */
.training-table th:nth-child(1),
.training-table td:nth-child(1) {
  width: 105px !important;
  min-width: 105px !important;
  max-width: 105px !important;
}

.training-table th:nth-child(3),
.training-table td:nth-child(3) {
  width: 76px !important;
  min-width: 76px !important;
  max-width: 76px !important;
}

.training-table thead th {
  height: auto !important;
  min-height: 0 !important;
  padding: 6px 5px !important;
  line-height: 1.15;
}

.training-table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.training-table thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 80 !important;
}

.training-table-wrap .training-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 81 !important;
  background: #102a34 !important;
  color: #fff !important;
}

/* Professional quick-entry layout on desktop. */
.frequency-dialog {
  width: min(780px, calc(100vw - 24px));
}

.quick-set-row {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  align-items: stretch !important;
}

.quick-set-heading,
.quick-rest-card,
.quick-note-field,
.quick-reason-field {
  grid-column: 1 / -1 !important;
}

.quick-set-heading {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.quick-set-row > label:not(.quick-note-field):not(.quick-reason-field) {
  align-content: start;
  min-width: 0;
}

.quick-rest-card {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto !important;
  align-items: center;
}

.quick-timer-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

@media (max-width: 720px) {
  .quick-set-row,
  .quick-rest-card {
    grid-template-columns: 1fr !important;
  }

  .quick-timer-actions {
    justify-content: stretch;
  }

  .quick-timer-actions > * {
    flex: 1;
  }
}

.table-wrap table thead th,
.training-table-wrap table thead th,
.progress-table-wrap table thead th,
table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 30 !important;
  background: #102a34 !important;
  color: #fff !important;
  box-shadow: inset 0 -2px 0 #f28c28;
}

@media (max-width: 720px) {
  .table-wrap,
  .training-table-wrap,
  .progress-table-wrap {
    max-height: 66vh !important;
  }
}

/* Compact, contained exercise progress panel. */
.exercise-progress-card {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.exercise-progress-card > summary.progress-card-head {
  align-items: center;
  margin: 0;
  cursor: pointer;
  list-style-position: inside;
}

.exercise-progress-card > summary.progress-card-head::marker {
  color: var(--brand);
}

.exercise-progress-content {
  min-width: 0;
  max-width: 100%;
  padding-top: 16px;
  overflow: hidden;
}

.exercise-progress-content .progress-exercise-filter {
  display: block;
  width: min(100%, 420px);
  margin-bottom: 12px;
}

.exercise-volume-chart {
  width: 100%;
  min-width: 0;
  min-height: 190px;
  max-width: 100%;
  padding: 12px;
  overflow: hidden;
}

.exercise-volume-chart .progress-bars {
  width: 100%;
  max-width: 100%;
  height: 145px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.exercise-volume-chart .progress-empty {
  min-height: 110px;
  padding: 20px 12px;
}

.exercise-comparison-wrap,
.progress-table-wrap {
  min-width: 0;
  max-width: 100%;
}

.progress-table-wrap {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

@media (max-width: 720px) {
  .exercise-progress-card {
    padding: 14px;
  }

  .exercise-progress-card > summary.progress-card-head {
    display: block;
  }

  .exercise-progress-card > summary.progress-card-head h3 {
    margin-top: 5px;
    font-size: 18px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .exercise-volume-chart {
    min-height: 170px;
    padding: 10px;
  }

  .exercise-volume-chart .progress-bars {
    height: 125px;
    gap: 6px;
  }

  .progress-bar-column {
    flex-basis: 42px;
  }
}

/* Responsive exercise evolution: compact summary and mobile cards. */
.progress-first-record {
  display: grid;
  min-height: 112px;
  align-content: center;
  justify-items: center;
  gap: 5px;
  text-align: center;
}

.progress-first-record span,
.progress-first-record small {
  color: var(--muted);
}

.progress-first-record strong {
  color: var(--brand);
  font-size: 30px;
}

.progress-first-record small {
  max-width: 420px;
  line-height: 1.35;
}

.progress-mobile-list {
  display: none;
}

@media (max-width: 720px) {
  .exercise-progress-content {
    padding-top: 10px;
  }

  .exercise-volume-chart {
    min-height: 0 !important;
    padding: 10px !important;
  }

  .exercise-volume-chart .progress-bars {
    height: 104px !important;
    margin-top: 6px;
    padding-top: 12px;
  }

  .exercise-volume-chart .progress-bar-column {
    grid-template-rows: 18px minmax(0, 1fr) 24px;
  }

  .progress-first-record {
    min-height: 96px;
  }

  .progress-table-wrap {
    display: none !important;
  }

  .progress-mobile-list {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }

  .progress-mobile-card {
    display: grid;
    gap: 9px;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
  }

  .progress-mobile-card header,
  .progress-mobile-card footer,
  .progress-mobile-card > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
  }

  .progress-mobile-card header {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .progress-mobile-card header .progress-change {
    justify-self: end;
  }

  .progress-mobile-card span {
    display: grid;
    gap: 2px;
    min-width: 0;
    color: var(--muted);
    font-size: 11px;
  }

  .progress-mobile-card b,
  .progress-mobile-card strong {
    color: var(--ink);
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .progress-mobile-card footer {
    padding: 9px;
    background: #f2f8f5;
  }

  .progress-mobile-card footer strong {
    justify-self: end;
  }
}
