:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c677d;
  --border: #dde3ea;
  --primary: #e85d04;
  --primary-hover: #d45103;
  --danger: #c1121f;
  --success: #2d6a4f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.topbar {
  background: #152238;
  color: #fff;
  padding: 0.85rem 1.25rem;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.lang-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.2);
}

.coach-info {
  font-size: 0.9rem;
  opacity: 0.9;
}

.workout-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.workout-edit-grid label {
  font-size: 0.8rem;
}

.workout-save-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.add-workout-panel {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
}

.add-workout-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.save-ok {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.auth-panel {
  max-width: 420px;
  margin: 2rem auto 0;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: #152238;
  color: #fff;
  border-color: #152238;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

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

.btn {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.full-width {
  grid-column: 1 / -1;
}

.tri-only-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
}

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

.field-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.25rem;
}

.athlete-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.athlete-card.inactive {
  opacity: 0.65;
}

.athlete-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.athlete-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-draft {
  background: #fff3cd;
  color: #856404;
}

.badge-approved {
  background: #d1e7dd;
  color: #0f5132;
}

.badge-pushed {
  background: #cfe2ff;
  color: #084298;
}

.badge-rejected {
  background: #f8d7da;
  color: #842029;
}

.badge-generating {
  background: #e2e3e5;
  color: #41464b;
}

.context-card-volume .volume-editor {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.volume-target-input {
  width: 4.5rem;
  padding: 0.35rem 0.45rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.volume-planned-line {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

.workout-structure-host {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.structure-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.structure-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.structure-summary {
  font-size: 0.75rem;
  color: var(--muted);
}

.structure-summary-text {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.workout-timeline {
  display: flex;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  margin: 0.5rem 0 0.75rem;
  border: 1px solid var(--border);
}

.timeline-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: #fff;
  min-width: 3px;
  overflow: hidden;
  white-space: nowrap;
}

.timeline-segment span {
  padding: 0 2px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.interval-block-editor {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
}

.block-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.block-header-row .block-label {
  flex: 1 1 120px;
  font-weight: 600;
}

.block-repeat-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.block-repeat {
  width: 3rem;
}

.interval-step-row {
  display: grid;
  grid-template-columns: 1fr 4rem auto 3rem auto auto;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.interval-step-row input {
  padding: 0.3rem 0.4rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.step-unit,
.step-zone-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.f-exercise-plan {
  width: 100%;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  resize: vertical;
}

.exercise-plan-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.exercise-plan-list li {
  margin-bottom: 0.25rem;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.context-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.context-card strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.workout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.workout-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.workout-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: var(--muted);
}

.workout-notes {
  margin-top: 0.75rem;
}

.back-btn {
  margin-bottom: 1rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

.success-banner {
  background: #d1e7dd;
  color: var(--success);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 1.5rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 34, 56, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 100;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .grid-form {
    grid-template-columns: 1fr;
  }

  .page-header,
  .athlete-card {
    flex-direction: column;
    align-items: stretch;
  }

  .athlete-actions {
    flex-direction: column;
  }
}
