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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #222;
  background: #f5f5f5;
}

nav {
  background: #1a3a5c;
  color: #fff;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
nav .brand { font-weight: 700; font-size: 16px; }
nav a { color: #cde; text-decoration: none; margin-left: 16px; }
nav a:hover { color: #fff; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-user { color: #89a; margin: 0 8px; }

main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
}

main.wide {
  max-width: none;
  margin: 24px 32px;
  padding: 0;
}

h2 { font-size: 20px; margin-bottom: 16px; color: #1a3a5c; }
h3 { font-size: 16px; margin: 20px 0 10px; color: #2a4a6c; }

.page-header,
.room-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-header h2,
.room-header h2 {
  margin-bottom: 4px;
}
.btn-link {
  display: inline-block;
  background: #f0f4f8;
  border: 1px solid #bcd;
  border-radius: 4px;
  color: #1a5a9c;
  padding: 6px 12px;
  text-decoration: none;
  white-space: nowrap;
}
.btn-link:hover {
  background: #e0e8f0;
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 20px;
}
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}
th { background: #f0f4f8; font-weight: 600; }
tr:hover { background: #fafbfc; }
a { color: #1a5a9c; text-decoration: none; }
a:hover { text-decoration: underline; }

.form-box {
  max-width: 360px;
  margin: 60px auto;
  background: #fff;
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  border-radius: 6px;
}
form label { display: block; margin: 12px 0 4px; font-weight: 500; }
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="file"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
form input:disabled {
  background: #f2f4f6;
  color: #666;
}
form button {
  margin-top: 16px;
  padding: 10px 24px;
  background: #1a5a9c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
form button:hover { background: #1a4a8c; }

.error { color: #c22; background: #fff0f0; padding: 10px; border-radius: 4px; margin: 10px 0; }
.success { color: #176b2c; background: #eef9f0; padding: 10px; border-radius: 4px; margin: 10px 0; }
.hint { color: #888; margin-top: 12px; font-size: 13px; }

.session-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  background: #fff; padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 20px;
}

.session-actions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 12px;
}

.inline-delete-form {
  display: inline;
  margin: 0;
}

.btn-danger {
  background: #b3261e;
}
.btn-danger:hover {
  background: #8f1d17;
}
.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.status { font-weight: 600; }
.status-done { color: #2a2; }
.status-processing { color: #c84; }
.status-error { color: #c22; }
.status-uploaded { color: #888; }

.plot-full { width: 100%; margin: 8px 0; border: 1px solid #ddd; border-radius: 4px; }
.plot-row { margin: 8px 0; }
.plot-container { width: 100%; margin: 8px 0; border: 1px solid #ddd; border-radius: 4px; }

/* Admin */
.role-badge { font-weight: 600; font-size: 12px; text-transform: uppercase; }
.role-admin { color: #a22; }
.role-coach { color: #16a; }
.role-athlete { color: #555; }

.tag {
  display: inline-block;
  background: #e8f0f8;
  border: 1px solid #bcd;
  border-radius: 3px;
  padding: 1px 6px;
  margin: 2px;
  font-size: 13px;
}
.btn-unlink {
  background: none; border: none; color: #c44; cursor: pointer;
  font-weight: 700; font-size: 13px; padding: 0 2px;
}
.btn-unlink:hover { color: #f00; }

.inline-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0;
}
.inline-form label { margin: 0; font-weight: 500; }
.inline-form select, .inline-form input { padding: 4px 8px; border: 1px solid #ccc; border-radius: 3px; }
.inline-form button { margin: 0; padding: 5px 12px; font-size: 13px; }

.admin-box {
  background: #fff8f0;
  border: 1px solid #ebc;
  border-radius: 4px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.share-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 14px 18px;
  margin-top: 24px;
}
.viewer-list { margin-top: 6px; padding-left: 18px; }
.viewer-list li { margin: 4px 0; }
.compact-table {
  margin-top: 14px;
  margin-bottom: 0;
}
.compact-table th,
.compact-table td {
  padding: 6px 10px;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 20px;
  align-items: start;
}
.settings-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.settings-panel h3 {
  margin-top: 0;
}
.workspace-block {
  border-top: 1px solid #e6e6e6;
  margin-top: 14px;
  padding-top: 12px;
}
.workspace-block h4 {
  color: #2a4a6c;
  font-size: 14px;
  margin-bottom: 6px;
}
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.room-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  color: #222;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  text-decoration: none;
}
.room-card:hover {
  border-color: #bcd;
  text-decoration: none;
}
.room-card strong {
  color: #1a3a5c;
  font-size: 16px;
}
.room-card span {
  color: #666;
}
.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}
.room-main,
.room-side {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: 18px;
}
.room-main h3:first-child,
.room-side h3:first-child {
  margin-top: 0;
}
.room-invite-form {
  margin-top: 16px;
}
.room-invite-form input {
  margin-bottom: 8px;
}
@media (max-width: 820px) {
  .room-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .page-header,
  .room-header {
    display: block;
  }
}
.btn-sm {
  background: #f0f4f8;
  border: 1px solid #bcd;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn-sm:hover { background: #e0e8f0; }

.stats-panel {
  background: #f8fff8;
  border: 1px solid #8b8;
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.stats-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats-body { display: flex; flex-wrap: wrap; gap: 20px; margin: 8px 0; }
.stats-body span { color: #666; margin-right: 4px; }
.btn-close { background: none; border: none; color: #888; font-size: 16px; cursor: pointer; }
.btn-close:hover { color: #333; }
.btn-scroll {
  margin-top: 8px;
  padding: 5px 14px;
  background: #e8f0e8;
  border: 1px solid #8b8;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.btn-scroll:hover { background: #d0e8d0; }

tr.highlight { background: #e8ffe8 !important; }

/* Compare page */
.cmp-pick-row {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}
.cmp-pick-panel {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
}
.cmp-pick-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.cmp-label {
  font-weight: 700;
  font-size: 15px;
  color: #1a3a5c;
}
.cmp-follow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #555;
  font-size: 12px;
  font-weight: 500;
  margin: 0;
}
.cmp-pick-bar select {
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 12px;
}
.cmp-pick-info {
  font-size: 12px;
  color: #2a2;
  margin-left: auto;
}
.cmp-pick-plot {
  width: 100%;
  min-height: 260px;
}
.cmp-result-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.cmp-plots-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cmp-stats-col {
  flex: 0 0 280px;
}
.cmp-stats-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 14px 16px;
  position: sticky;
  top: 24px;
}
.cmp-stats-panel h3 {
  font-size: 15px;
  color: #1a3a5c;
  margin: 0 0 10px;
}
.cmp-stats-table {
  width: 100%;
  border-collapse: collapse;
}
.cmp-stats-table th {
  text-align: left;
  font-size: 13px;
  color: #1a3a5c;
  padding: 6px 0 4px;
  border-bottom: 1px solid #eee;
}
.cmp-stats-table td {
  font-size: 13px;
  padding: 2px 0;
}
.cmp-stats-table td:last-child {
  text-align: right;
  font-weight: 600;
}
.cmp-placeholder {
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 6px;
  padding: 50px 20px;
  text-align: center;
  color: #aaa;
  font-size: 15px;
}
.cmp-result-plot {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
}
.cmp-result-plot h3 {
  font-size: 14px;
  color: #1a3a5c;
  margin: 0 0 8px;
}
.cmp-result-inner {
  width: 100%;
  min-height: 280px;
}

.cmp-view-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.cmp-view-label {
  font-weight: 600;
  font-size: 13px;
  color: #1a3a5c;
  margin-right: 4px;
}
.cmp-view-btn {
  padding: 5px 16px;
  border: 1px solid #bcd;
  border-radius: 4px;
  background: #f5f7fa;
  color: #555;
  font-size: 13px;
  cursor: pointer;
}
.cmp-view-btn:hover { background: #e2e8f0; }
.cmp-view-btn.active {
  background: #1a5a9c;
  color: #fff;
  border-color: #1a5a9c;
}

/* Report page */
.report-select-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.report-select-bar select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 13px;
}
.report-mode-label {
  font-weight: 600;
  font-size: 13px;
  color: #1a3a5c;
  margin-left: 12px;
}
.report-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #555;
  font-size: 13px;
  font-weight: 500;
}
.report-mode-btn {
  padding: 4px 14px;
  border: 1px solid #bcd;
  border-radius: 4px;
  background: #f5f7fa;
  color: #555;
  font-size: 13px;
  cursor: pointer;
}
.report-mode-btn:hover { background: #e2e8f0; }
.report-mode-btn.active {
  background: #1a5a9c;
  color: #fff;
  border-color: #1a5a9c;
}
.report-placeholder {
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 6px;
  padding: 50px 20px;
  text-align: center;
  color: #aaa;
  font-size: 15px;
}
.report-pick-plot {
  margin-bottom: 18px;
}
.report-section {
  margin-bottom: 28px;
}
.report-section h3 {
  margin: 0 0 10px;
  color: #1a3a5c;
}
.report-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  background: #f8fafb;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 13px;
}
.report-totals span { color: #555; }
.report-totals strong { color: #1a3a5c; }
.report-table {
  font-size: 13px;
}
.report-table th {
  text-align: center;
  font-size: 12px;
  padding: 8px 10px;
}
.report-table td {
  text-align: center;
  padding: 6px 10px;
}
.report-table td:first-child,
.report-table th:first-child {
  text-align: left;
  font-weight: 600;
}

@media (max-width: 760px) {
  nav {
    height: auto;
    min-height: 48px;
    padding: 10px 16px;
    align-items: flex-start;
    gap: 8px;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  main {
    padding: 0 14px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
