:root {
  --bg-page: #0f1419;
  --bg-surface: #1a222d;
  --bg-card: #242f3d;
  --bg-input: #1e2733;
  --border: #3a4a5c;
  --text: #e8edf2;
  --text-muted: #8b9aab;
  --accent: #3dd68c;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max-w: 480px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: #080b0f;
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}

.app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
}

.app-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
}

.app-main {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.app-footer {
  border-top: 1px solid var(--border);
  display: flex;
}

.nav-item {
  flex: 1;
  text-align: center;
  padding: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
}

.nav-item.active { color: var(--accent); }

.btn {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #0a120e;
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field-input {
  padding: 0.875rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.error-text { color: #f07178; }

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.list-item {
  display: block;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.home-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.home-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-admin-btn {
  display: block;
  padding: 0.65rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

.home-admin-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-logout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1rem;
}

.logout-form { margin: 0; }

.flash {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.top-bar { margin-bottom: 0.75rem; }

.back-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.section-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.5rem;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.admin-row-main .name {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.admin-row-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
}

.inline-form { display: inline; }

.inline-add { margin: 0.5rem 0 1rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  text-decoration: none;
}

.btn-link.danger { color: #f07178; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.5rem 0;
  text-align: left;
  width: auto;
}

.badge {
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.weighted {
  background: rgba(61, 214, 140, 0.15);
  color: var(--accent);
}

.config-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 100%;
}

.settings-form { margin-top: 0.5rem; }

.hidden { display: none !important; }

.date-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.workout-title { margin-bottom: 1rem; }

.page-heading {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.workout-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.workout-grid th,
.workout-grid td {
  padding: 0.5rem 0.35rem;
  text-align: center;
  vertical-align: middle;
}

.workout-grid th:first-child,
.workout-grid td:first-child {
  text-align: left;
  min-width: 8rem;
}

.workout-grid .sets-col-header,
.workout-grid .sets-col {
  text-align: left;
}

.set-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-start;
}

.set-cell {
  min-width: 2.5rem;
  text-align: center;
}

.workout-name-form {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.workout-save-btn {
  margin-top: 1.5rem;
}

.workout-grid th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
}

.exercise-btn,
.exercise-record-form .exercise-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.exercise-record-form { margin: 0; }

.type-hint {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.cell-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 100%;
}

.cell-filled {
  display: inline-block;
  padding: 0.35rem 0.5rem;
  background: rgba(61, 214, 140, 0.15);
  color: var(--accent);
  font-weight: 600;
  border-radius: 6px;
}

.cell-filled.compact {
  font-size: 0.7rem;
  line-height: 1.2;
  padding: 2px 4px;
}

.cell-tick {
  color: var(--accent);
  font-size: 1.1rem;
}

.cell-empty { color: var(--border); }

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
}

.overlay-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
  box-sizing: border-box;
}

.timer-display {
  font-size: 3.5rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 1rem 0;
}

.timer-label {
  color: var(--text-muted);
  font-size: 1rem;
}

.timer-set-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin-top: 1.5rem;
}

.overlay-inner form {
  width: 100%;
}

.overlay-actions.row {
  flex-direction: row;
  max-width: 100%;
}

.overlay-actions.row .btn { flex: 1; }

.btn-danger-outline {
  background: transparent;
  color: #f07178;
  border: 1px solid #f07178;
}

.btn-sm {
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(8, 11, 15, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 300px;
  border: 1px solid var(--border);
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1rem;
}

.modal-actions .btn { flex: 1; }

.duration-row {
  display: flex;
  gap: 0.5rem;
}

.duration-row .field-input:first-child {
  flex: 1;
}

.duration-unit {
  flex: 0 0 7rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}

.history-item .date-box {
  text-align: center;
  min-width: 44px;
}

.history-item .date-box .day {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.history-item .date-box .month {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.history-item .info {
  flex: 1;
  min-width: 0;
}

.history-item .info .name {
  font-weight: 600;
  font-size: 0.95rem;
}

.history-item .info .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.complete-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.complete-dot.partial {
  background: var(--warning);
}

.chevron {
  color: var(--text-muted);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.read-only-grid .cell-filled {
  display: inline-block;
  min-width: 2.5rem;
}
