:root {
  --green: #2E7D32;
  --green-light: #4CAF50;
  --red: #C62828;
  --red-light: #E53935;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.admin-header {
  background: var(--green);
  color: white;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}
.header-brand { display: flex; align-items: center; gap: .75rem; }
.logo { height: 44px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.header-title { font-size: 1.25rem; font-weight: 700; color: white; }
.header-sub { font-weight: 400; opacity: .8; font-size: .9rem; }
.admin-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.admin-nav a, .btn-link {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  font-size: .875rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.admin-nav a:hover, .btn-link:hover { color: white; text-decoration: underline; }

/* Main */
.admin-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
}

/* Footer */
.admin-footer {
  text-align: center;
  padding: .75rem;
  font-size: .75rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.page-header h1, .page-header h2 { margin: 0; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--green); color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: #F59E0B; color: white; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.form-group label { font-size: .85rem; font-weight: 500; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
  padding: .5rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: .9rem;
  transition: border-color .15s;
  background: white;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--green);
}
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; font-weight: 400; font-size: .875rem; margin-bottom: .25rem; }
.input-eye { display: flex; gap: 0; }
.input-eye input { flex: 1; border-radius: 6px 0 0 6px; }
.eye-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .65rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  color: var(--gray-600);
  transition: background .15s, color .15s;
  min-width: 38px;
}
.eye-toggle:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: .875rem;
}
.data-table th {
  background: var(--green);
  color: white;
  text-align: left;
  padding: .6rem .9rem;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table td { padding: .6rem .9rem; border-bottom: 1px solid var(--gray-100); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.row-paused td { opacity: .6; font-style: italic; }

/* Badges */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-toss { background: #E8F5E9; color: var(--green); }
.badge-elimination { background: #FFF3E0; color: #E65100; }
.badge-roundrobin { background: #E3F2FD; color: #1565C0; }
.badge-groups_knockout { background: #F3E5F5; color: #6A1B9A; }
.badge-status-draft { background: var(--gray-200); color: var(--gray-600); }
.badge-status-active { background: #E8F5E9; color: var(--green); }
.badge-status-ending { background: #FFF3E0; color: #E65100; }
.badge-status-finished { background: var(--gray-200); color: var(--gray-600); }
.badge-status-paused { background: #FFF3E0; color: #E65100; }
.badge-status-active { background: #E8F5E9; color: var(--green); }
.badge-test { background: #FFF9C4; color: #F57F17; }
.badge-superadmin { background: var(--red); color: white; }
.badge-admin { background: var(--green); color: white; }

/* Alerts */
.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert-error { background: #FFEBEE; color: var(--red); border-left: 4px solid var(--red); }
.alert-success { background: #E8F5E9; color: var(--green); border-left: 4px solid var(--green); }
.alert-info { background: #E3F2FD; color: #1565C0; border-left: 4px solid #1565C0; }

/* Auth card */
.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.auth-card h1 { margin-bottom: 1.25rem; font-size: 1.3rem; }
.auth-logo { display: block; height: 60px; margin: 0 auto 1.25rem; }

/* Courts grid */
.courts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.court-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.court-card h3 { color: var(--green); margin-bottom: .75rem; font-size: 1rem; }
.match-row { padding: .6rem; border-radius: 6px; margin-bottom: .5rem; }
.match-in_progress { background: #E8F5E9; border-left: 4px solid var(--green); }
.match-pending { background: #F3F4F6; border-left: 4px solid var(--gray-400); }
.match-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; margin-bottom: .3rem; }
.match-teams { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .875rem; }
.vs { color: var(--gray-400); font-style: italic; font-size: .8rem; }
.score-form { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }

/* Tournament controls */
.tournament-controls { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* Empty state */
.empty-state { color: var(--gray-400); font-style: italic; text-align: center; padding: 2rem 1rem; }

/* Responsive */
@media (max-width: 600px) {
  .admin-main { padding: 1rem; }
  .header-inner { padding: .6rem 1rem; }
  .page-header { flex-direction: column; }
}
