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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  padding: 1.5rem;
}

.container { max-width: 720px; margin: 0 auto; }

h1 { margin-bottom: 1rem; font-size: 1.5rem; }
h2 { font-size: 1.1rem; color: #aaa; }

/* --- Header bar --- */

.header-bar {
  max-width: 720px;
  margin: 0 auto 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-bar h1 { margin-bottom: 0; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#usernameDisplay {
  color: #888;
  font-size: 0.9rem;
}

.logout-btn {
  background: none;
  color: #888;
  border: 1px solid #333;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

.logout-btn:hover { color: #e0e0e0; border-color: #555; }

/* --- Section header with button --- */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 0.75rem;
}

.add-exercise-btn {
  background: none;
  color: #5b8def;
  border: 1px solid #5b8def;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

.add-exercise-btn:hover { background: #5b8def22; }

/* --- Login page --- */

.login-container {
  max-width: 360px;
  margin: 15vh auto 0;
  text-align: center;
}

.login-container h1 {
  margin-bottom: 1.5rem;
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-container input[type="text"],
.login-container input[type="password"] {
  padding: 0.7rem 0.8rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.95rem;
}

.login-container input:focus { outline: none; border-color: #5b8def; }

.stay-logged-in {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
}

.stay-logged-in input[type="checkbox"] {
  accent-color: #5b8def;
}

.secondary-btn {
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
}

.secondary-btn:hover { border-color: #5b8def; color: #e0e0e0; }

.login-error {
  background: #2a1a1a;
  border: 1px solid #4a2a2a;
  color: #e55;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.login-error.hidden { display: none; }

/* --- Chart --- */

.chart-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chart-controls select {
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #333;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.chart-wrap {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  max-height: 300px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.legend-checkbox {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.input-section { margin-bottom: 1rem; }

#parseForm {
  display: flex;
  gap: 0.5rem;
}

#parseForm input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.95rem;
}

#parseForm input:focus { outline: none; border-color: #5b8def; }

button {
  padding: 0.6rem 1rem;
  background: #5b8def;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover { background: #4a7cde; }
button:disabled { opacity: 0.5; cursor: default; }

.preview {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #1a2a1a;
  border: 1px solid #2a4a2a;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview.hidden { display: none; }
.preview .parsed-text { font-size: 0.95rem; }

.preview .save-btn {
  background: #3a3;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

.preview .save-btn:hover { background: #2a2; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid #333;
  color: #888;
  font-weight: 500;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid #1a1a1a;
}

.delete-btn {
  background: none;
  color: #666;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

.delete-btn:hover { color: #e55; }

.exercise-name { text-transform: capitalize; }

.suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.suggestion-card {
  min-width: 0;
  background: #1a1a2a;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 0.75rem 1rem 0.55rem;
  transition: border-color 0.15s, background 0.15s;
  overflow-wrap: anywhere;
}

.suggestion-card:hover {
  background: #1e1e35;
  border-color: #4a4a8a;
}

.suggestion-main {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  font: inherit;
}

.suggestion-main:hover { background: none; }
.suggestion-main > span { display: block; }

.suggestion-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.55rem;
  padding-top: 0.4rem;
  border-top: 1px solid #2a2a4a;
}

.suggestion-actions button {
  background: none;
  color: #9aaccf;
  padding: 0.2rem 0.35rem;
  font-size: 0.75rem;
}

.suggestion-actions button:hover { background: #2a2a4a; color: #e0e0e0; }
.suggestion-actions .badge-delete:hover { color: #ff8888; }

.suggestion-exercise {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

.days-ago {
  font-weight: normal;
  font-size: 0.85rem;
}

.days-ago.recent {
  color: #4caf50;
}

.days-ago.stale {
  color: #e05252;
}

.suggestion-rx {
  font-size: 1.1rem;
  color: #5b8def;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.suggestion-reason {
  font-size: 0.8rem;
  color: #8a8;
}

.suggestion-last {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.3rem;
}

.notes-field {
  width: 100%;
  min-height: 80px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 1rem;
}

.notes-field:focus { outline: none; border-color: #5b8def; }

.suggestion-empty {
  color: #555;
  font-size: 0.85rem;
}

.log-scroll {
  max-height: 400px;
  overflow-y: auto;
}

/* --- Modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  color: #888;
  border: none;
  font-size: 1.4rem;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { color: #e0e0e0; background: none; }

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #aaa;
}

.modal input[type="text"],
.modal input[type="number"],
.modal textarea,
.modal select {
  padding: 0.6rem 0.8rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.95rem;
  width: 100%;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus { outline: none; border-color: #5b8def; }

.modal textarea { font-family: inherit; resize: vertical; }

.modal-row {
  display: flex;
  gap: 0.75rem;
}

.modal-row label { flex: 1; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
