*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #0f1117; color: #e2e8f0; min-height: 100vh; }

/* ── Header ── */
header {
  background: #1a1d27;
  border-bottom: 1px solid #2d3748;
  padding: .75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
header h1 { font-size: 1.25rem; color: #63b3ed; letter-spacing: .5px; flex-shrink: 0; }

#status-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
  font-size: .82rem;
  color: #a0aec0;
}
.hdr-connector {
  display: flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  padding: .2rem .5rem;
  border-radius: 5px;
  transition: background .15s;
}
.hdr-connector:hover { background: #2d3748; }
.hdr-dot { font-size: .7rem; line-height: 1; }
.hdr-dot.ok   { color: #68d391; }
.hdr-dot.err  { color: #fc8181; }
.hdr-dot.warn { color: #f6ad55; }
.hdr-dot.unk  { color: #718096; }
#hdr-last-sync { color: #718096; font-size: .78rem; margin-left: .4rem; }

#user-info { font-size: .82rem; color: #a0aec0; display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }

/* ── Main nav tabs ── */
.main-nav {
  background: #1a1d27;
  border-bottom: 1px solid #2d3748;
  padding: 0 2rem;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav-tab {
  padding: .65rem 1.1rem;
  font-size: .88rem;
  color: #a0aec0;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.main-nav-tab:hover { color: #e2e8f0; }
.main-nav-tab.active { color: #63b3ed; border-bottom-color: #63b3ed; }

/* ── Layout ── */
main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; }

.card {
  background: #1a1d27;
  border: 1px solid #2d3748;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card h2 { margin-bottom: 1rem; font-size: 1.1rem; color: #90cdf4; }

/* ── Form controls ── */
input, button, select {
  font-size: .9rem;
  padding: .55rem .9rem;
  border-radius: 6px;
  border: 1px solid #2d3748;
  outline: none;
}
input, select { background: #0f1117; color: #e2e8f0; width: 100%; margin-bottom: .6rem; }
input:focus, select:focus { border-color: #63b3ed; }
input[type="date"] { cursor: pointer; color-scheme: dark; }
button {
  background: #2b6cb0;
  color: #fff;
  cursor: pointer;
  border: none;
  transition: background .15s;
}
button:hover { background: #3182ce; }
button:disabled { background: #4a5568; cursor: not-allowed; }
.btn-secondary { background: #2d3748; }
.btn-secondary:hover { background: #4a5568; }

.row { display: flex; gap: .6rem; align-items: flex-start; flex-wrap: wrap; }
.row input, .row select { flex: 1; min-width: 120px; margin-bottom: 0; }
label { font-size: .82rem; color: #a0aec0; display: block; margin-bottom: .3rem; }

/* ── Auth tabs ── */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.tab {
  padding: .5rem 1rem;
  background: #2d3748;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  border: 1px solid transparent;
}
.tab.active { background: #2b6cb0; border-color: #3182ce; }

/* ── Calendar picker ── */
.gs-calendar { margin-bottom: 1rem; }
.gs-cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem;
}
.gs-cal-active-label { font-size: .88rem; color: #e2e8f0; font-weight: 500; }
.gs-cal-toolbar-btns { display: flex; gap: .3rem; flex-wrap: wrap; }
.gs-cal-tbtn {
  background: #2d3748; border: 1px solid #4a5568; color: #a0aec0;
  font-size: .78rem; padding: .25rem .65rem; border-radius: 5px;
  cursor: pointer; transition: background .15s, color .15s;
}
.gs-cal-tbtn:hover { background: #4a5568; color: #e2e8f0; }
.gs-cal-body { margin-top: .4rem; }
.gs-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .5rem;
}
.gs-cal-title { font-weight: 600; color: #90cdf4; font-size: .95rem; }
.gs-cal-nav {
  background: #2d3748; border: none; color: #a0aec0; cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.gs-cal-nav:hover { background: #4a5568; color: #e2e8f0; }
.gs-cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  margin-bottom: 2px;
}
.gs-cal-weekdays span {
  text-align: center; font-size: .7rem; color: #718096;
  padding: .2rem 0; text-transform: uppercase; letter-spacing: .04em;
}
.gs-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.gs-cal-day {
  aspect-ratio: 1; min-height: 36px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 6px; position: relative;
  font-size: .82rem; color: #4a5568;
  transition: background .12s;
}
.gs-cal-day.has-data {
  color: #e2e8f0; cursor: pointer; background: #1e2330;
}
.gs-cal-day.has-data:hover { background: #2d3748; }
.gs-cal-day.active { background: #2b6cb0 !important; color: #fff; }
.gs-cal-day.today .gs-cal-num {
  outline: 1.5px solid #63b3ed; border-radius: 50%;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
}
.gs-cal-num { line-height: 1; }
.gs-cal-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #63b3ed; margin-top: 2px;
}
.gs-cal-day.active .gs-cal-dot { background: #bee3f8; }
.gs-cal-empty { font-size: .75rem; color: #718096; padding: .5rem 0; }
.gs-cal-detail { margin-top: .5rem; }
.gs-cal-detail-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .7rem; border-radius: 6px;
  font-size: .82rem; border: 1px solid #2d3748; margin-bottom: .3rem;
  cursor: pointer; transition: background .12s;
}
.gs-cal-detail-item:hover { background: #1e2330; border-color: #4a5568; }
.gs-cal-detail-item.active { background: #1a2e3a; border-color: #2b6cb0; }
.gs-cal-detail-del {
  background: none; border: none; color: #718096; cursor: pointer;
  padding: 0 3px; font-size: .85rem; line-height: 1; margin-left: auto;
}
.gs-cal-detail-del:hover { color: #fc8181; }
.badge-auto {
  display: inline-block; background: #2c5282; color: #90cdf4;
  font-size: .65rem; padding: 1px 5px; border-radius: 8px;
  vertical-align: middle; margin-left: 3px; letter-spacing: .3px;
}

#report-rendered { margin-top: .5rem; }
#report-rendered h1 { font-size: 1.3rem; color: #90cdf4; margin: 1rem 0 .5rem; }
#report-rendered h2 { font-size: 1.1rem; color: #68d391; margin: 1rem 0 .4rem; border-bottom: 1px solid #2d3748; padding-bottom: .3rem; }
#report-rendered h3 { font-size: 1rem; color: #f6ad55; margin: .8rem 0 .3rem; }
#report-rendered ul { padding-left: 1.2rem; margin: .3rem 0; }
#report-rendered li { margin: .2rem 0; }
#report-rendered table { border-collapse: collapse; width: 100%; font-size: .8rem; margin: .5rem 0; }
#report-rendered th, #report-rendered td { border: 1px solid #2d3748; padding: .35rem .6rem; text-align: left; }
#report-rendered th { background: #2d3748; }
#report-rendered p { margin: .3rem 0; }

.report-editor-textarea {
  width: 100%;
  min-height: 400px;
  background: #0f1117;
  color: #e2e8f0;
  border: 1px solid #4a5568;
  border-radius: 6px;
  padding: .6rem;
  font-size: .85rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: .6rem;
  box-sizing: border-box;
}
.report-editor-actions { display: flex; gap: .5rem; }

/* ── Status badges ── */
.status-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.status-ok   { background: #276749; color: #9ae6b4; }
.status-err  { background: #742a2a; color: #feb2b2; }
.status-warn { background: #744210; color: #fbd38d; }

/* ── Equipment tags ── */
.eq-tag {
  display: inline-flex; align-items: center; gap: .3rem;
  background: #2d3748; border-radius: 6px;
  padding: .25rem .6rem; font-size: .82rem; margin: .2rem;
}
.eq-tag button { background: none; border: none; color: #fc8181; cursor: pointer; padding: 0; font-size: .9rem; line-height: 1; }

/* ── Training plan ── */
.plan-day { border: 1px solid #2d3748; border-radius: 8px; margin-bottom: .8rem; }
.plan-day-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .9rem; background: #1e2330; border-radius: 8px 8px 0 0; cursor: pointer;
}
.plan-day-header .day-label { font-weight: 600; color: #90cdf4; margin-right: .5rem; }
.plan-day-body { padding: .7rem .9rem; display: none; }
.plan-day-body.open { display: block; }
.ex-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .4rem; }
.ex-row input { flex: 1; min-width: 80px; margin-bottom: 0; font-size: .82rem; padding: .35rem .6rem; }
.ex-row .ex-name { flex: 3; min-width: 160px; }
.ex-row button { flex-shrink: 0; }
.btn-icon { background: none; border: none; color: #a0aec0; cursor: pointer; font-size: 1rem; padding: .2rem .4rem; }
.btn-icon:hover { color: #fc8181; }

/* ── Garmin import panel ── */
#garmin-import-panel {
  border: 1px solid #2c7a7b;
  border-radius: 8px;
  padding: .9rem;
  margin-top: .8rem;
  background: #0f1117;
}
.workout-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .7rem; border-radius: 6px;
  font-size: .85rem; border: 1px solid #2d3748; margin-bottom: .35rem;
  transition: background .12s;
}
.workout-item:hover { background: #1e2330; border-color: #4a5568; }
.workout-item.selected { background: #1a2e3a; border-color: #2c7a7b; }
.workout-item input[type=checkbox] { flex-shrink: 0; accent-color: #2c7a7b; width: 15px; height: 15px; cursor: pointer; }
.workout-item label { flex: 1; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.wi-dur { font-size: .75rem; color: #4a5568; white-space: nowrap; }
#garmin-import-footer { margin-top: .7rem; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
#garmin-selection-count { font-size: .82rem; color: #a0aec0; }

/* ── Recommendations ── */
#rec-content { margin-top: .8rem; }
#rec-content h1 { font-size: 1.3rem; color: #90cdf4; margin: 1rem 0 .5rem; }
#rec-content h2 { font-size: 1.1rem; color: #68d391; margin: 1rem 0 .4rem; border-bottom: 1px solid #2d3748; padding-bottom: .3rem; }
#rec-content h3 { font-size: 1rem; color: #f6ad55; margin: .8rem 0 .3rem; }
#rec-content ul { padding-left: 1.2rem; margin: .3rem 0; }
#rec-content li { margin: .2rem 0; }
#rec-content p { margin: .3rem 0; }
#rec-content table { border-collapse: collapse; width: 100%; font-size: .8rem; margin: .5rem 0; }
#rec-content th, #rec-content td { border: 1px solid #2d3748; padding: .35rem .6rem; text-align: left; }
#rec-content th { background: #2d3748; }
#rec-calendar { margin-bottom: .8rem; }

.rec-mode-tab {
  padding: .3rem .8rem;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #a0aec0;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rec-mode-tab:hover { background: #4a5568; color: #e2e8f0; }
.rec-mode-tab.active { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }

/* ── Health summary cards ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.summary-card {
  background: #0f1117;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: .75rem .9rem;
  text-align: center;
}
.summary-card .s-label { font-size: .72rem; color: #718096; margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .04em; }
.summary-card .s-value { font-size: 1.35rem; font-weight: 600; color: #e2e8f0; line-height: 1.1; }
.summary-card .s-sub { font-size: .72rem; color: #a0aec0; margin-top: .2rem; }
#summary-date { font-size: .75rem; color: #718096; margin-bottom: .75rem; }

/* ── Readiness indicator ── */
.readiness-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-radius: 8px;
  border: 1px solid #2d3748;
  background: #0f1117;
  margin-bottom: 1rem;
}
.readiness-light {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.readiness-light.green  { background: #276749; box-shadow: 0 0 10px #276749; }
.readiness-light.yellow { background: #744210; box-shadow: 0 0 10px #744210; }
.readiness-light.red    { background: #742a2a; box-shadow: 0 0 10px #742a2a; }
.readiness-light.grey   { background: #2d3748; }
.readiness-text .r-title { font-size: .95rem; font-weight: 600; }
.readiness-text .r-title.green  { color: #68d391; }
.readiness-text .r-title.yellow { color: #f6ad55; }
.readiness-text .r-title.red    { color: #fc8181; }
.readiness-text .r-title.grey   { color: #718096; }
.readiness-text .r-detail { font-size: .78rem; color: #718096; margin-top: .2rem; }

/* ── Connection sections ── */
.conn-section { padding: .75rem 0; }
.conn-section:first-child { padding-top: 0; }
.conn-section + .conn-section { border-top: 1px solid #2d3748; }
.conn-section-header { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .2rem 0; user-select: none; }
.conn-section-header:hover .conn-section-title { color: #e2e8f0; }
.conn-section-title { font-size: .92rem; font-weight: 600; color: #90cdf4; }
.conn-toggle-icon { margin-left: auto; color: #718096; font-size: .82rem; }
.conn-section-body { margin-top: .6rem; }

/* ── Sync progress ── */
#sync-progress { margin-top: .8rem; display: none; }
#sync-progress-bar-wrap { background: #2d3748; border-radius: 999px; height: 6px; margin-bottom: .4rem; }
#sync-progress-bar { background: #63b3ed; border-radius: 999px; height: 6px; width: 0; transition: width .3s; }
#sync-progress-text { font-size: .8rem; color: #a0aec0; }
#sync-results { margin-top: .5rem; font-size: .8rem; }
.sync-result-ok  { color: #9ae6b4; }
.sync-result-err { color: #feb2b2; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: #276749; color: #9ae6b4;
  padding: .7rem 1.2rem;
  border-radius: 8px;
  font-size: .85rem;
  display: none;
  z-index: 999;
}
#toast.error { background: #742a2a; color: #feb2b2; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #4a5568;
  border-top-color: #63b3ed;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-left: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chart panel ── */
.chart-period-btn {
  background: #2d3748;
  border: 1px solid #4a5568;
  color: #a0aec0;
  font-size: .78rem;
  padding: .25rem .65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.chart-period-btn:hover { background: #4a5568; color: #e2e8f0; }
.chart-period-btn.active { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }

.summary-card { cursor: pointer; transition: border-color .15s, background .15s; }
.summary-card:hover { border-color: #4a5568; background: #1a2030; }
.summary-card.active { border-color: #63b3ed; background: #1a2535; }

/* ── Admin table ── */
.admin-table { border-collapse: collapse; width: 100%; font-size: .82rem; }
.admin-table th, .admin-table td { border: 1px solid #2d3748; padding: .4rem .7rem; text-align: left; vertical-align: middle; }
.admin-table th { background: #2d3748; color: #90cdf4; }
.admin-table tr:hover td { background: #1e2330; }
.admin-table td button { margin-right: .3rem; }

.hidden { display: none !important; }

/* ── Mobile ── */
@media (max-width: 640px) {
  header { padding: .5rem .75rem; gap: .5rem; flex-wrap: wrap; }
  header h1 { font-size: 1.05rem; }
  #status-bar { font-size: .75rem; gap: .4rem; }
  #user-info { font-size: .75rem; gap: .4rem; }
  .main-nav { padding: 0 .5rem; }
  .main-nav-tab { padding: .5rem .7rem; font-size: .8rem; }
  main { padding: 1rem .6rem; }
  .card { padding: 1rem; }
  .gs-cal-day { min-height: 32px; font-size: .75rem; }
  .gs-cal-title { font-size: .85rem; }
  .gs-cal-nav { width: 28px; height: 28px; font-size: .95rem; }
}
