/* Race control: the operator's console on the timing laptop. */

body {
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--bone);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--bone);
}
.btn.primary {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--on-accent);
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  color: var(--bad);
  border-color: rgba(239, 90, 76, 0.5);
}
.btn.big {
  height: 54px;
  padding: 0 24px;
  font-size: 17px;
  border-radius: 12px;
}
.btn.xs {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input,
select {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--deep);
  color: var(--bone);
  min-width: 0;
}
input:focus,
select:focus {
  outline: 2px solid var(--orange);
  outline-offset: -1px;
}
input[readonly] {
  color: var(--muted);
}
input:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* top bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: rgba(21, 25, 29, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.brand img {
  height: 26px;
}
.brand .brand-logo {
  height: 30px;
  max-width: 110px;
}
.heatpick {
  display: flex;
  gap: 8px;
}
.heatpick select {
  max-width: 200px;
}
.tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel);
}
.tabs button {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.on {
  background: var(--card);
  color: var(--bone);
}
.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.conn i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}
.conn.ok i {
  background: var(--ok);
}
.conn.off i {
  background: var(--bad);
}

.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h3 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.cardhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cardhead h3 {
  margin: 0;
}
.note {
  color: var(--muted);
  margin: 0 0 14px;
  max-width: 80ch;
}
.twocol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* start bar */
.startbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.phase-clock {
  font-size: 54px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.phase-sub {
  color: var(--muted);
  margin-top: 6px;
}
.startactions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.startactions select {
  height: 54px;
}
.startbar.live {
  border-color: rgba(224, 82, 28, 0.6);
}
.startbar.live .phase-label,
.startbar.live #phase-label {
  color: var(--orange);
}

/* tables */
.grid {
  width: 100%;
  border-collapse: collapse;
}
.grid th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid td.r,
.grid th.r {
  text-align: right;
}
.grid tr:last-child td {
  border-bottom: 0;
}
.lanes-table {
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.lanes-table td {
  padding: 14px 10px;
}
.lanes-table .ln {
  font-size: 22px;
  font-weight: 700;
  width: 64px;
  padding-left: 18px;
}
.lanes-table .tm b {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}
.lanes-table .tm div {
  color: var(--muted);
  font-size: 13px;
}
.lanes-table .st b {
  font-weight: 600;
}
.lanes-table .st div {
  color: var(--muted);
  font-size: 13px;
}
.lanes-table .big {
  font-size: 20px;
  font-weight: 700;
}
.lanes-table .acts {
  text-align: right;
  white-space: nowrap;
  padding-right: 16px;
}
.lanes-table .acts .btn {
  margin-left: 4px;
}
.lanes-table tr.empty td {
  color: var(--dim);
}
.judge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  white-space: nowrap;
}
.judge i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  flex: none;
}
.judge.ok i {
  background: var(--ok);
}
.judge.stale i {
  background: var(--warn);
}
.judge .warn {
  color: var(--warn);
  font-weight: 600;
}
.minitrack {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.minitrack i {
  width: 14px;
  height: 5px;
  border-radius: 2px;
  background: var(--line);
}
.minitrack i.run {
  width: 6px;
}
.minitrack i.d {
  background: var(--done);
}
.minitrack i.n {
  background: var(--orange);
}
.pos-badge {
  display: inline-block;
  min-width: 34px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--card);
  text-align: center;
  font-weight: 700;
}
.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--card);
  color: var(--muted);
}
.status-tag.fin {
  color: var(--bone);
}
.status-tag.out {
  color: var(--bad);
}

.feed {
  margin: 0;
  padding: 0;
  list-style: none;
}
.feed li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.feed li:last-child {
  border-bottom: 0;
}
.feed li span:first-child {
  color: var(--muted);
}
.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}
.tips li {
  margin-bottom: 8px;
}
.tips b {
  color: var(--bone);
}

/* setup */
.savebar {
  position: sticky;
  top: 66px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0 14px;
  background: var(--bg);
}
.savebar #save-state {
  margin-right: auto;
  color: var(--muted);
}
.savebar.dirty #save-state {
  color: var(--warn);
  font-weight: 600;
}
.fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.fields label,
label.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.form-table input,
.form-table select {
  width: 100%;
}
.form-table td {
  padding: 6px 6px;
}
.form-table td.n {
  width: 40px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.form-table td.ops {
  width: 120px;
  white-space: nowrap;
  text-align: right;
}
.form-table input.narrow {
  width: 100px;
}
.lock {
  margin-left: 12px;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--warn);
}
.toggles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  max-width: 90ch;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--orange);
}
.check b {
  color: var(--bone);
}
label.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.inline-row {
  display: flex;
  gap: 8px;
}
.inline-row input {
  flex: 1;
}

/* judges */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.qr-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}
.qr-card .qr {
  width: 150px;
  height: 150px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}
.qr-card .qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.qr-card .l {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.qr-card .t {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin: 4px 0 8px;
}
.qr-card .u {
  font-size: 12px;
  color: var(--dim);
  word-break: break-all;
}
.qr-card .p {
  margin-top: 10px;
}

/* results */
.scrollx {
  overflow-x: auto;
}
.results-table td,
.results-table th {
  white-space: nowrap;
}
.results-table td.best {
  color: var(--orange);
  font-weight: 700;
}
.results-table .tm b {
  font-family: var(--serif);
  font-size: 16px;
}
.results-table .tm div {
  color: var(--muted);
  font-size: 12px;
}

/* screen tab */
.screen-layout {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 18px;
  align-items: start;
}
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  align-items: center;
}
.seg button {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.seg button.on {
  background: var(--bone);
  border-color: var(--bone);
  color: var(--deep);
}
.seg.small span {
  color: var(--muted);
  margin-right: 6px;
}
.seg.small button {
  height: 34px;
}
.screen-layout .card > * + * {
  margin-top: 14px;
}
.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--deep);
  border: 1px solid var(--line);
}
.preview iframe {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

/* login */
.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  width: min(92vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-box img {
  width: 96px;
  margin: 0 auto 10px;
}
.login-box .brand-logo {
  width: auto;
  height: 64px;
  max-width: 220px;
}
.login-box h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
}
.login-box p {
  color: var(--muted);
  margin: 0;
}
.login-box input {
  height: 52px;
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.3em;
}
.err {
  color: var(--bad);
  min-height: 1.3em;
}

/* modal */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: min(100%, 620px);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 22px;
}
.modal h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}
.modal p {
  color: var(--muted);
  margin: 0 0 16px;
}
.modal .grid input {
  width: 120px;
  text-align: right;
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal .err {
  margin-top: 10px;
}
.modal .fields {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--bone);
  color: var(--deep);
  font-weight: 600;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(24px);
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}

/* print: judge cards on white paper */
.print-cards {
  display: none;
}
@media print {
  @page {
    size: A4;
    margin: 12mm;
  }
  body {
    background: #fff !important;
    color: #000;
  }
  .bar,
  .wrap,
  .toast,
  .login,
  .modal-bg {
    display: none !important;
  }
  .print-cards {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8mm;
  }
  .pcard {
    break-inside: avoid;
    border: 0.4mm solid #000;
    border-radius: 4mm;
    padding: 6mm;
    text-align: center;
    color: #000;
    font-family: var(--sans);
  }
  .pcard .pl {
    font-size: 12pt;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }
  .pcard .pn {
    font-size: 54pt;
    font-weight: 800;
    line-height: 1;
  }
  .pcard .pt {
    font-family: var(--serif);
    font-size: 15pt;
    margin: 2mm 0 3mm;
    min-height: 1.2em;
  }
  .pcard svg {
    width: 52mm;
    height: 52mm;
  }
  .pcard .pu {
    font-size: 8pt;
    margin-top: 2mm;
    word-break: break-all;
  }
  .pcard .ph {
    font-size: 8.5pt;
    margin-top: 2mm;
  }
}

@media (max-width: 1100px) {
  .bar {
    flex-wrap: wrap;
  }
  .tabs {
    margin-left: 0;
    order: 5;
    width: 100%;
  }
  .twocol,
  .screen-layout {
    grid-template-columns: 1fr;
  }
  .qr-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fields {
    grid-template-columns: 1fr;
  }
}

/* branding card */
.logo-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: center;
}
.logo-box {
  height: 120px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
  padding: 14px;
}
.logo-box img {
  max-width: 100%;
  max-height: 100%;
}
.logo-row .note {
  margin-bottom: 12px;
}
html[data-theme='adidas'] .startbar.live {
  border-color: rgba(255, 255, 255, 0.6);
}
html[data-theme='adidas'] .seg button.on {
  color: #000;
}
@media print {
  .pcard .plogo {
    display: block;
    height: 14mm;
    max-width: 50mm;
    margin: 0 auto 3mm;
    object-fit: contain;
    filter: brightness(0);
  }
}

/* team confirmation */
.ok-text {
  color: var(--ok);
  font-weight: 600;
}
.warn-text {
  color: var(--warn);
  font-weight: 600;
}
.bad-text {
  color: var(--bad);
  font-weight: 700;
}
.results-table .conf {
  margin-top: 4px;
  font-size: 12px;
  white-space: normal;
}
.nowrap {
  white-space: nowrap;
}

.results-table td.sp small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--dim);
}
.results-table td.sp .best {
  color: var(--orange);
  font-weight: 700;
}
.results-table td.sp small .best {
  color: var(--bone);
}
