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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  background: white;
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

h1 {
  color: #333;
  margin-bottom: 25px;
  font-size: 2.5em;
  text-align: center;
}

h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.5em;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 25px;
  border-radius: 10px;
  text-align: center;
  color: white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-label {
  display: block;
  font-size: 0.9em;
  opacity: 0.9;
  margin-bottom: 10px;
}

.stat-value {
  display: block;
  font-size: 2em;
  font-weight: bold;
}

.filters {
  background: white;
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-weight: 600;
  color: #555;
  font-size: 0.9em;
}

.input-group input,
.input-group select {
  padding: 12px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: #667eea;
}

button {
  padding: 12px 25px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-filter {
  background: #667eea;
  color: white;
}

.btn-filter:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-reset {
  background: #6c757d;
  color: white;
}

.btn-reset:hover {
  background: #5a6268;
  transform: translateY(-2px);
}

.btn-refresh {
  background: #28a745;
  color: white;
}

.btn-refresh:hover {
  background: #218838;
  transform: translateY(-2px);
}

.btn-export {
  background: #17a2b8;
  color: white;
}

.btn-export:hover {
  background: #138496;
  transform: translateY(-2px);
}

.btn-copy {
  background: #ffc107;
  color: #333;
  margin-top: 10px;
}

.btn-copy:hover {
  background: #e0a800;
  transform: translateY(-2px);
}

/* Improved API controls styling for better layout and responsiveness */
.api-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
}

.btn-api {
  background: #007bff;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 123, 255, 0.2);
}

.btn-api:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-api-sync {
  background: #28a745;
}

.btn-api-sync:hover {
  background: #218838;
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-api-stats {
  background: #17a2b8;
}

.btn-api-stats:hover {
  background: #138496;
  box-shadow: 0 4px 8px rgba(23, 162, 184, 0.3);
}

.btn-api-config {
  background: #6c757d;
}

.btn-api-config:hover {
  background: #5a6268;
  box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.btn-icon {
  font-size: 1.2em;
  line-height: 1;
}

.btn-text {
  line-height: 1;
}

.api-status {
  font-size: 0.85em;
  font-weight: 600;
  padding: 10px 18px;
  background: white;
  border-radius: 20px;
  border: 2px solid #e9ecef;
  white-space: nowrap;
}

.data-section {
  background: white;
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
}

tbody tr {
  border-bottom: 1px solid #eee;
  transition: background-color 0.3s ease;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

td {
  padding: 15px;
}

.type-badge {
  display: inline-block;
  padding: 5px 15px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85em;
}

.type-click {
  background: #e3f2fd;
  color: #1976d2;
}

.type-lead {
  background: #e8f5e9;
  color: #388e3c;
}

/* Added source badge styling */
.source-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 600;
}

.source-api {
  background: #d1ecf1;
  color: #0c5460;
}

.source-postback {
  background: #fff3cd;
  color: #856404;
}

.country-flag {
  font-size: 1.5em;
  margin-right: 5px;
}

.revenue {
  color: #28a745;
  font-weight: 600;
}

.no-data {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

.postback-info {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.info-box {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 15px;
}

.info-box code {
  display: block;
  background: #333;
  color: #0f0;
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  font-family: "Courier New", monospace;
}

.info-box ul {
  margin-left: 20px;
  margin-top: 10px;
}

.info-box li {
  margin: 8px 0;
  color: #555;
}

.info-box li code {
  display: inline;
  background: #e9ecef;
  color: #d63384;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Added modal styling for API stats */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: white;
  margin: 10% auto;
  padding: 30px;
  border-radius: 15px;
  width: 80%;
  max-width: 600px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
}

.close {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  transition: color 0.3s;
}

.close:hover {
  color: #000;
}

.api-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.api-stat-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
}

.api-stat-item h3 {
  font-size: 0.9em;
  margin-bottom: 10px;
  opacity: 0.9;
}

.api-stat-value {
  font-size: 2em;
  font-weight: bold;
  margin: 0;
}

@media (max-width: 768px) {
  h1 {
    font-size: 1.8em;
  }

  /* Better mobile responsiveness for API controls */
  .api-controls {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .btn-api {
    width: 100%;
    justify-content: center;
  }

  .api-status {
    width: 100%;
    text-align: center;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }

  .filter-group {
    flex-direction: column;
  }

  .section-header {
    flex-direction: column;
    gap: 15px;
  }

  table {
    font-size: 0.85em;
  }

  th,
  td {
    padding: 10px;
  }
}
