:root {
  --bg: #0d0f17;
  --surface: #161924;
  --surface-2: #1c2030;
  --surface-3: #242838;
  --text: #eceff4;
  --text-2: #a8afc0;
  --text-3: #6b7385;
  --accent: #4f8ff7;
  --accent-press: #3a7ae0;
  --accent-bg: rgba(79, 143, 247, 0.1);
  --border: #252938;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sheet: 0 -4px 32px rgba(0,0,0,0.55);
  --helmet-white: #d4d8e0;
  --helmet-yellow: #f0c800;
  --helmet-blue: #3b82f6;
  --helmet-red: #e53935;
  --cell-empty: #3a3f50;
  --danger: #f44336;
  --touch: 44px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.4;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ═══ HEADER ═══ */
.header {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-shrink: 0;
}
.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.25rem;
  width: var(--touch);
  height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-back::before { content: '‹'; font-size: 1.6rem; font-weight: 300; }
.btn-back:active { background: var(--accent-bg); }

#screenTitle {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ MAIN ═══ */
main#screen {
  flex: 1;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 10px 20px;
  border-radius: 100px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  z-index: 500;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s;
  max-width: min(90vw, 320px);
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  pointer-events: none;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-error {
  background: rgba(244, 67, 54, 0.9);
  color: #fff;
}

/* ═══ BUTTONS ═══ */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.08s;
  -webkit-user-select: none;
  user-select: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); transform: scale(0.97); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--surface-3); transform: scale(0.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { background: #d32f2f; transform: scale(0.97); }

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-add:active { background: var(--accent-press); transform: scale(0.98); }

/* ═══ EVENTS ═══ */
.events-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.events-toolbar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-2);
  min-height: var(--touch);
  cursor: pointer;
}
.events-list { list-style: none; }
.events-list li { margin-bottom: 8px; }

.event-card-wrap.event-card-hidden .event-card {
  opacity: 0.55;
  border-style: dashed;
}
.event-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.12s;
}
.event-card:active { background: var(--surface-2); }
.event-card-main { cursor: pointer; }
.event-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 3px;
}
.event-card p {
  font-size: 0.8125rem;
  color: var(--text-2);
}
.event-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.event-badge-hidden { background: var(--text-3); color: var(--bg); }

.event-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-event-action {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-bg);
  border: none;
  border-radius: var(--radius-xs);
  color: var(--accent);
  cursor: pointer;
}
.btn-event-action:active { background: var(--accent); color: #fff; }
.btn-event-action-danger { background: transparent; color: var(--text-3); }
.btn-event-action-danger:active { background: rgba(244,67,54,0.15); color: var(--danger); }

/* ═══ FORMS ═══ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}
.form-group input,
.form-group select {
  width: 100%;
  height: var(--touch);
  padding: 0 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row.form-row-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.form-row.form-row-inline label { min-width: 3.5rem; margin-bottom: 0; font-size: 0.8125rem; }
.form-row.form-row-inline input { width: 4rem; height: 38px; min-height: auto; }
.form-row.form-row-inline span { font-size: 0.8125rem; color: var(--text-3); }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.form-actions button { flex: 1; min-height: var(--touch); }

/* ═══ RIDERS ═══ */
.riders-header {
  margin-bottom: 12px;
}
.riders-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}
.riders-protocol-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
}
.riders-admin-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.riders-admin-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
}
.riders-admin-btn:active {
  background: var(--surface-3);
  transform: scale(0.97);
}

.riders-list { list-style: none; }
.riders-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.riders-list .rider-num {
  font-weight: 700;
  min-width: 24px;
  color: var(--accent);
  font-size: 0.9375rem;
  text-align: center;
}
.riders-list .rider-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.riders-list .rider-city {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}
.riders-list button {
  background: var(--accent-bg);
  border: none;
  color: var(--accent);
  padding: 6px 10px;
  min-height: 32px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.riders-list button:active { background: var(--accent); color: #fff; }

/* ═══ PROTOCOL TOOLBAR ═══ */
.protocol-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.pill-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pill-tab {
  min-height: 36px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.12s;
}
.pill-tab:active { background: var(--surface-3); }
.pill-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ═══ VIEW TOGGLE ═══ */
.view-toggle {
  display: flex;
  background: var(--surface);
  border-radius: 100px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.view-tab {
  flex: 1;
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.view-tab.active {
  background: var(--accent);
  color: #fff;
}
.view-tab:active:not(.active) {
  background: var(--surface-3);
}

/* ═══ PROTOCOL ADMIN BAR ═══ */
.protocol-admin-bar {
  display: flex;
  gap: 6px;
}
.btn-admin-sm {
  flex: 1;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
}
.btn-admin-sm:active {
  background: var(--surface-3);
  transform: scale(0.97);
}

.protocol-hint {
  font-size: 0.6875rem;
  color: var(--text-3);
  margin: 0 0 6px 0;
}

/* ═══ HEAT VIEW ═══ */
.heat-view {
  padding-bottom: 16px;
}
.heat-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.heat-nav-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.heat-nav-btn:active:not(:disabled) {
  background: var(--accent-bg);
  transform: scale(0.95);
}
.heat-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.heat-nav-center {
  flex: 1;
  text-align: center;
}
.heat-label {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}
.heat-counter {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 2px;
}
.heat-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
  font-size: 0.875rem;
}
.heat-riders-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.heat-rider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.12s;
}
.heat-rider-helmet {
  width: 6px;
  min-height: 36px;
  border-radius: 3px;
  flex-shrink: 0;
}
.heat-rider-helmet.helmet-red { background: var(--helmet-red); }
.heat-rider-helmet.helmet-blue { background: var(--helmet-blue); }
.heat-rider-helmet.helmet-yellow { background: var(--helmet-yellow); }
.heat-rider-helmet.helmet-white { background: var(--helmet-white); }
.heat-rider-helmet.no-helmet { background: var(--cell-empty); }

.heat-rider-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.heat-rider-num {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.125rem;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.heat-rider-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.heat-rider-name {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heat-rider-city {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 1px;
}
.heat-rider-sub {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--helmet-yellow);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heat-rider-sub-for {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #66bb6a;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-rider.subbed-out {
  opacity: 0.45;
  border-style: dashed;
  border-color: var(--text-3);
}
.heat-rider.is-substitute {
  border-color: rgba(102, 187, 106, 0.35);
}

.heat-rider-pts {
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  flex-shrink: 0;
  transition: transform 0.08s;
}
.heat-rider-pts:active:not(:disabled) {
  transform: scale(0.9);
}
.heat-rider-pts:disabled {
  cursor: default;
  opacity: 0.6;
}
.heat-rider-pts.no-value {
  background: var(--cell-empty);
  color: var(--text-3);
  border-color: var(--cell-empty);
}
.heat-rider-pts.has-value {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.heat-rider-pts.has-value.helmet-red {
  background: var(--helmet-red);
  border-color: var(--helmet-red);
}
.heat-rider-pts.has-value.helmet-blue {
  background: var(--helmet-blue);
  border-color: var(--helmet-blue);
}
.heat-rider-pts.has-value.helmet-yellow {
  background: var(--helmet-yellow);
  border-color: var(--helmet-yellow);
  color: #1a1a2e;
  text-shadow: none;
}
.heat-rider-pts.has-value.helmet-white {
  background: var(--helmet-white);
  border-color: var(--helmet-white);
  color: #1a1a2e;
  text-shadow: none;
}

/* ═══ PROTOCOL TABLE ═══ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -12px;
  background: var(--surface);
}

.protocol-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}
.protocol-table th,
.protocol-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0;
  text-align: center;
  background: var(--surface);
  vertical-align: middle;
  height: 36px;
}
.protocol-table th {
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10px;
  height: 30px;
}

.protocol-table .col-num {
  width: 28px;
  min-width: 28px;
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-2);
  border-right: 2px solid var(--border);
  padding: 0 2px;
}
.protocol-table th.col-num {
  z-index: 7;
  background: var(--surface-2);
  border-right: 2px solid var(--border);
}
.protocol-table .col-name {
  min-width: 80px;
  max-width: 100px;
  text-align: left;
  position: sticky;
  left: 28px;
  z-index: 5;
  background: var(--surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
  font-size: 11px;
  border-right: 2px solid var(--border);
}
.protocol-table th.col-name {
  z-index: 7;
  background: var(--surface-2);
  border-right: 2px solid var(--border);
}
.protocol-table .col-city {
  min-width: 0;
  max-width: 0;
  width: 0;
  overflow: hidden;
  padding: 0;
  border: none;
  font-size: 0;
  display: none;
}
.protocol-table .col-heat { width: 32px; min-width: 32px; }
.protocol-table .col-heat-extra { width: 32px; min-width: 32px; font-size: 9px; }
.protocol-table .col-sum,
.protocol-table .col-total {
  min-width: 32px;
  font-weight: 700;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
}
.protocol-table td.col-sum,
.protocol-table td.col-total {
  background: var(--surface-2);
}

/* ═══ CELLS ═══ */
.cell-heat-wrap { padding: 2px !important; }
.cell-point {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  margin: 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell-point:active:not(.readonly) { transform: scale(0.85); opacity: 0.85; }
.cell-point.cell-empty { background: var(--cell-empty); }
.cell-point.helmet-white { background: var(--helmet-white); color: #1a1a2e; text-shadow: none; }
.cell-point.helmet-grey { background: var(--helmet-white); color: #1a1a2e; text-shadow: none; }
.cell-point.helmet-yellow { background: var(--helmet-yellow); color: #1a1a2e; text-shadow: none; }
.cell-point.helmet-blue { background: var(--helmet-blue); }
.cell-point.helmet-red { background: var(--helmet-red); }
.cell-point.readonly { cursor: default; }
.cell-point.subbed-out-cell {
  opacity: 0.35;
  cursor: default;
}

/* ═══ PICKER — BOTTOM SHEET ═══ */
.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.points-picker {
  position: fixed;
  z-index: 101;
  background: var(--surface-2);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-sheet);
  left: 0 !important;
  right: 0;
  bottom: 0 !important;
  top: auto !important;
  width: 100%;
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.points-picker::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--text-3);
  border-radius: 2px;
  margin: 0 auto 12px;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.points-picker-title {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 8px;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.points-picker-title:first-of-type { margin-top: 0; }

.points-picker-btns {
  display: flex;
  gap: 6px;
}
.points-picker-btn {
  flex: 1;
  min-height: 48px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  font-size: 1.125rem;
}
.points-picker-btn:active { background: var(--surface-3); }
.points-picker-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.points-picker-btn.points-picker-dq,
.points-picker-btn.points-picker-special { font-weight: 700; font-size: 1rem; }
.points-picker-btn.points-picker-dq.active {
  background: var(--danger);
  border-color: var(--danger);
}
.points-picker-btn.points-picker-special.active {
  background: var(--helmet-yellow);
  border-color: var(--helmet-yellow);
  color: #1a1a2e;
}

.points-picker-colors {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.points-picker-color {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}
.points-picker-color.helmet-white { background: var(--helmet-white); }
.points-picker-color.helmet-grey { background: var(--helmet-white); }
.points-picker-color.helmet-yellow { background: var(--helmet-yellow); }
.points-picker-color.helmet-blue { background: var(--helmet-blue); }
.points-picker-color.helmet-red { background: var(--helmet-red); }
.points-picker-color.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

/* ═══ SUBSTITUTE PICKER ═══ */
.substitute-picker .sub-current {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-bottom: 10px;
  padding: 0;
}
.sub-riders-list {
  max-height: 45vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.sub-rider-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--touch);
  padding: 8px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: 0.875rem;
}
.sub-rider-option:active { background: var(--surface-3); }
.sub-rider-option.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.sub-rider-num {
  font-weight: 700;
  color: var(--accent);
  min-width: 24px;
}
.sub-rider-name { flex: 1; min-width: 0; }
.sub-rider-city { font-size: 0.75rem; color: var(--text-3); }
.sub-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-3);
  font-size: 0.8125rem;
}

.points-picker-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.points-picker-actions .points-picker-save,
.points-picker-actions .points-picker-clear {
  flex: 1;
  min-height: 48px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  padding: 0 12px;
}
.points-picker-save { background: var(--accent); color: #fff; }
.points-picker-save:active { background: var(--accent-press); }
.points-picker-clear {
  background: var(--surface-3);
  color: var(--text-2);
}
.points-picker-clear:active { background: var(--border); color: var(--text); }

/* ═══ ORDER PANEL ═══ */
.rider-order-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.rider-order-panel h4 {
  padding: 16px 16px 12px;
  color: var(--text);
  font-size: 1rem;
  background: var(--surface-2);
  border-radius: 16px 16px 0 0;
}
.rider-order-panel .rider-order-list {
  list-style: none;
  max-height: 55vh;
  overflow-y: auto;
  background: var(--surface);
}
.rider-order-panel .rider-order-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--touch);
}
.rider-order-panel .rider-order-list li:last-child { border-bottom: none; }
.rider-order-panel .btn-order-up,
.rider-order-panel .btn-order-down {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  background: var(--accent-bg);
  border: none;
  color: var(--accent);
  border-radius: var(--radius-xs);
}
.rider-order-panel .btn-order-up:active,
.rider-order-panel .btn-order-down:active { background: var(--accent); color: #fff; }
.rider-order-panel .form-actions {
  margin-top: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-2);
}

/* ═══ IMPORT / MODAL PANELS ═══ */
.import-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.import-panel-content {
  background: var(--surface-2);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 85vh;
  overflow-y: auto;
}
.import-panel-content::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--text-3);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.import-panel h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.import-panel .import-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 12px;
  line-height: 1.4;
}
.import-panel textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
}
.import-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.import-panel select {
  width: 100%;
  height: var(--touch);
  padding: 0 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1rem;
}
.import-panel .form-actions { margin-top: 12px; }

/* ═══ STATES ═══ */
.loading, .error {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-3);
  font-size: 0.875rem;
}
.loading::before {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto 12px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  color: #ef9a9a;
  background: rgba(244, 67, 54, 0.07);
  border-radius: var(--radius);
  border: 1px solid rgba(244, 67, 54, 0.15);
}

.hidden { display: none !important; }

/* ═══ DESKTOP ═══ */
@media (min-width: 640px) {
  main#screen { padding: 16px; max-width: 880px; margin: 0 auto; }
  .event-card { flex-direction: row; align-items: center; }
  .event-card-actions { flex-wrap: nowrap; }
  .riders-header { display: flex; align-items: center; justify-content: space-between; }
  .riders-protocol-btn { width: auto; min-width: 160px; }
  .protocol-toolbar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .view-toggle { max-width: 240px; }
  .heat-rider-pts { width: 56px; height: 56px; min-width: 56px; font-size: 1.5rem; }
  .points-picker {
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto;
    max-width: 340px;
    border-radius: var(--radius);
    animation: fadeIn 0.15s ease;
    padding: 12px 16px 16px;
  }
  .points-picker::before { display: none; }
  .import-panel { align-items: center; justify-content: center; }
  .import-panel-content { max-width: 400px; border-radius: var(--radius); }
  .import-panel-content::before { display: none; }
  .rider-order-panel { align-items: center; justify-content: center; }
  .rider-order-panel h4 { max-width: 400px; border-radius: var(--radius) var(--radius) 0 0; }
  .rider-order-panel .rider-order-list { max-width: 400px; }
  .rider-order-panel .form-actions { max-width: 400px; border-radius: 0 0 var(--radius) var(--radius); }
  .protocol-table .col-city { display: table-cell; min-width: 60px; max-width: 80px; width: auto; font-size: 10px; color: var(--text-3); padding: 0 4px; border-right: 1px solid var(--border); }
}
