* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header { flex: 0 0 auto; }
main, .screen {
  flex: 1 1 auto;
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
  background: #0f172a;
  z-index: 10;
}
header h1 { margin: 0; font-size: 18px; font-weight: 600; }
header .ver { font-size: 10px; color: #64748b; font-weight: 400; margin-left: 4px; }

.sync-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 0;
  background: #64748b;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.sync-dot.ok { background: #10b981; box-shadow: 0 0 6px #10b98166; }
.sync-dot.error { background: #ef4444; box-shadow: 0 0 6px #ef444466; }
.sync-dot.pending { background: #f59e0b; box-shadow: 0 0 6px #f59e0b66; }
.sync-dot.offline { background: #64748b; }
.sync-dot.syncing { background: #10b981; animation: blink 1s infinite; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: 0.3 } }

main, .screen { padding: 20px; max-width: 720px; margin: 0 auto; }
.hidden { display: none !important; }

.dashboard {
  display: flex;
  flex-direction: column;
}
.dash-top { flex: 0 0 auto; }
.dash-bottom { margin-top: auto; padding-top: 24px; }

.divider { border: 0; border-top: 1px solid #1e293b; margin: 24px 0 8px; }

.actions { display: flex; gap: 12px; flex-wrap: nowrap; }
.primary {
  background: #3b82f6;
  color: white;
  border: 0;
  padding: 14px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}
.primary.full { width: 100%; }
.primary:active { background: #2563eb; }
.primary.error-flash { background: #dc2626; }

.danger {
  background: #475569;
  color: white;
  border: 0;
  padding: 14px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.danger.armed { background: #dc2626; color: white; }
.danger.error-flash { background: #dc2626; color: white; }

.btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.btn:active { background: #334155; }
.btn.active-filter { background: #dc2626; color: white; border-color: #dc2626; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px; }

.screen-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.screen-head h2 {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}
.screen-head .spacer { display: block; min-width: 36px; }

h2 { font-size: 16px; color: #94a3b8; margin: 0 0 12px; font-weight: 500; }
.section-label { text-transform: uppercase; letter-spacing: 0.8px; font-size: 12px; }

.stats { display: flex; gap: 10px; margin-top: 20px; }
.stat {
  flex: 1;
  background: #1e293b;
  padding: 14px 12px;
  border-radius: 10px;
  min-width: 0;
  cursor: pointer;
}
.stat:active { background: #334155; }
.stat-label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; color: #e2e8f0; margin-top: 6px; line-height: 1; }

.card {
  background: #1e293b;
  padding: 14px;
  border-radius: 10px;
  margin-top: 14px;
  cursor: pointer;
}
.card-label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head .card-label { margin-bottom: 0; }
.card-head .card-tag { font-size: 10px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }

.strip {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
}
.strip .day {
  aspect-ratio: 1;
  border-radius: 3px;
  background: #334155;
}
.strip .day.active { background: #3b82f6; }
.strip.weights .day.active { background: #ef4444; }
.strip .day.today { outline: 2px solid #94a3b8; outline-offset: -2px; }

.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: #1e293b;
  border-radius: 10px;
}
.filter-row { display: flex; gap: 8px; }
.filter-row label { flex: 1 1 0; min-width: 0; }
.filters input, .filters select { width: 100%; min-width: 0; }
.date-field { display: flex; gap: 6px; align-items: stretch; }
.date-field > input[type="text"] { flex: 1 1 auto; min-width: 0; }
.cal-wrap { position: relative; flex: 0 0 auto; display: inline-block; }
.cal-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 0 12px;
  height: 100%;
  min-height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  pointer-events: none;
}
.cal-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  font-size: 16px;
  color: transparent;
}
.form .date-field > input[type="text"] { background: #1e293b; }
.form .date-field .cal-btn { background: #1e293b; padding: 0 16px; min-height: 44px; }
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.filters input, .filters select {
  background: #0f172a;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.filters input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.filters .btn { align-self: flex-start; margin-top: 4px; }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  background: #1e293b;
  padding: 12px 14px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.list li.plain { cursor: default; }
.list .meta { font-size: 12px; color: #94a3b8; }
.list .pending-mark {
  font-size: 10px;
  background: #713f12;
  color: #fcd34d;
  padding: 2px 6px;
  border-radius: 4px;
}
.list li.has-results { border-left: 3px solid #10b981; }

.row-left { flex: 1; min-width: 0; }
.row-left .w-date { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 14px; color: #e2e8f0; }
.row-left .w-type { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.row-left .w-loc { font-size: 12px; color: #e2e8f0; margin-top: 2px; }
.row-right { display: flex; align-items: center; gap: 12px; }
.sport-icon { font-size: 28px; line-height: 1; }
.chevron { color: #64748b; font-size: 20px; }

.result-item-left { flex: 1; min-width: 0; }
.result-item-left .ex { font-weight: 600; font-size: 14px; }
.result-item-left .meta { margin-top: 3px; }

#results-list li { flex-direction: column; align-items: stretch; gap: 6px; }
#results-list .r-ex { font-weight: 600; font-size: 15px; color: #e2e8f0; }
#results-list .r-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font-size: 12px; color: #94a3b8; }
#results-list .r-meta .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#results-list .r-meta .pr-tag { color: #ef4444; font-weight: 700; }
.result-num {
  font-size: 22px;
  font-weight: 800;
  color: #e2e8f0;
  line-height: 1;
}
.result-num.pr { color: #ef4444; }
.result-num .unit { font-size: 11px; color: #94a3b8; font-weight: 500; margin-left: 2px; text-transform: uppercase; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #94a3b8; }
.form label.inline { flex-direction: row; align-items: center; gap: 10px; color: #e2e8f0; }
.form input, .form select, .form textarea {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.form input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.form input.full { width: 100%; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: #3b82f6; }
.form input.invalid, .form select.invalid, .form textarea.invalid, .form fieldset.invalid { border-color: #ef4444; }
.form textarea { resize: none; overflow: hidden; min-height: 44px; }
.form fieldset { border: 1px solid #334155; border-radius: 10px; padding: 12px; margin: 0; }
.form fieldset legend { color: #94a3b8; font-size: 13px; padding: 0 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.row-equal { flex-wrap: nowrap; }
.chips.row-equal .chip { flex: 1 1 0; text-align: center; padding: 10px 6px; }
.chip {
  background: #334155;
  color: #e2e8f0;
  border: 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0.55;
}
.chip.selected { opacity: 1; }
.chip.plain.selected { background: #3b82f6; color: white; }

.chip-mg { color: white; font-weight: 500; border-radius: 6px; }
.chip-mg.selected { box-shadow: 0 0 0 2px rgba(255,255,255,0.35) inset; }
.chip-mg[data-color="brown"] { background: #9F6B53; }
.chip-mg[data-color="orange"] { background: #D9730D; }
.chip-mg[data-color="yellow"] { background: #DFAB01; }
.chip-mg[data-color="green"] { background: #0F7B6C; }
.chip-mg[data-color="blue"] { background: #0B6E99; }
.chip-mg[data-color="purple"] { background: #6940A5; }
.chip-mg[data-color="pink"] { background: #AD1A72; }
.chip-mg[data-color="red"] { background: #E03E3E; }
.chip-mg[data-color="gray"] { background: #6b7280; }

.dur-row { display: flex; gap: 8px; align-items: stretch; }
.dur-num { flex: 1; min-width: 0; }
.dur-units { display: flex; gap: 6px; }
.dur-units .chip { padding: 10px 14px; border-radius: 10px; font-weight: 700; }

.stars { display: flex; gap: 6px; }
.stars button {
  background: transparent;
  border: 0;
  font-size: 30px;
  color: #334155;
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
}
.stars button.on { color: #f59e0b; }

.pr-btn {
  background: #475569;
  color: white;
  border: 0;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.8px;
  font-family: inherit;
}
.pr-btn.active { background: #dc2626; }

.info {
  background: #1e293b;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; align-items: flex-start; }
.info .row .k { color: #94a3b8; flex-shrink: 0; }
.info .row .v { color: #e2e8f0; text-align: right; }
.info .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.info .tags .chip-mg { font-size: 12px; padding: 6px 12px; opacity: 1; border-radius: 6px; }

.list.log li {
  flex-direction: column;
  align-items: flex-start;
  cursor: default;
  gap: 4px;
  padding: 10px 12px;
}
.list.log .ts { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: #64748b; }
.list.log .msg { font-size: 13px; color: #e2e8f0; }
.list.log li.lvl-error .msg { color: #fca5a5; }
.list.log li.lvl-ok .msg { color: #6ee7b7; }
