@font-face {
  font-family: "Orbitron";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/orbitron-400.ttf") format("truetype");
}

@font-face {
  font-family: "Orbitron";
  font-style: normal;
  font-weight: 700;
  src: url("assets/fonts/orbitron-700.ttf") format("truetype");
}

@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/roboto-mono-400.ttf") format("truetype");
}

@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 700;
  src: url("assets/fonts/roboto-mono-700.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: #fbfbfd;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.12);
  --nav-bg: rgba(255, 255, 255, 0.78);
  --header-bg: rgba(5, 5, 5, 0.9);
  --red: #a60000;
  --red-bright: #d00202;
  --accent: #0071e3;
  --gold: #f2d400;
  --orange: #c98219;
  --table-dark: #000000;
  --table-row: #1f1f1f;
  --button-hover: #005bb5;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="night"] {
  color-scheme: dark;
  --bg: #000000;
  --panel: #1c1c1e;
  --panel-soft: #2c2c2e;
  --ink: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255, 255, 255, 0.16);
  --nav-bg: rgba(28, 28, 30, 0.78);
  --header-bg: rgba(0, 0, 0, 0.9);
  --red: #c00000;
  --button-hover: #2997ff;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.46);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: 700 0.88rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  min-height: 38px;
  padding: 0 14px;
  text-transform: uppercase;
}

button:hover {
  background: var(--button-hover);
}

button:disabled {
  background: #9a9a9a;
  border-color: #8a8a8a;
  color: #ededed;
  cursor: not-allowed;
  opacity: 0.68;
}

button.secondary:disabled,
.tab:disabled {
  background: color-mix(in srgb, var(--panel) 55%, #8f8f8f);
  color: var(--muted);
}

button.secondary,
.tab {
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border: 1px solid var(--line);
  color: var(--ink);
}

.app-header {
  align-items: center;
  backdrop-filter: saturate(180%) blur(18px);
  background: var(--header-bg);
  display: flex;
  justify-content: center;
  min-height: 104px;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-stack {
  display: grid;
  gap: 8px;
  justify-items: center;
  left: 50%;
  max-width: min(520px, calc(100vw - 40px));
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.brand-wordmark {
  display: block;
  height: 58px;
  max-width: min(520px, 82vw);
  object-fit: contain;
  width: auto;
}

.brand-stack p {
  color: #fff;
  font: 700 clamp(0.72rem, 1.8vw, 1rem) Orbitron, sans-serif;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  position: absolute;
  right: 20px;
  top: 18px;
}

.auth-status {
  align-items: center;
  color: #fff;
  display: inline-flex;
  font: 700 0.74rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  gap: 7px;
  max-width: 160px;
  text-transform: uppercase;
  white-space: nowrap;
}

.auth-status span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-avatar {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  height: 26px;
  object-fit: contain;
  width: 26px;
}

.header-actions button {
  min-width: 72px;
}

.theme-toggle {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #1d1d1f;
  display: inline-flex;
  justify-content: center;
  min-width: 82px;
}

.theme-toggle:hover {
  color: #fff;
}

.tabs {
  backdrop-filter: saturate(180%) blur(18px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  position: sticky;
  top: 104px;
  z-index: 29;
}

.modal-backdrop {
  align-items: center;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 60;
}

.login-panel,
.service-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 18px;
  width: 100%;
}

.service-modal {
  max-height: calc(100vh - 36px);
  max-width: 760px;
  overflow: auto;
}

.wide-service-modal {
  max-width: min(1680px, calc(100vw - 28px));
  padding: 14px;
}

.login-panel label,
.service-modal label {
  color: var(--muted);
  display: grid;
  font: 700 0.78rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  gap: 6px;
  text-transform: uppercase;
}

.login-panel input,
.service-modal input[type="number"],
.service-modal select,
.service-modal textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: 400 1rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  min-height: 42px;
  padding: 8px 10px;
}

.service-modal select {
  appearance: none;
  background-color: var(--bg);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  line-height: 1.2;
  min-height: 44px;
  padding-right: 34px;
}

.service-modal textarea {
  resize: vertical;
}

.service-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 10px;
}

.service-fieldset legend {
  color: var(--muted);
  font: 700 0.78rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 0 6px;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented-control label {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 40px;
}

.segmented-control label:has(input:checked) {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.segmented-control input {
  appearance: none;
  height: 0;
  margin: 0;
  width: 0;
}

.field-help {
  color: var(--muted);
  font: 700 0.72rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.field-help.valid {
  color: #168152;
}

.field-help.invalid {
  color: var(--red);
}

.checkbox-row {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: flex !important;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
}

.checkbox-row input {
  accent-color: var(--red);
  height: 18px;
  width: 18px;
}

.modal-note {
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
}

.report-vote-details {
  display: grid;
  gap: 10px;
}

.report-vote-details.empty {
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 12px;
  text-transform: uppercase;
}

.report-vote-details .incidents-list {
  gap: 0;
}

.report-vote-details .incident-card {
  box-shadow: none;
}

.report-vote-details .incident-body {
  grid-template-columns: 1fr;
}

.report-vote-details .incident-media {
  max-width: 300px;
}

.feedback-panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  max-width: 420px;
  padding: 18px;
  text-align: center;
  width: 100%;
}

.feedback-panel.success {
  border-color: #168152;
}

.feedback-panel.error {
  border-color: var(--red);
}

.feedback-panel h2 {
  margin: 0;
}

.feedback-panel.success h2 {
  color: #168152;
}

.feedback-panel.error h2 {
  color: var(--red);
}

.feedback-panel p {
  color: var(--ink);
  margin: 0;
  text-transform: uppercase;
}

.privacy-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 36px);
  max-width: 640px;
  overflow: auto;
  padding: 20px;
  width: min(640px, calc(100vw - 28px));
}

.privacy-copy {
  color: var(--ink);
  display: grid;
  gap: 10px;
}

.privacy-copy h3 {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 8px 0 0;
}

.privacy-copy p {
  margin: 0;
}

.qualifying-editor-actions,
.qualifying-defaults,
.qualifying-sheet-head,
.row-actions {
  align-items: center;
  gap: 8px;
}

.qualifying-editor-actions,
.qualifying-sheet-head,
.row-actions {
  display: flex;
}

.qualifying-defaults {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.qualifying-editor-actions,
.qualifying-sheet-head {
  justify-content: space-between;
}

.qualifying-editor-actions {
  justify-content: flex-start;
}

.qualifying-sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qualifying-sheet-tabs:empty {
  display: none;
}

.qualifying-sheet-tabs button {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--ink);
}

.qualifying-sheet-tabs button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

[data-theme="night"] .qualifying-sheet-tabs button.active {
  color: #1d1d1f;
}

.qualifying-editor {
  display: grid;
  gap: 12px;
}

.qualifying-editor.empty {
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  padding: 14px;
  text-transform: uppercase;
}

.qualifying-sheet-head h3 {
  margin: 0;
}

.race-points-tools {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.race-points-tools select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 38px;
  min-width: 260px;
  padding: 6px 8px;
}

.qualifying-edit-table table {
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.qualifying-edit-table th:nth-child(1),
.qualifying-edit-table td:nth-child(1) {
  width: 42px;
}

.qualifying-edit-table th:nth-child(2),
.qualifying-edit-table td:nth-child(2) {
  width: 12%;
}

.qualifying-edit-table th:nth-child(3),
.qualifying-edit-table td:nth-child(3) {
  width: 14%;
}

.qualifying-edit-table th:nth-child(4),
.qualifying-edit-table td:nth-child(4) {
  width: 12%;
}

.qualifying-edit-table th:nth-child(5),
.qualifying-edit-table td:nth-child(5),
.qualifying-edit-table th:nth-child(6),
.qualifying-edit-table td:nth-child(6) {
  width: 7.5%;
}

.qualifying-edit-table th:nth-child(7),
.qualifying-edit-table td:nth-child(7),
.qualifying-edit-table th:nth-child(8),
.qualifying-edit-table td:nth-child(8) {
  width: 9%;
}

.qualifying-edit-table th:nth-child(9),
.qualifying-edit-table td:nth-child(9) {
  width: 70px;
}

.qualifying-edit-table th:nth-child(10),
.qualifying-edit-table td:nth-child(10) {
  width: 178px;
}

.race-edit-table th:nth-child(1),
.race-edit-table td:nth-child(1) {
  width: 38px;
}

.race-edit-table th:nth-child(2),
.race-edit-table td:nth-child(2) {
  width: 10%;
}

.race-edit-table th:nth-child(3),
.race-edit-table td:nth-child(3) {
  width: 11%;
}

.race-edit-table th:nth-child(4),
.race-edit-table td:nth-child(4) {
  width: 10%;
}

.race-edit-table th:nth-child(5),
.race-edit-table td:nth-child(5),
.race-edit-table th:nth-child(6),
.race-edit-table td:nth-child(6),
.race-edit-table th:nth-child(9),
.race-edit-table td:nth-child(9),
.race-edit-table th:nth-child(11),
.race-edit-table td:nth-child(11) {
  width: 62px;
}

.race-edit-table th:nth-child(7),
.race-edit-table td:nth-child(7),
.race-edit-table th:nth-child(8),
.race-edit-table td:nth-child(8) {
  width: 8%;
}

.race-edit-table th:nth-child(10),
.race-edit-table td:nth-child(10) {
  width: 9%;
}

.race-edit-table th:nth-child(12),
.race-edit-table td:nth-child(12),
.race-edit-table th:nth-child(13),
.race-edit-table td:nth-child(13) {
  text-align: center;
  width: 48px;
}

.race-edit-table th:nth-child(14),
.race-edit-table td:nth-child(14) {
  width: 178px;
}

.qualifying-edit-table th {
  background: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

[data-theme="night"] .qualifying-edit-table th {
  color: #1d1d1f;
}

.qualifying-edit-table td {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 6px;
}

.qualifying-edit-table tbody tr:nth-child(even) {
  background: var(--panel-soft);
}

.qualifying-edit-table tbody tr:nth-child(odd) td {
  color: var(--ink);
}

.qualifying-edit-table select,
.qualifying-edit-table input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 34px;
  padding: 5px 7px;
  width: 100%;
}

.qualifying-edit-table select {
  appearance: none;
  background-color: var(--panel);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  line-height: 1.2;
  min-width: 0;
  padding-right: 30px;
}

.qualifying-edit-table input {
  min-width: 0;
}

.race-edit-table input[type="checkbox"] {
  accent-color: var(--accent);
  min-height: 18px;
  width: 18px;
}

.invalid-field,
.result-time-input.invalid-time {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(179, 0, 0, 0.22);
}

.validation-status {
  color: var(--muted);
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  margin: -4px 0 0;
  text-transform: uppercase;
}

.validation-status.valid {
  color: #168152;
}

.validation-status.invalid {
  color: var(--red);
}

.row-actions {
  flex-wrap: nowrap;
}

.row-actions button {
  font-size: 0.72rem;
  min-width: 36px;
  padding-inline: 6px;
}

.icon-button {
  min-width: 38px;
  padding-inline: 10px;
}

.form-error {
  color: var(--red);
  font-weight: 700;
  margin: 0;
  min-height: 1.45em;
  text-transform: uppercase;
}

.tab {
  color: var(--ink);
  min-width: 110px;
}

.tab.active,
.subtabs button.active,
.filter-row button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

[data-theme="night"] .tab.active,
[data-theme="night"] .subtabs button.active,
[data-theme="night"] .filter-row button.active {
  color: #1d1d1f;
}

main {
  margin: 0 auto;
  max-width: 1380px;
  padding: 18px 18px 44px;
}

.app-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: center;
  margin: 0 auto;
  max-width: 1380px;
  padding: 18px;
}

.app-footer a {
  color: var(--muted);
  font: 700 0.78rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 0 8px;
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--ink);
}

h1,
h2,
h3,
h4,
.event-date,
.post-codes,
th,
.count-pill {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.api-debug-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
  padding: 14px 16px;
}

.api-debug-panel > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.api-debug-panel strong,
.api-log-entry summary span,
.api-log-entry summary strong {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.api-debug-panel > summary span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.api-debug-panel > button {
  margin-top: 12px;
}

.api-log {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.api-log-entry {
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 5px solid #d9a726;
  border-radius: 8px;
  overflow: hidden;
}

.api-log-entry.ok {
  border-left-color: #168152;
}

.api-log-entry.error {
  border-left-color: var(--red);
}

.api-log-entry summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 10px;
}

.api-log-entry summary small {
  color: var(--muted);
  margin-left: auto;
}

.api-log-entry pre {
  background: #090909;
  color: #f3f4f1;
  font: 400 0.78rem "Roboto Mono", monospace;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

.back-button {
  margin-bottom: 12px;
}

.home-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.panel-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h1,
.panel-head h2 {
  font-size: clamp(1.35rem, 2.4vw, 2.15rem);
  line-height: 1.1;
  margin: 0;
}

.count-pill {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--red);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 30px;
  min-width: 42px;
  padding: 0 10px;
}

.result-feed,
.event-list {
  display: grid;
  gap: 18px;
}

.result-feed.empty,
.event-list.empty {
  color: var(--muted);
}

.result-post {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.post-header {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 128px;
  padding: 16px 18px 12px;
}

.clickable-header {
  cursor: pointer;
}

.clickable-header:hover .post-title h3 {
  color: var(--red);
}

.post-main {
  align-items: center;
  display: flex;
  gap: 16px;
  min-width: 0;
}

.post-avatar {
  border: 2px solid var(--red);
  border-radius: 999px;
  flex: 0 0 auto;
  height: 76px;
  object-fit: contain;
  width: 76px;
}

.post-title {
  flex: 1;
  min-width: 0;
}

.post-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}

.post-codes a {
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 999px;
  color: var(--accent);
  font: 700 0.9rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 5px 10px;
  text-decoration: none;
  text-transform: uppercase;
}

.post-codes a:hover {
  background: var(--accent);
  color: #fff;
}

.post-title h3 {
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.12;
  margin: 0;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.game-mark {
  align-items: center;
  display: grid;
  gap: 6px;
  justify-items: center;
}

.game-code {
  color: var(--muted);
  font: 700 0.86rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.game-mark img {
  display: block;
  max-height: 64px;
  max-width: 112px;
  object-fit: contain;
}

.post-title p {
  color: var(--muted);
  margin: 3px 0 0;
}

.result-toggle {
  border-top: 1px solid var(--line);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}

.result-toggle button {
  background: var(--panel);
  border-radius: 0;
  color: var(--muted);
  font-size: 0.84rem;
  min-height: 40px;
}

.result-toggle button + button {
  border-left: 1px solid var(--line);
}

.result-toggle button.active {
  background: var(--ink);
  color: #fff;
}

[data-theme="night"] .result-toggle button.active {
  color: #1d1d1f;
}

.result-toggle button:disabled {
  color: #b7b7b7;
  cursor: not-allowed;
}

.result-panel {
  display: none;
}

.result-panel.active {
  display: block;
}

.incidents-panel {
  background: color-mix(in srgb, var(--panel) 92%, #000);
  border-top: 1px solid var(--line);
  padding: 14px;
}

.incidents-list {
  display: grid;
  gap: 12px;
}

.incident-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.incident-header {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.incident-header h4 {
  color: var(--red);
  font-size: 0.95rem;
  margin: 0;
  text-transform: uppercase;
}

.incident-header span {
  color: var(--muted);
  font-size: 0.84rem;
}

.incident-people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.person-pill {
  align-items: center;
  background: color-mix(in srgb, var(--red) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--red) 24%, var(--line));
  border-radius: 999px;
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px 5px 5px;
}

.person-pill img {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  height: 34px;
  object-fit: contain;
  width: 34px;
}

.person-pill span {
  display: grid;
  min-width: 0;
}

.person-pill small {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1;
  text-transform: uppercase;
}

.person-pill strong {
  color: var(--ink);
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}

.incident-description {
  color: var(--ink);
  margin: 0 0 12px;
}

.incident-body {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 0.75fr) minmax(340px, 1fr);
}

.incident-main {
  min-width: 0;
}

.incident-link {
  color: var(--red);
  display: inline-block;
  font: 700 0.8rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.incident-media {
  display: grid;
  gap: 8px;
  margin: 0;
  max-width: 360px;
}

.incident-media iframe {
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
  width: 100%;
}

.incident-media video {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  width: 100%;
}

.incident-preview {
  aspect-ratio: 16 / 9;
  align-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--red) 38%, #000), #151515);
  border-radius: 8px;
  color: #fff;
  display: grid;
  font: 700 0.82rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  justify-items: center;
  max-height: 205px;
  text-transform: uppercase;
  width: 100%;
}

.incident-penalties {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  min-width: 0;
}

.incident-section {
  background: color-mix(in srgb, var(--panel) 84%, #000);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.incident-section h5 {
  color: var(--muted);
  font: 700 0.74rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.incident-section p,
.incident-section ul {
  color: var(--ink);
  margin: 0;
}

.incident-section ul {
  display: grid;
  gap: 6px;
  list-style: none;
  padding: 0;
}

.incident-section li {
  border-left: 3px solid var(--red);
  padding-left: 8px;
}

.result-table-block {
  background: #000;
  background-image: linear-gradient(rgba(0, 0, 0, 0.54), rgba(0, 0, 0, 0.76)), var(--track-image);
  background-position: center;
  background-size: cover;
  padding: 10px 0 12px;
}

.result-table-block h4 {
  color: #fff;
  font-family: Orbitron, sans-serif;
  font-size: clamp(1.05rem, 2.1vw, 1.45rem);
  font-weight: 700;
  margin: 4px 10px 14px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.86);
  text-transform: uppercase;
}

.podium {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.34fr) minmax(0, 1fr);
  margin: 0 auto 12px;
  max-width: 660px;
  padding: 0 14px;
}

.podium-driver {
  align-items: center;
  background: rgba(14, 14, 14, 0.76);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #fff;
  display: grid;
  gap: 5px;
  justify-items: center;
  min-width: 0;
  padding: 10px 8px;
  text-align: center;
}

.podium-driver img {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid currentColor;
  border-radius: 999px;
  height: 64px;
  object-fit: contain;
  padding: 3px;
  width: 64px;
}

.podium-driver strong {
  color: var(--gold);
  font: 700 0.68rem Orbitron, sans-serif;
  overflow-wrap: anywhere;
}

.podium-position {
  color: currentColor;
  font: 700 0.72rem Orbitron, sans-serif;
}

.podium-1 {
  border-color: #f4c542;
  color: #f4c542;
  min-height: 124px;
  transform: translateY(8px);
}

.podium-2 {
  border-color: #c7ccd5;
  color: #c7ccd5;
  min-height: 104px;
}

.podium-3 {
  border-color: #bf7a3a;
  color: #bf7a3a;
  min-height: 104px;
}

.podium-1 img {
  height: 78px;
  width: 78px;
}

.podium-2 img {
  height: 64px;
  width: 64px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 780px;
  width: 100%;
}

th {
  background: var(--red);
  color: #fff;
  font-family: Orbitron, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: #d8d8d8;
  font: 700 0.84rem Orbitron, sans-serif;
  padding: 10px 10px;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--table-row);
}

tbody tr:nth-child(odd) td:nth-child(1),
tbody tr:nth-child(odd) td:nth-child(2),
tbody tr:nth-child(odd) td:nth-child(5),
tbody tr:nth-child(odd) td:last-child {
  color: var(--gold);
}

tbody tr:nth-child(odd) td:nth-child(3),
tbody tr:nth-child(odd) td:nth-child(4),
tbody tr:nth-child(odd) td:nth-child(6),
tbody tr:nth-child(odd) td:nth-child(7),
tbody tr:nth-child(odd) td:nth-child(8),
tbody tr:nth-child(odd) td:nth-child(9) {
  color: var(--orange);
}

.numeric-cell {
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  text-align: center;
}

.delta-up {
  color: #33d17a !important;
}

.delta-down {
  color: #ff5c5c !important;
}

.delta-same {
  color: #cfcfcf !important;
}

.empty-result {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.event-card {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--panel) 94%, transparent), color-mix(in srgb, var(--panel) 78%, transparent)),
    var(--event-image, none) center / cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  padding: 16px;
}

.event-card-content {
  display: grid;
  gap: 8px;
}

.event-card h3 {
  font-size: 1rem;
  line-height: 1.2;
  margin: 0;
  text-transform: uppercase;
}

.event-card p {
  color: var(--muted);
  margin: 0;
}

.event-title-link {
  color: var(--ink);
  text-decoration: none;
}

.event-title-link:hover {
  color: var(--red);
}

.event-date {
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.league-grid,
.division-grid,
.user-grid {
  display: grid;
  gap: 14px;
}

.league-grid {
  grid-template-columns: 1fr;
}

.division-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.user-grid {
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.league-card,
.division-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  overflow: hidden;
}

.league-card {
  grid-template-columns: minmax(180px, 260px) 1fr;
  min-height: 230px;
}

.league-card img {
  align-self: center;
  display: block;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  width: 100%;
}

.league-card > div,
.division-card > div {
  padding: 14px;
}

.league-card span,
.division-card span,
.hero-card span {
  color: var(--accent);
  font: 700 0.8rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.division-card span {
  font-size: 0.98rem;
}

.league-card h2,
.division-card h3,
.hero-card h1 {
  margin: 6px 0;
}

.league-card p,
.division-card p,
.hero-card p {
  color: var(--muted);
  margin: 0;
}

.league-card p {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  display: -webkit-box;
  overflow: hidden;
}

.league-card dl {
  display: grid;
  gap: 6px 10px;
  grid-template-columns: auto 1fr;
  margin: 12px 0 0;
}

.league-card dt {
  color: var(--muted);
  font-weight: 700;
}

.league-card dd {
  margin: 0;
}

.hero-card {
  align-items: center;
  background-color: #050505;
  background-image: var(--hero-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  display: grid;
  gap: 16px;
  grid-template-columns: 96px 1fr;
  margin-bottom: 14px;
  min-height: 180px;
  padding: 20px;
}

.division-hero,
.event-hero {
  grid-template-columns: 112px minmax(0, 1fr) 150px;
}

.division-hero span {
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.division-hero > img,
.event-hero > img {
  height: 104px;
  width: 104px;
}

.division-hero-game {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.division-hero-game span {
  color: #fff;
  font: 700 clamp(0.95rem, 1.7vw, 1.2rem) -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-align: center;
  text-transform: uppercase;
}

.division-hero-game img {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  padding: 8px;
  width: 130px;
}

.hero-card::before {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.46));
  content: "";
  inset: 0;
  position: absolute;
}

.hero-card > * {
  position: relative;
  z-index: 1;
}

.hero-card {
  position: relative;
  overflow: hidden;
}

.hero-card img {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  height: 88px;
  object-fit: contain;
  width: 88px;
}

.hero-card p {
  color: #e4e4e4;
}

.description-wrap {
  display: grid;
  gap: 8px;
}

.description-wrap.collapsed p {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  display: -webkit-box;
  overflow: hidden;
}

.description-toggle {
  justify-self: start;
  min-height: 30px;
  padding-inline: 10px;
}

.subtabs,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.subtabs button,
.filter-row button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.division-card {
  align-items: center;
  display: grid;
  grid-template-columns: 120px 1fr;
  min-height: 188px;
}

.division-card img {
  height: 120px;
  object-fit: contain;
  padding: 8px;
  width: 120px;
}

.event-calendar-card {
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.42)), var(--event-image);
  background-position: center;
  background-size: cover;
  color: #fff;
  grid-template-columns: 1fr;
}

.event-calendar-card .division-card-main {
  min-height: 188px;
}

.event-calendar-card p {
  color: #e4e4e4;
}

.event-calendar-card h3 {
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.event-hero {
  background-image: none;
}

.division-card-main {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 112px;
}

.division-card-main > div {
  min-width: 0;
}

.division-game {
  align-items: center;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 6px;
  justify-items: center;
  padding-left: 12px;
}

.division-game img {
  height: 56px;
  object-fit: contain;
  padding: 0;
  width: 96px;
}

.division-game span {
  font-size: 0.92rem;
  text-align: center;
}

.division-card small {
  color: var(--muted);
  font: 700 0.74rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

.standings-table table {
  background: #000;
  min-width: 520px;
}

.league-post-list {
  display: grid;
  gap: 12px;
}

.league-post {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.league-post header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.league-post header > span {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.league-post p {
  color: var(--ink);
  margin: 0;
  white-space: pre-wrap;
}

.service-dashboard {
  display: grid;
  gap: 18px;
}

.service-dashboard.empty {
  color: var(--muted);
}

.portal-empty,
.service-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.portal-empty {
  padding: 16px;
}

.service-group {
  overflow: hidden;
}

.service-group-head {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 0;
  padding: 16px;
  text-align: left;
  width: 100%;
}

.service-group-head:hover {
  background: var(--bg);
  color: var(--ink);
}

.service-group-head h2 {
  font-size: 1.1rem;
  margin: 0;
}

.service-group-head span {
  color: var(--accent);
  flex: 0 0 auto;
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
}

.service-group-head::before {
  color: var(--accent);
  content: "+";
  font: 700 1.3rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

.service-group:not(.collapsed) .service-group-head::before {
  content: "-";
}

.portal-empty h2,
.portal-empty p {
  margin: 0;
}

.portal-empty p {
  color: var(--muted);
  text-transform: uppercase;
}

.portal-controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}

.portal-controls label {
  color: var(--muted);
  display: grid;
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  gap: 7px;
  text-transform: uppercase;
}

.portal-controls select {
  appearance: none;
  background-color: var(--bg);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: 700 0.95rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.2;
  min-height: 44px;
  padding: 8px 34px 8px 12px;
  text-transform: uppercase;
}

.portal-controls select:disabled {
  color: var(--muted);
  opacity: 0.62;
}

.service-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 16px 16px;
}

.service-group.collapsed .service-grid {
  display: none;
}

.service-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  min-height: 142px;
  padding: 14px;
  position: relative;
}

.service-card.actionable {
  cursor: pointer;
}

.service-card.actionable:hover,
.service-card.actionable:focus {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-soft);
  outline: 0;
}

.service-card.disabled {
  border-left-color: #8f8f8f;
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.service-card.disabled span {
  color: var(--muted);
}

.service-card .coming-soon {
  align-items: center;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 8px;
  color: #fff;
  display: flex;
  font: 700 0.86rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  inset: 0;
  justify-content: center;
  position: absolute;
  text-transform: uppercase;
  z-index: 1;
}

.service-card span {
  color: var(--accent);
  display: block;
  font: 700 0.76rem -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.service-card h3 {
  font-size: 1.02rem;
  line-height: 1.2;
  margin: 0;
}

.service-card p {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 920px) {
  .home-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: -1;
  }

  .service-grid {
    grid-template-columns: 1fr;
  }

  .qualifying-defaults {
    grid-template-columns: 1fr;
  }

  .qualifying-edit-table table {
    min-width: 1120px;
  }

  .race-edit-table table {
    min-width: 1420px;
  }

  .race-sheet-head,
  .race-points-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .race-points-tools select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 620px) {
  .app-header {
    min-height: 92px;
    padding: 14px 12px;
    position: sticky;
  }

  .tabs {
    overflow-x: auto;
    top: 143px;
  }

  .brand-wordmark {
    height: 42px;
  }

  .theme-toggle {
    min-width: 68px;
    padding-inline: 8px;
  }

  .header-actions {
    justify-content: center;
    margin-top: 10px;
    position: static;
    width: 100%;
  }

  .auth-status {
    max-width: 120px;
  }

  .app-header {
    flex-direction: column;
  }

  .brand-stack {
    left: auto;
    position: static;
    top: auto;
    transform: none;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .division-hero,
  .event-hero {
    grid-template-columns: 1fr;
  }

  .division-hero-game {
    justify-items: start;
  }

  .league-card {
    grid-template-columns: 1fr;
  }

  .division-grid {
    grid-template-columns: 1fr;
  }

  .division-card,
  .division-card-main {
    grid-template-columns: 1fr;
  }

  .division-game {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 10px;
  }

  .portal-controls {
    grid-template-columns: 1fr;
  }

  .league-post header {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding-inline: 10px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .post-header {
    align-items: flex-start;
    grid-template-columns: 1fr;
    padding-inline: 12px;
  }

  .post-main {
    align-items: flex-start;
  }

  .post-avatar {
    height: 58px;
    width: 58px;
  }

  .post-codes a {
    font-size: 0.78rem;
  }

  .game-mark {
    justify-items: center;
  }

  .result-toggle button {
    font-size: 0.78rem;
  }

  .incident-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .incident-penalties {
    grid-template-columns: 1fr;
  }

  .incident-body {
    grid-template-columns: 1fr;
  }

  .podium {
    grid-template-columns: 1fr;
    max-width: 260px;
  }

  .podium-driver {
    min-height: auto;
  }
}
