:root {
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --slate-800: #1e293b;
  --slate-600: #475569;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --white: #ffffff;
  --red-500: #ef4444;
  --amber-500: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--slate-800);
  background: var(--slate-100);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Login */
.login-page {
  min-height: 100vh;
  background: var(--green-600);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-brand {
  padding: 24px;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--white);
  padding: 4px;
}

.brand-card h1 {
  margin: 0;
  color: var(--white);
  font-size: 28px;
}

.brand-card p {
  margin: 4px 0 0;
  color: #bbf7d0;
  font-size: 12px;
}

.login-panel {
  flex: 1;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  margin: 0 8px;
  padding: 32px 32px 48px;
}

.login-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--slate-600);
  font-size: 14px;
}

.login-form label {
  display: block;
  margin-bottom: 16px;
}

.login-form label span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--slate-600);
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--green-600);
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--green-700);
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
}

.alert-warning {
  background: #fffbeb;
  color: #b45309;
}

.alert-success {
  background: var(--green-50);
  color: var(--green-700);
}

/* Admin layout */
.admin-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: 64px;
  background: var(--green-600);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--white);
  padding: 4px;
}

.header-brand strong {
  display: block;
  font-size: 18px;
}

.header-brand span {
  display: block;
  font-size: 12px;
  color: #bbf7d0;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.header-user a {
  color: #dcfce7;
}

.header-user a:hover {
  color: var(--white);
}

.admin-body {
  flex: 1;
  display: flex;
  min-height: calc(100vh - 64px);
}

.admin-sidebar {
  width: 220px;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  padding: 16px 12px;
}

.menu-item {
  display: block;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--slate-600);
  font-size: 15px;
  margin-bottom: 4px;
}

.menu-item:hover {
  background: var(--green-50);
  color: var(--green-700);
}

.menu-item.active {
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 600;
}

.admin-content {
  flex: 1;
  padding: 24px;
}

.content-header h1 {
  margin: 0 0 20px;
  font-size: 24px;
}

.placeholder-card {
  background: var(--white);
  border: 1px dashed var(--slate-200);
  border-radius: 12px;
  padding: 48px 24px;
  color: var(--slate-600);
  text-align: center;
}

.page-banner {
  background: var(--green-600);
  color: var(--white);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.page-banner strong {
  display: block;
  font-size: 16px;
}

.page-banner span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #bbf7d0;
}

.venue-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.venue-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 20px;
}

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

.venue-card-header h2 {
  margin: 0;
  font-size: 18px;
}

.venue-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--slate-600);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.badge-pending {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-match-enrolling {
  background: #dcfce7;
  color: #15803d;
}

.badge-match-registration_closed,
.badge-match-ongoing {
  background: #fef3c7;
  color: #b45309;
}

.badge-match-finished,
.badge-match-completed {
  background: #f1f5f9;
  color: #64748b;
}

.badge-type-official {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-type-personal {
  background: #dbeafe;
  color: #1d4ed8;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 16px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--slate-600);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 22px;
  color: var(--slate-800);
}

.stat-highlight {
  color: var(--green-700);
}

.panel-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.withdraw-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.withdraw-form label {
  flex: 1;
  min-width: 200px;
}

.withdraw-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--slate-600);
}

.withdraw-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  font-size: 14px;
}

.panel-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

.bracket-round {
  margin-bottom: 16px;
}

.bracket-round h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--slate-600);
}

.pairing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pairing-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--slate-100);
  border-radius: 8px;
  font-size: 14px;
}

.pairing-item span:first-child,
.pairing-item span:last-child {
  flex: 1;
}

.pairing-vs {
  flex: 0 0 auto !important;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.pairing-bye {
  opacity: 0.7;
}

button.btn-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.score-form .form-actions {
  margin-top: 8px;
}

.score-pairing-card {
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fafafa;
}

.score-players {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.score-players span:first-child,
.score-players span:last-child {
  flex: 1;
}

.score-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.score-fields label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--slate-600);
}

.score-fields input,
.score-fields select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.score-finish-actions {
  margin-top: 16px;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 96px;
}

.action-group form {
  margin: 0;
}

.action-group .btn {
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
}

.venue-details p {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--slate-600);
  line-height: 1.5;
}

.venue-details .label {
  display: inline-block;
  min-width: 72px;
  color: var(--slate-800);
  font-weight: 600;
}

.image-group {
  margin-top: 16px;
}

.image-group-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: #64748b;
}

.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-grid img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
}

.venue-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.venue-actions form,
.venue-actions .reject-panel {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--green-600);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--green-700);
}

.btn-sm {
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
}

.btn-outline {
  background: var(--white);
  color: var(--slate-800);
  border: 1px solid var(--slate-200);
  list-style: none;
}

.btn-danger {
  background: #ef4444;
  color: var(--white);
}

.reject-panel summary {
  list-style: none;
}

.reject-panel summary::-webkit-details-marker {
  display: none;
}

.reject-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reject-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
}

.empty-state {
  background: var(--white);
  border-radius: 12px;
  padding: 64px 24px;
  text-align: center;
  color: #94a3b8;
}

.content-body .alert {
  margin-bottom: 16px;
}

.table-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--slate-200);
}

.data-table th {
  background: var(--slate-100);
  color: var(--slate-800);
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.data-table .sub-text {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #94a3b8;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.page-link {
  padding: 8px 16px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  font-size: 14px;
  color: var(--slate-800);
}

.page-link:hover {
  border-color: var(--green-600);
  color: var(--green-700);
}

.page-link.disabled {
  color: #cbd5e1;
  pointer-events: none;
}

.page-info {
  font-size: 14px;
  color: var(--slate-600);
}

.detail-toolbar {
  margin-bottom: 16px;
}

.back-link {
  font-size: 14px;
  color: var(--green-700);
}

.back-link:hover {
  color: var(--green-600);
}

.table-title-link {
  color: var(--green-700);
  font-weight: 600;
  text-decoration: none;
}

.table-title-link:hover {
  color: var(--green-600);
  text-decoration: underline;
}

.match-detail-actions {
  flex-wrap: wrap;
}

.registration-panel {
  margin-top: 20px;
}

.registration-panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.standings-group+.standings-group {
  margin-top: 16px;
}

.standings-group h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--slate-700);
}

.rank-cell {
  width: 72px;
  text-align: center;
}

.medal-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.medal-gold {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.medal-silver {
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.medal-bronze {
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
}

.rank-number {
  display: inline-block;
  min-width: 24px;
  font-weight: 600;
  color: var(--slate-700);
}

.standings-top-1 {
  background: #fffbeb;
}

.standings-top-2 {
  background: #f8fafc;
}

.standings-top-3 {
  background: #fff7ed;
}

.registration-panel .empty-state {
  margin: 0;
  padding: 24px 0;
}

.match-detail-actions .btn {
  width: auto;
  min-width: 120px;
}

.image-grid-lg img {
  width: 120px;
  height: 120px;
}

@media (min-width: 768px) {
  .login-shell {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 48px;
    padding: 48px;
  }

  .login-brand {
    flex: 1;
    max-width: 420px;
  }

  .login-panel {
    flex: 0 0 420px;
    border-radius: 24px;
    margin: 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  }
}