:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --bg-2: #111;
  --panel: #171717;
  --panel-soft: #202020;
  --field: #0f1012;
  --line: #333;
  --line-strong: #555;
  --text: #f4f4f4;
  --muted: #b9b9b9;
  --top-muted: #c8c8c8;
  --primary: #c51f26;
  --primary-dark: #98171d;
  --accent: #ededed;
  --danger: #ff6b63;
  --warning: #e3b75f;
  --ok: #57c27a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #0b0b0b;
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

body::before {
  content: none;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
  color: var(--text);
}

button {
  min-height: 34px;
  padding: 6px 11px;
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

button:hover {
  border-color: var(--primary);
  background: #242424;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  text-transform: uppercase;
}

a.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.primary:hover,
a.button.primary:hover {
  background: var(--primary-dark);
}

button.danger {
  border-color: rgba(255, 107, 99, 0.65);
  color: var(--danger);
}

button.icon {
  width: 34px;
  padding: 0;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  overflow: hidden;
}

button.icon::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

button.move-up::before {
  border-bottom: 7px solid currentColor;
}

button.move-down::before {
  border-top: 7px solid currentColor;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(197, 31, 38, 0.2);
  outline-offset: 1px;
  border-color: var(--primary);
}

textarea {
  min-height: 92px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 3px solid var(--primary);
  background: rgba(8, 9, 11, 0.94);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-logo {
  width: 118px;
  max-width: 28vw;
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}

.topbar p {
  margin: 2px 0 0;
  color: var(--top-muted);
}

.topbar button {
  border-color: #59606c;
  background: #101217;
  color: #fff;
}

.topbar button:hover {
  border-color: #fff;
  background: #171b22;
}

.topbar button.primary {
  border-color: var(--primary);
  background: var(--primary);
}

.topbar button.primary:hover {
  background: var(--primary-dark);
}

.race-control-invite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.discord-logo {
  width: 19px;
  height: 19px;
  margin-right: 7px;
  flex: 0 0 auto;
}

.race-control-invite:hover {
  background: var(--primary-dark);
}

.actions,
.row-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 4px solid var(--primary);
  background: #111;
}

.tab-group {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 6px;
  border: 1px solid #2b2b2b;
  border-radius: 2px;
  background: #151515;
}

.tab-group-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #1b1b1b;
  color: #ddd;
}

.tab-notification-badge {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border-radius: 999px;
  background: var(--danger);
  color: #080808;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

main {
  width: 100%;
  max-width: none;
  margin: 0 0 40px;
  padding: 26px 20px 40px;
  background: #111;
  min-height: calc(100vh - 150px);
}

.panel {
  display: none;
}

.login-panel {
  max-width: 520px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
  text-transform: uppercase;
}

.login-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

.panel.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-head select {
  max-width: 180px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 4px;
  min-height: 108px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-card.error {
  border-color: rgba(255, 107, 99, 0.85);
  background: rgba(255, 107, 99, 0.08);
}

.summary-card.error .summary-value,
.summary-card.error .summary-label {
  color: var(--danger);
}

.summary-card.ok {
  border-color: rgba(87, 194, 122, 0.7);
  background: rgba(87, 194, 122, 0.08);
}

.summary-card.ok .summary-value,
.summary-card.ok .summary-label {
  color: var(--ok);
}

.summary-value {
  color: #fff;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.summary-label {
  color: var(--text);
  font-weight: 800;
  text-transform: uppercase;
}

.summary-detail {
  color: var(--muted);
  font-size: 12px;
}

.home-section-head {
  margin: 20px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.home-section-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
}

.team-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.team-summary-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}

.team-summary-title {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
}

.team-logo {
  width: 36px;
  height: 36px;
  grid-row: span 2;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #080808;
}

.team-logo.small {
  width: 28px;
  height: 28px;
  grid-row: auto;
}

.team-logo-preview {
  width: 140px;
  max-width: 100%;
  max-height: 90px;
  object-fit: contain;
  justify-self: start;
  padding: 8px;
  border: 1px solid var(--line);
  background: #080808;
}

.team-summary-title strong {
  color: #fff;
  font-size: 16px;
}

.team-summary-title span {
  color: var(--muted);
  font-size: 12px;
}

.team-summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.team-summary-stats span {
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
  font-size: 12px;
  font-weight: 700;
}

.team-summary-stats .r2la-complete {
  border-color: rgba(87, 194, 122, 0.75);
  background: rgba(87, 194, 122, 0.16);
  color: var(--ok);
}

.team-summary-stats .r2la-partial {
  border-color: rgba(227, 183, 95, 0.8);
  background: rgba(227, 183, 95, 0.14);
  color: var(--warning);
}

.team-summary-stats .grids-complete {
  border-color: rgba(87, 194, 122, 0.75);
  background: rgba(87, 194, 122, 0.16);
  color: var(--ok);
}

.team-summary-stats .grids-partial {
  border-color: rgba(227, 183, 95, 0.8);
  background: rgba(227, 183, 95, 0.14);
  color: var(--warning);
}

.team-summary-stats .prefs-complete {
  border-color: rgba(87, 194, 122, 0.75);
  background: rgba(87, 194, 122, 0.16);
  color: var(--ok);
}

.team-summary-stats .prefs-partial {
  border-color: rgba(227, 183, 95, 0.8);
  background: rgba(227, 183, 95, 0.14);
  color: var(--warning);
}

.team-summary-managers {
  color: var(--muted);
  font-size: 12px;
}

.team-summary-drivers {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.team-summary-driver-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.vehicle-grid-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
}

.vehicle-grid-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}

.vehicle-grid-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.vehicle-grid-head strong {
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.vehicle-grid-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.vehicle-model-list {
  display: grid;
  gap: 5px;
}

.vehicle-model-row,
.vehicle-issue-row {
  display: grid;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--field);
}

.vehicle-model-row {
  grid-template-columns: minmax(100px, 150px) minmax(160px, 1fr) auto;
}

.vehicle-model-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.vehicle-issue-list {
  display: grid;
  gap: 6px;
}

.vehicle-issue-row {
  grid-template-columns: minmax(160px, 220px) minmax(180px, 1fr) minmax(160px, 240px) minmax(220px, 1fr);
  border-color: rgba(255, 107, 99, 0.6);
  background: rgba(255, 107, 99, 0.08);
}

.vehicle-issue-row strong,
.vehicle-issue-row span:nth-child(3) {
  color: var(--danger);
}

.agenda-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 10px;
}

.agenda-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}

.agenda-card.pause {
  border-color: rgba(227, 183, 95, 0.45);
  background: rgba(227, 183, 95, 0.05);
}

.agenda-card.info {
  border-color: rgba(87, 194, 122, 0.45);
  background: rgba(87, 194, 122, 0.05);
}

.agenda-card.conflict {
  border-color: rgba(255, 107, 99, 0.75);
  background: rgba(255, 107, 99, 0.06);
}

.agenda-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.agenda-slot-title {
  display: grid;
  gap: 2px;
}

.agenda-slot-title strong {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
}

.agenda-slot-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.agenda-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.agenda-rows {
  display: grid;
  gap: 6px;
}

.agenda-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 1.6fr);
  align-items: center;
  gap: 7px;
}

.agenda-driver {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--field);
  font-weight: 700;
}

.agenda-choice.absent {
  border-color: rgba(227, 183, 95, 0.85);
  background: rgba(227, 183, 95, 0.12);
  color: var(--warning);
}

.agenda-choice.present {
  border-color: rgba(87, 194, 122, 0.8);
  background: rgba(87, 194, 122, 0.12);
  color: var(--ok);
}

.agenda-choice.chassis {
  border-color: rgba(87, 194, 122, 0.8);
  background: rgba(87, 194, 122, 0.12);
  color: var(--ok);
}

.agenda-row.conflict .agenda-driver,
.agenda-row.conflict .agenda-choice {
  border-color: rgba(255, 107, 99, 0.9);
  background: rgba(255, 107, 99, 0.13);
  color: var(--danger);
}

.agenda-conflict {
  font-size: 12px;
  font-weight: 700;
}

.agenda-countdown {
  min-height: 120px;
  border-color: rgba(87, 194, 122, 0.75);
  background: rgba(87, 194, 122, 0.1);
}

.agenda-countdown .summary-value {
  font-size: 40px;
}

.agenda-schedule {
  display: grid;
  gap: 16px;
}

.agenda-section {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.agenda-section h3,
.agenda-main-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
}

.agenda-section p {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.agenda-lines,
.agenda-event-lines {
  display: grid;
  gap: 5px;
}

.agenda-event-lines {
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(87, 194, 122, 0.06);
}

.agenda-line {
  display: grid;
  grid-template-columns: minmax(72px, 92px) 1fr;
  gap: 8px;
  align-items: baseline;
  color: var(--text);
  font-size: 16px;
}

.agenda-line strong {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.agenda-line span {
  color: var(--muted);
  font-size: 16px;
}

.agenda-rounds {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.standings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--panel);
}

.standings-races-count {
  justify-self: start;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.standings-table {
  width: 100%;
  min-width: 840px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 18px;
}

.standings-table th,
.standings-table td {
  min-width: 58px;
  padding: 8px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.standings-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-soft);
  color: #fff;
  font-size: 13px;
  text-transform: uppercase;
}

.standings-table tbody tr:nth-child(even) th,
.standings-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

.standings-table tbody tr:hover th,
.standings-table tbody tr:hover td {
  background: rgba(197, 31, 38, 0.11);
}

.standings-table tbody tr.standing-podium-1 th,
.standings-table tbody tr.standing-podium-1 td {
  background: rgba(212, 175, 55, 0.18);
  border-bottom-color: rgba(212, 175, 55, 0.55);
}

.standings-table tbody tr.standing-podium-2 th,
.standings-table tbody tr.standing-podium-2 td {
  background: rgba(192, 192, 192, 0.16);
  border-bottom-color: rgba(192, 192, 192, 0.5);
}

.standings-table tbody tr.standing-podium-3 th,
.standings-table tbody tr.standing-podium-3 td {
  background: rgba(205, 127, 50, 0.17);
  border-bottom-color: rgba(205, 127, 50, 0.5);
}

.standings-table tbody tr.standing-podium:hover th,
.standings-table tbody tr.standing-podium:hover td {
  filter: brightness(1.16);
}

.standings-table .standing-position,
.standings-table th:first-child {
  min-width: 46px;
  text-align: center;
}

.standings-table .standing-trend,
.standings-table thead th:nth-child(2) {
  min-width: 82px;
  text-align: center;
  font-weight: 800;
}

.standings-table .standing-trend.gain {
  color: var(--ok);
}

.standings-table .standing-trend.loss {
  color: var(--danger);
}

.standings-table .standing-trend.stable {
  color: var(--muted);
}

.standings-table .standing-team,
.standings-table thead th:nth-child(3) {
  min-width: 210px;
  text-align: left;
}

.standings-table .standing-drivers,
.standings-table thead th:nth-child(4) {
  min-width: 320px;
  max-width: 420px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}

.standings-table tbody .standing-team {
  font-weight: 600;
}

.standings-table tbody .standing-drivers {
  font-weight: 300;
}

.standings-table .standing-total {
  color: #fff;
  font-weight: 800;
}

.stream-stats-table-wrap {
  max-height: calc(100vh - 260px);
}

.stream-stats-table {
  min-width: max-content;
  table-layout: fixed;
  font-size: 13px;
}

.stream-stats-table th,
.stream-stats-table td {
  min-width: 48px;
  width: 48px;
  padding: 7px 8px;
  text-align: right;
}

.stream-stats-table tbody th,
.stream-stats-table tbody td {
  font-size: 13px;
}

.stream-stats-table th,
.stream-stats-table td {
  white-space: nowrap;
}

.stream-sort-button {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  font-size: inherit;
  font-weight: 800;
  line-height: inherit;
}

.stream-sort-button:hover {
  background: transparent;
  color: #fff;
}

.stream-stats-table th.sorted {
  color: #fff;
  background: #2a2a2a;
}

.stream-stats-table .stream-rank {
  min-width: 42px;
  width: 42px;
  text-align: center;
}

.stream-stats-table .stream-name {
  min-width: 190px;
  width: 190px;
  text-align: left;
}

.stream-stats-table .stream-team {
  min-width: 76px;
  width: 76px;
  text-align: center;
}

.stream-stats-table .stream-points,
.stream-stats-table .stream-percent,
.stream-stats-table .stream-wins {
  min-width: 64px;
  width: 64px;
  font-weight: 800;
}

.stream-stats-table .stream-wins-positive {
  color: var(--ok);
  background: rgba(87, 194, 122, 0.1);
}

.stream-stats-table .stream-race {
  min-width: 52px;
  width: 52px;
}

.stream-stats-table .stream-dnf {
  color: var(--warning);
  font-weight: 800;
}

.stream-team-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.stream-team-profile {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  background: var(--panel);
}

.stream-team-profile-hero {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 72px;
}

.stream-team-profile-logo {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  object-fit: contain;
  padding: 6px;
  border: 1px solid var(--line);
  background: #080808;
}

.stream-team-profile-logo.placeholder {
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.stream-team-profile-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.stream-team-profile-title span,
.stream-team-profile-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stream-team-profile-title strong {
  overflow: hidden;
  color: #fff;
  font-size: 22px;
  line-height: 1.05;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.stream-team-profile-managers {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #101010;
}

.stream-team-profile-managers span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stream-team-profile-managers strong {
  color: #fff;
  font-size: 15px;
}

.stream-team-profile-drivers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stream-team-profile-drivers .driver-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stream-team-profile-drivers .country-flag {
  width: 18px;
  height: 18px;
}

.standing-team-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}

.standing-team-content span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.standings-chart {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.standings-chart h3 {
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
}

.standings-chart svg {
  width: 100%;
  min-height: 300px;
  overflow: visible;
}

.chart-grid,
.chart-tick {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chart-line {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  stroke: #080808;
  stroke-width: 2;
}

.chart-line-label {
  font-size: 12px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #080808;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.driver-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
  color: var(--text);
  font-weight: 650;
}

.driver-chip.r2la {
  border-color: rgba(87, 194, 122, 0.65);
  color: var(--ok);
}

.driver-chip.missing-r2la {
  border-color: rgba(227, 183, 95, 0.8);
  color: var(--warning);
}

.r2la-drivers-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: #101010;
}

.r2la-drivers-list.compact {
  max-height: 150px;
  margin-top: 6px;
}

.r2la-unmatched-box {
  padding: 8px;
  border: 1px solid rgba(227, 183, 95, 0.55);
  background: rgba(227, 183, 95, 0.06);
}

.r2la-unmatched-box > strong {
  display: block;
  color: var(--warning);
  font-size: 12px;
  text-transform: uppercase;
}

.country-flag {
  display: inline-block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.country-flags {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.log-view {
  max-height: 360px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #080808;
  color: #d9dde4;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.compact-field {
  min-width: 220px;
}

.live-team.ok {
  border-color: rgba(87, 194, 122, 0.45);
}

.live-team.warn {
  border-color: rgba(227, 183, 95, 0.75);
}

.live-team.error {
  border-color: rgba(255, 107, 99, 0.85);
}

.live-team .item-head {
  grid-template-columns: minmax(80px, 140px) 1fr auto auto;
}

.live-alert {
  font-weight: 800;
}

.live-status {
  justify-self: end;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.live-status.ok {
  border-color: rgba(87, 194, 122, 0.75);
  background: rgba(87, 194, 122, 0.16);
  color: var(--ok);
}

.live-status.warn {
  border-color: rgba(227, 183, 95, 0.8);
  background: rgba(227, 183, 95, 0.14);
  color: var(--warning);
}

.live-status.error {
  border-color: rgba(255, 107, 99, 0.85);
  background: rgba(255, 107, 99, 0.14);
  color: var(--danger);
}

.live-team-body,
.live-driver-list,
.live-server-list,
.live-conflicts {
  display: grid;
  gap: 6px;
}

.live-driver-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(56px, 70px) minmax(160px, 1fr) minmax(200px, 1.4fr) minmax(140px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
}

.live-driver-row.with-actions {
  grid-template-columns: minmax(160px, 1.2fr) minmax(56px, 70px) minmax(160px, 1fr) minmax(200px, 1.4fr) minmax(120px, 0.8fr) minmax(260px, 1.2fr);
}

.live-grid-badge {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid rgba(87, 194, 122, 0.65);
  border-radius: 2px;
  background: rgba(87, 194, 122, 0.12);
  color: var(--ok);
  font-weight: 800;
}

.live-driver-row.warn {
  border-color: rgba(227, 183, 95, 0.8);
  background: rgba(227, 183, 95, 0.1);
}

.live-driver-row.error {
  border-color: rgba(255, 107, 99, 0.85);
  background: rgba(255, 107, 99, 0.1);
}

.live-driver-row.error .live-grid-badge {
  border-color: rgba(255, 107, 99, 0.85);
  background: rgba(255, 107, 99, 0.14);
  color: var(--danger);
}

.live-unmatched-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.live-server {
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
}

.grid-tabs,
.team-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.grid-tab,
.team-tab {
  min-width: 46px;
  border-color: var(--line-strong);
  background: #1b1b1b;
  color: #ddd;
}

.grid-tab.active,
.team-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.grid-tab.rule-violation {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 99, 0.4), 0 0 10px rgba(255, 107, 99, 0.2);
}

.grid-tab.rule-violation.active {
  background: var(--danger);
  color: #080808;
}

.team-tabs {
  max-width: 100%;
  overflow-x: visible;
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.team-tab {
  flex: 0 0 auto;
  min-width: 56px;
}

.panel-tabs {
  margin: -2px 0 12px;
}

.control-server-tabs {
  margin-bottom: 10px;
}

.rf2-grid-form {
  display: grid;
  grid-template-columns: minmax(72px, 96px) minmax(90px, 120px) minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.rf2-grid-result {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(87, 194, 122, 0.65);
  border-radius: 2px;
  background: rgba(87, 194, 122, 0.12);
}

.rf2-grid-result strong {
  color: var(--ok);
}

.stack {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.item-head {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.item-title {
  font-weight: 800;
  text-transform: uppercase;
}

.item-body {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field span,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.field span {
  text-transform: uppercase;
}

.driver-country-control span {
  display: none;
}

.teams-picker {
  display: grid;
  gap: 8px;
}

.teams-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.teams-picker-head > span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.teams-picker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.team-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.team-choice.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.team-choice.disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.team-choice input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.driver-name-control,
.driver-select-control {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  gap: 6px;
}

input.validated,
select.validated {
  border-color: var(--ok);
}

input.unvalidated,
select.unvalidated {
  border-color: var(--warning);
}

.driver-validation {
  min-width: 44px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: transparent;
  font-size: 11px;
  font-weight: 800;
}

.driver-validation.valid {
  border-color: rgba(87, 194, 122, 0.65);
  background: rgba(87, 194, 122, 0.14);
  color: var(--ok);
}

.list {
  display: grid;
  gap: 6px;
}

.list-row {
  display: grid;
  grid-template-columns: 34px 34px minmax(160px, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.list-row.team-row {
  grid-template-columns: 34px 34px minmax(90px, 120px) minmax(160px, 1fr) auto;
}

.list-row.driver-row {
  grid-template-columns: 34px 34px minmax(180px, 1fr) minmax(110px, 130px) minmax(240px, 330px) auto;
}

.list-row.rule-violation,
.r2la-team-match-row.rule-violation {
  margin: 1px 0;
  padding: 5px 7px;
  border: 2px solid rgba(255, 107, 99, 0.95);
  border-left-width: 7px;
  border-radius: 2px;
  background: rgba(255, 107, 99, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 99, 0.22);
}

.list-row.rule-violation select,
.r2la-team-match-row.rule-violation select {
  border-color: var(--danger);
  background: rgba(255, 107, 99, 0.08);
}

.list-row.user-request-row {
  grid-template-columns: minmax(140px, 190px) minmax(180px, 1fr) minmax(160px, 220px) auto;
}

.rules-summary-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 7px;
}

.r2la-team-match-row {
  display: grid;
  grid-template-columns: minmax(80px, 120px) minmax(220px, 1fr) minmax(180px, auto);
  align-items: center;
  gap: 8px;
}

.r2la-local-team {
  display: grid;
  gap: 2px;
}

.r2la-local-team small {
  color: var(--muted);
  font-size: 11px;
}

.driver-discord-control {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
}

code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0c0c0c;
  color: #ff8181;
}

.message {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel-soft);
  white-space: pre-wrap;
}

.message.ok {
  border-color: rgba(87, 194, 122, 0.65);
  color: var(--ok);
}

.message.error {
  border-color: rgba(255, 107, 99, 0.75);
  color: var(--danger);
}

.message.warn {
  border-color: rgba(227, 183, 95, 0.75);
  color: var(--warning);
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}

.market-card {
  display: grid;
  gap: 11px;
  padding: 17px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.market-card.status-closed,
.market-card.status-expired,
.market-card.status-recruited {
  opacity: 0.72;
  border-top-color: var(--line-strong);
}

.market-card-head,
.market-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.market-card h3,
.market-card p {
  margin: 0;
}

.market-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.market-status {
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.market-status.status-active {
  border-color: var(--ok);
  color: var(--ok);
}

.market-status.status-discussion {
  border-color: var(--warning);
  color: var(--warning);
}

.market-author {
  color: #fff;
  font-weight: 700;
}

.market-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.market-meta span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.market-description,
.market-experience {
  white-space: pre-wrap;
}

.market-experience {
  color: var(--muted);
}

.market-form-body {
  display: grid;
  gap: 16px;
}

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

.market-form-grid .field:nth-last-child(-n + 3) {
  grid-column: 1 / -1;
}

.market-apply-area,
.market-applications {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.market-application-form {
  display: grid;
  gap: 10px;
}

.market-applications {
  display: grid;
  gap: 9px;
}

.market-applications h4 {
  margin: 0;
}

.market-application {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  background: var(--field);
}

.market-application.status-accepted,
.market-application.status-attached {
  border-color: var(--ok);
}

.market-application.status-rejected,
.market-application.status-withdrawn {
  opacity: 0.68;
}

.market-application-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.market-application p {
  margin: 0;
  white-space: pre-wrap;
}

.market-manager-note {
  color: var(--warning);
}

.market-status.status-pending {
  border-color: var(--warning);
  color: var(--warning);
}

.market-status.status-accepted,
.market-status.status-attached {
  border-color: var(--ok);
  color: var(--ok);
}

.market-status.status-rejected,
.market-status.status-withdrawn {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 760px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-logo {
    width: 92px;
    max-width: 34vw;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .actions .race-control-invite {
    flex: 1;
  }

  .tabs {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 8px;
    overflow-x: auto;
    padding-left: 12px;
    padding-right: 12px;
  }

  .tab-group {
    flex: 0 0 auto;
    min-width: 152px;
  }

  main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .item-head,
  .summary-grid,
  .team-summary-grid,
  .vehicle-grid-summary,
  .agenda-grid,
  .agenda-rounds,
  .grid-4,
  .list-row,
  .list-row.team-row,
  .list-row.driver-row,
  .list-row.user-request-row,
  .vehicle-model-row,
  .vehicle-issue-row,
  .agenda-row,
  .live-driver-row,
  .rf2-grid-form {
    grid-template-columns: 1fr;
  }

  .live-driver-row.with-actions,
  .live-unmatched-actions,
  .driver-discord-control,
  .market-form-grid {
    grid-template-columns: 1fr;
  }

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

  .market-card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .market-application-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions,
  .inline-actions {
    flex-wrap: wrap;
  }

  .grid-tabs,
  .team-tabs {
    width: 100%;
    overflow-x: visible;
    flex-wrap: wrap;
  }

  .grid-tab,
  .team-tab {
    flex: 0 0 auto;
  }
}
