:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #6a737d;
  --line: #dbe1e6;
  --line-strong: #c7d0d8;
  --accent: #117865;
  --accent-dark: #075c4c;
  --accent-soft: #e5f3ef;
  --danger: #bf3f31;
  --warn-soft: #fff2de;
  --shadow: 0 16px 42px rgba(31, 43, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4f1 0, rgba(238, 244, 241, 0) 310px),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

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

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #f1f5f4;
  border-color: #d5dfdc;
  color: var(--ink);
}

button.secondary:hover {
  background: #e6eeeb;
}

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

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 120, 101, 0.12);
}

textarea {
  resize: vertical;
  min-height: 88px;
}

a {
  color: var(--accent-dark);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

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

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 850;
}

.brand p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #e6ecea;
  border: 1px solid #d7e1de;
  border-radius: 8px;
  padding: 5px;
  margin: 14px 0 16px;
}

.tabs button {
  background: transparent;
  color: #5f6968;
  min-height: 38px;
  padding: 0 8px;
}

.tabs button:hover,
.tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(27, 31, 36, 0.07);
}

.section {
  margin-top: 16px;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.login-panel {
  width: min(480px, 100%);
  margin: 34px auto 0;
  padding: 22px;
}

.admin-login {
  border-top: 4px solid #263238;
}

.login-mark {
  width: fit-content;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 5px 9px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 850;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(31, 43, 54, 0.05);
}

.metric.good {
  background: var(--accent-soft);
  border-color: #badcd4;
}

.metric-value {
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.metric-label {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

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

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

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

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

.field label {
  display: block;
  color: #4f5b62;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

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

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

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

.guest-card:hover {
  border-color: #b7c9c4;
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.rank-list {
  display: grid;
  gap: 9px;
}

.rank-item {
  display: grid;
  grid-template-columns: 36px 1fr 82px 36px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.rank-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #23302f;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.rank-actions {
  display: grid;
  grid-template-columns: repeat(2, 36px);
  gap: 6px;
}

.icon-btn {
  min-width: 36px;
  width: 36px;
  padding: 0;
  background: #eef3f1;
  border-color: #dae4e1;
  color: var(--ink);
}

.icon-btn:hover {
  background: #dfe9e6;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfc;
}

.status {
  margin-top: 4px;
  min-height: 20px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: #526169;
  font-weight: 800;
  background: #f8faf9;
}

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

.pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr 42px;
  gap: 8px;
  align-items: center;
}

.canvas-wrap {
  width: 100%;
  overflow-x: auto;
}

#resultCanvas {
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  body {
    background: var(--bg);
  }

  .shell {
    max-width: 430px;
    padding: 18px 14px 40px;
  }

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

  .brand h1 {
    font-size: 24px;
  }

  .grid,
  .grid.three,
  .metrics {
    grid-template-columns: 1fr;
  }

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

  .panel {
    padding: 14px;
  }

  .login-panel {
    margin-top: 18px;
  }

  .admin-table {
    min-width: 760px;
  }

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

  .pair-row {
    grid-template-columns: 1fr;
  }

  .rank-item {
    grid-template-columns: 34px 1fr 36px;
  }

  .rank-actions {
    grid-column: 2 / 3;
    grid-row: 2;
  }
}
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-overlay .panel { max-width: 480px; width: 100%; box-shadow: 0 24px 64px rgba(0,0,0,0.2); }
 
