:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #edf3f3;
  --ink: #182227;
  --muted: #617077;
  --line: #d8e0e2;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --blue: #244b7a;
  --amber: #b7791f;
  --green: #2f7d4f;
  --red: #a13d3d;
  --shadow: 0 16px 40px rgba(21, 36, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-header {
  display: grid;
  grid-template-columns: minmax(180px, 300px) 1fr;
  align-items: start;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.app-title {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
}

#programMeta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.header-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.header-controls label {
  flex: 1 1 140px;
  min-width: 0;
}

.header-controls label:has(#competitionFilter),
.header-controls label:has(#programSelect),
.header-controls label:has(#elementFilter) {
  flex-basis: 240px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
}

select {
  height: 36px;
  min-width: 180px;
  padding: 0 32px 0 10px;
}

input {
  height: 36px;
  width: 100%;
  padding: 0 10px;
}

.header-controls input {
  min-width: 0;
}

#seasonFilter,
#levelFilter,
#statusFilter {
  min-width: 140px;
}

#competitionFilter {
  min-width: 240px;
}

.header-controls select,
.header-controls input {
  width: 100%;
  min-width: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1.08fr) minmax(350px, 0.82fr) minmax(360px, 0.92fr);
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 78px);
  max-width: 100vw;
}

.video-pane,
.table-pane,
.detail-pane {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.video-pane {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  overflow: hidden;
}

.video-shell {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111b22;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

iframe[hidden],
#clipPlayer[hidden],
video[hidden] {
  display: none;
}

#clipPlayer {
  width: 100%;
  height: 100%;
  display: block;
  background: #111b22;
}

.source-notice {
  min-height: 34px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.source-notice.warning {
  color: var(--amber);
  background: #fffaf0;
}

.source-notice.clip {
  color: var(--teal-dark);
  background: #eef7f6;
}

.support-panel {
  display: grid;
  grid-template-columns: minmax(136px, 166px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #f8fbfb;
}

.support-ad {
  display: grid;
  align-content: space-between;
  gap: 8px;
  aspect-ratio: 1 / 1;
  max-width: 166px;
  min-height: 136px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-decoration: none;
}

.support-ad:hover {
  border-color: var(--teal);
  background: #f4fbfa;
}

.support-ad[aria-disabled="true"] {
  cursor: default;
}

.support-ad[aria-disabled="true"]:hover {
  border-color: var(--line);
  background: var(--panel);
}

.support-ad span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.support-ad strong {
  font-size: 18px;
  line-height: 1.1;
}

.support-copy {
  display: grid;
  justify-items: start;
  gap: 10px;
  min-width: 0;
}

.support-copy p {
  max-width: 34ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.support-link {
  height: 34px;
}

.transport,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.section-head {
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.button.secondary:hover,
.icon-button:hover {
  background: var(--panel-soft);
}

.button.active {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: #eef7f6;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 170px);
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.col-number {
  width: 44px;
}

.col-team {
  width: 108px;
}

.col-score {
  width: 74px;
}

.col-time {
  width: 116px;
}

.col-status {
  width: 112px;
}

body.public-view table {
  min-width: 510px;
}

body.mode-loading .review-only,
body.public-view .review-only,
body.public-view .status-cell,
body.public-view .col-status,
body.public-view #detailStatus {
  display: none !important;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.number-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.favorite-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  background: var(--panel);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.favorite-button:hover,
.favorite-button.active {
  border-color: #d6a316;
  color: #8f6a00;
  background: #fff7dd;
}

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

.detail-favorite {
  width: 34px;
  height: 34px;
  font-size: 21px;
}

.auth-status {
  align-self: end;
  max-width: 170px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.numeric {
  font-variant-numeric: tabular-nums;
}

.number-cell,
.score-cell,
.time-cell,
.status-cell {
  white-space: nowrap;
}

.call-cell strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lift-context {
  display: inline-flex;
  max-width: 100%;
  min-height: 18px;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lift-context.combo {
  background: #fff4df;
  color: var(--amber);
}

.lift-context.standalone {
  background: #e8f3ff;
  color: var(--blue);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef7f6;
}

.empty-row {
  color: var(--muted);
  cursor: default;
}

.status-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.corrected {
  background: #e5f4ea;
  color: var(--green);
}

.pill.accepted {
  background: #e8f3ff;
  color: var(--blue);
}

.pill.needs_review {
  background: #fff4df;
  color: var(--amber);
}

.pill.rejected {
  background: #fdeaea;
  color: var(--red);
}

.mode-badge {
  align-self: end;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-transform: uppercase;
}

.detail-pane {
  padding-bottom: 12px;
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 14px 12px;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.judge-score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.judge-chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfb;
  font-size: 12px;
}

.judge-chip-id,
.judge-chip-country {
  color: var(--muted);
  font-weight: 700;
}

.judge-chip strong {
  justify-self: center;
  font-size: 14px;
  line-height: 1;
}

.judge-panel-list {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.judge-panel-list summary {
  cursor: pointer;
  font-weight: 700;
}

.judge-panel-list ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.judge-panel-list li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: baseline;
}

.judge-panel-list li span:nth-child(2) {
  overflow-wrap: anywhere;
}

.edit-form {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

.edit-form.read-only input,
.edit-form.read-only select,
.edit-form.read-only textarea {
  background: var(--panel-soft);
  color: var(--muted);
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.time-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.time-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.mini-button:hover {
  background: var(--panel-soft);
}

textarea {
  width: 100%;
  min-height: 136px;
  resize: vertical;
  padding: 10px;
  color: var(--ink);
  line-height: 1.4;
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.save-status {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1360px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .video-pane {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .app-header {
    align-items: stretch;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .header-controls {
    align-items: stretch;
  }

  .header-controls label,
  .header-controls input,
  .header-controls select,
  .header-controls button,
  .header-controls .button {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .transport {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .support-panel {
    display: none !important;
  }

  .table-wrap {
    max-height: none;
  }

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

@media (max-width: 520px) {
  .judge-score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
