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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fb;
  color: #111827;
  overflow: hidden;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 4px 20px 8px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile scroll fix */
@media (max-width: 1024px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }
  
  .page {
    overflow: visible;
    height: auto;
    min-height: 100vh;
    padding-bottom: 40px;
  }
}

.header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.logo-img {
  height: 50px;
  width: auto;
}

.header-title {
  font-size: 24px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
  align-items: end;
}

.clear-filters-btn {
  background-color: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.clear-filters-btn:hover {
  background-color: #b91c1c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.download-btn {
  background-color: #059669;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.download-btn:hover {
  background-color: #047857;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter label {
  font-size: 11px;
  font-weight: 600;
  color: #4b5563;
}

.filter select {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #dfe1e5;
  font-size: 12px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.filter select:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border-color: #c0c4c9;
}

.filter select:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 1px 3px rgba(66, 133, 244, 0.3);
}

/* Dashboard layout */
.dashboard {
  display: grid;
  grid-template-rows: auto 1fr;
  row-gap: 8px;
  flex: 1;
  min-height: 0;
}

/* Top summary row */
.summary {
  display: flex;
  gap: 12px;
  align-items: stretch;
  justify-content: center;
  flex-shrink: 0;
}

.tile {
  background: #111827;
  color: #e5e7eb;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
  position: relative;
}

.tile-small {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  text-align: center;
  padding: 14px 10px 18px;
  width: 180px;
  height: 180px;
}

.tile-label {
  font-size: 15px;
  line-height: 1.3;
  color: #ffffff;
  margin-bottom: 10px;
}

.tile-value {
  font-size: 54px;
  font-weight: 700;
  color: #22d3ee;
}

/* Gauges */
.gauge-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gauge-container .gauge-block {
  width: 320px;
}

.gauge-block {
  background: #f9fafb;
  border-radius: 12px;
  padding: 8px 10px 6px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.gauge-block h3 {
  font-size: 12px;
  margin-bottom: 4px;
}

.gauge-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-wrapper canvas {
  max-height: 100px;
}

.gauge-label {
  position: relative;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
}

.gauge-number {
  font-size: 32px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1;
}

.gauge-percent {
  font-size: 13px;
  font-weight: 500;
  color: #22d3ee;
  margin-top: 2px;
}

/* Bottom row */
.bottom {
  display: grid;
  grid-template-columns: 1.4fr 1.3fr;
  gap: 8px;
  min-height: 0;
  flex: 1;
  max-height: calc(100vh - 380px);
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 8px 12px 10px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.card h3 {
  font-size: 12px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.card-subtitle {
  font-size: 10px;
  color: #6b7280;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-total {
  background: #06b6d4;
}

.legend-completed {
  background: #4b5563;
}

#countryBarChart {
  flex: 1;
  min-height: 0;
}

/* Map */
.map {
  flex: 1;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
}

/* Leaflet tweaks */
.leaflet-container {
  width: 100%;
  height: 100%;
  background: #1a1a2e;
}

/* Country name labels on map */
.country-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.country-label span {
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  text-shadow: 
    1px 1px 2px rgba(0, 0, 0, 0.9),
    -1px -1px 2px rgba(0, 0, 0, 0.9),
    1px -1px 2px rgba(0, 0, 0, 0.9),
    -1px 1px 2px rgba(0, 0, 0, 0.9),
    0 0 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 1200px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary {
    flex-wrap: wrap;
  }

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

@media (max-width: 768px) {
  .page {
    padding: 8px 12px 16px;
  }

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

  .summary {
    flex-direction: column;
    align-items: center;
  }
  
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .header-left {
    width: 100%;
  }
  
  .header-right {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
  }
  
  .nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .nav-btn {
    min-width: 90px;
    padding: 5px 10px;
    font-size: 11px;
    height: 28px;
  }
  
  .dashboard {
    overflow: visible;
    height: auto;
  }
  
  .bottom {
    height: auto;
    min-height: 300px;
  }
  
  .tile-small {
    width: 150px;
    height: 150px;
  }
}


/* Header layout with nav tabs */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.nav-tabs {
  gap: 8px;
}

.nav-btn {
  background: #111827;
  color: #e5e7eb;
  border-radius: 999px;
  border: 1px solid #4b5563;
  padding: 6px 14px;
  min-width: 110px;
  text-align: center;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  box-sizing: border-box;
}

.nav-btn:hover {
  background: #1f2937;
  text-decoration: none !important;
}

.nav-btn:visited,
.nav-btn:active,
.nav-btn:focus {
  text-decoration: none !important;
  color: #e5e7eb;
}

.nav-btn-active {
  background: #22d3ee;
  color: #111827;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

/* Views */
.view {
  display: none;
}

.view.view-active {
  display: block;
}

/* Feedback filters */
.filters-feedback {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 10px 20px;
  background: #f1f5f9;
}

/* Feedback dashboard tweaks */
.dashboard-feedback {
  display: flex;
  flex-direction: column;
  padding: 10px 20px;
  gap: 10px;
  height: calc(100vh - 120px);
  overflow: hidden;
}

.summary-feedback {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.summary-feedback .tile-small {
  width: 140px;
  height: 120px;
  padding: 12px 10px;
}

.summary-feedback .tile-small .tile-label {
  font-size: 12px;
  line-height: 1.3;
}

.summary-feedback .tile-small .tile-value {
  font-size: 36px;
}

.gauge-container-feedback {
  display: flex;
  gap: 12px;
}

.gauge-container-feedback .gauge-block {
  width: 200px;
  height: 220px;
  background: #f9fafb;
  border-radius: 12px;
  padding: 12px 14px 10px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

.gauge-container-feedback .gauge-block h3 {
  font-size: 12px;
  margin-bottom: 8px;
  text-align: center;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-container-feedback .gauge-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-container-feedback .gauge-wrapper canvas {
  max-height: 100px;
}

.bottom-feedback {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
}

.card-feedback-map {
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card-feedback-map .map {
  flex: 1;
  min-height: 0;
}

/* Bowler table */
.bowler-card {
  background: #111827;
  border-radius: 16px;
  padding: 14px 16px 16px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
  color: #f9fafb;
  margin-top: 10px;
}

.bowler-title {
  font-size: 16px;
  margin-bottom: 10px;
}

.bowler-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.bowler-table thead th {
  background: #020617;
  color: #f9fafb;
  padding: 6px 4px;
  border: 1px solid #0f172a;
  text-align: center;
}

.bowler-table tbody th {
  background: #020617;
  color: #f9fafb;
  padding: 6px 4px;
  border: 1px solid #0f172a;
  text-align: left;
}

.bowler-table td {
  background: #111827;
  color: #e5e7eb;
  padding: 6px 4px;
  border: 1px solid #1f2937;
  text-align: center;
}

/* Ensure single page layout without scroll */
#view-cst.view-active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

#view-feedback.view-active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

#view-bowler.view-active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.filters-bowler {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 10px 20px;
  background: #f1f5f9;
  flex-shrink: 0;
}

.bowler-pct-row td {
  background: #0f172a !important;
  color: #22d3ee !important;
  font-weight: 600;
}

.bowler-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 12px;
  font-weight: 400;
}

/* CST Trainers View */
#view-trainers.view-active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.filters-trainers {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 10px 20px;
  background: #f1f5f9;
  flex-shrink: 0;
}

.dashboard-trainers {
  display: grid;
  grid-template-rows: auto 1fr;
  row-gap: 8px;
  flex: 1;
  min-height: 0;
  padding: 0 20px;
}

.summary-trainers {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.bottom-trainers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 0;
}

.card-trainers {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}

.card-trainers h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #111827;
}

.card-trainers canvas {
  flex: 1;
  min-height: 0;
}

.card-trainers-list {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-trainers-list h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #111827;
}

.trainers-list {
  flex: 1;
  overflow-y: auto;
}

.trainer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}

.trainer-item:last-child {
  border-bottom: none;
}

.trainer-name {
  font-weight: 500;
  color: #111827;
}

.trainer-country {
  color: #6b7280;
  font-size: 12px;
}

/* Admin View Container */
.admin-container {
  padding: 20px;
  height: auto;
  min-height: 100%;
  overflow-y: visible;
}

#view-admin {
  overflow-y: auto;
  height: calc(100vh - 120px);
}

@media (max-width: 1024px) {
  #view-admin {
    overflow-y: visible;
    height: auto;
  }
}

.admin-login-card {
  max-width: 400px;
  margin: 40px auto;
  background: #ffffff;
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-login-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #111827;
}

.admin-login-content > p {
  color: #6b7280;
  margin-bottom: 20px;
}

.admin-panel-content {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-header-bar h2 {
  font-size: 20px;
  color: #111827;
  margin: 0;
}

.admin-header-bar .btn-logout {
  margin-top: 0;
}

.admin-form-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.admin-form-group input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #6b7280;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-download {
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-download:hover {
  background: #047857;
}

.cst-download-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 0 10px;
}

.btn-download-completed {
  background: #22c55e;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.btn-download-completed:hover {
  background: #16a34a;
}

.btn-download-pending {
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.btn-download-pending:hover {
  background: #b91c1c;
}

.btn-upload {
  background: #7c3aed;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-upload:hover {
  background: #6d28d9;
}

#adminCountryFilter {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2937;
  font-size: 14px;
  min-width: 150px;
}

.btn-logout {
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
}

.btn-logout:hover {
  background: #b91c1c;
}

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

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #25D366;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-whatsapp:hover {
  background: #128C7E;
}

.error-msg {
  color: #dc2626;
  font-size: 13px;
  margin-top: 8px;
}

.success-msg {
  color: #059669;
  font-size: 13px;
  margin-top: 8px;
}

/* Admin Search */
.admin-search {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.admin-search input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

/* Admin Results Table */
.admin-results {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  background: #f3f4f6;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
}

.admin-table tbody tr:hover {
  background: #f9fafb;
}

.admin-table .btn-edit {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.admin-table .btn-edit:hover {
  background: #1d4ed8;
}

/* Admin Edit Form */
.admin-edit-form {
  background: #f9fafb;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}

.admin-edit-form h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #111827;
}

.admin-form-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-field label {
  font-size: 11px;
  font-weight: 600;
  color: #4b5563;
}

.admin-field input,
.admin-field select {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
}

.admin-form-actions {
  display: flex;
  gap: 12px;
}

@media (max-width: 768px) {
  .admin-form-fields {
    grid-template-columns: repeat(2, 1fr);
  }
}
