:root {
  --primary: #b91c2b;
  --accent: #0f766e;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --soft: #f5f7fb;
  --paper: #ffffff;
  --gold: #b7791f;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--soft);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

button.secondary {
  color: var(--ink);
  background: #eef2f7;
}

button.ghost {
  color: var(--primary);
  border: 1px solid rgba(185, 28, 43, 0.28);
  background: #fff;
}

.button-like.ghost {
  color: var(--primary);
  border: 1px solid rgba(185, 28, 43, 0.28);
  background: #fff;
}

button.danger {
  background: var(--danger);
}

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

.button-like {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.page-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.mobile-shell {
  width: min(520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.hero-panel,
.panel,
.form-panel {
  border: 1px solid rgba(217, 222, 232, 0.9);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-panel {
  overflow: hidden;
}

.hero-image {
  display: none;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #dbe4ef;
}

.hero-image[src]:not([src=""]) {
  display: block;
}

.hero-body {
  padding: 24px;
}

.logo-image {
  display: none;
  width: auto;
  max-width: 148px;
  max-height: 52px;
  margin-bottom: 14px;
  object-fit: contain;
}

.logo-image[src]:not([src=""]) {
  display: block;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 21px;
  line-height: 1.35;
}

h3 {
  font-size: 17px;
}

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  margin-bottom: 0;
  line-height: 1.7;
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.meta-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.meta-item strong {
  color: var(--ink);
}

.form-panel {
  margin-top: 16px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label,
.field-title {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd6e4;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status {
  margin: 14px 0 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #344054;
  background: #eef4ff;
}

.status.success {
  color: var(--success);
  background: #ecfdf3;
}

.status.error {
  color: var(--danger);
  background: #fef3f2;
}

.status.warn {
  color: #93370d;
  background: #fffaeb;
}

.window-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.window-chip {
  border: 1px solid #d9dee8;
  border-radius: 8px;
  padding: 10px 12px;
  color: #475467;
  background: #fff;
  font-size: 13px;
}

.score-sheet-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid #111827;
  background: #fff;
}

.score-sheet {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  background: #fff;
  color: #111827;
  text-align: center;
}

.score-sheet th,
.score-sheet td {
  border: 1px solid #111827;
  padding: 9px 8px;
  font-size: 15px;
}

.score-sheet th {
  font-weight: 700;
}

.score-sheet .score-name {
  width: 92px;
  font-weight: 700;
}

.score-sheet .score-max {
  width: 72px;
}

.score-sheet .score-input-cell {
  width: 108px;
}

.score-input {
  width: 78px;
  min-height: 34px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  padding: 6px;
  text-align: center;
}

.score-total {
  font-weight: 800;
  color: var(--primary);
}

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

.serial-line.single-field {
  grid-template-columns: 1fr;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.admin-brand {
  margin: 4px 4px 14px;
}

.admin-brand h1 {
  margin: 0 0 4px;
  font-size: 21px;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav button {
  justify-content: flex-start;
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.admin-nav button.active {
  color: #fff;
  background: var(--primary);
}

.panel {
  padding: 20px;
}

.panel + .panel {
  margin-top: 14px;
}

.data-block {
  min-width: 0;
}

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

.panel-head h2 {
  margin-bottom: 4px;
}

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

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

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

.qr-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  text-align: center;
}

.qr-box img {
  width: 220px;
  height: 220px;
  max-width: 100%;
  image-rendering: pixelated;
}

.qr-box h3 {
  margin-bottom: 8px;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  color: #344054;
  background: #f8fafc;
  font-weight: 800;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.editable-list {
  display: grid;
  gap: 10px;
}

.edit-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.score-row {
  grid-template-columns: minmax(90px, 1fr) 90px minmax(180px, 2fr) auto;
}

.contestant-row {
  grid-template-columns: minmax(90px, 1fr) minmax(160px, 2fr) auto;
}

.image-preview {
  display: block;
  width: 100%;
  max-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #f8fafc;
}

.hidden {
  display: none !important;
}

.footer-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.home-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.home-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.home-link strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}

.home-link span {
  color: var(--muted);
  font-size: 14px;
}

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

  .admin-sidebar {
    position: static;
  }

  .admin-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-2,
  .grid-3,
  .qr-grid,
  .home-links {
    grid-template-columns: 1fr;
  }

  .edit-row,
  .score-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .page-shell,
  .mobile-shell {
    width: min(100% - 20px, 520px);
  }

  .hero-body {
    padding: 20px 16px;
  }

  h1 {
    font-size: 23px;
  }

  .serial-line {
    grid-template-columns: 1fr;
  }

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

  .panel {
    padding: 16px;
  }
}
