/* ===== Global ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --secondary: #1f2937;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #374151;
  --bg-light: #1f2937;
  --bg-white: #111827;
  --text-dark: #f3f4f6;
  --text-light: #9ca3af;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
      'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background-color: #0f1419;
  color: var(--text-dark);
  line-height: 1.5;
}

/* ===== Container ===== */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Header ===== */
.header {
  background: var(--bg-white);
  border-bottom: 2px solid var(--border);
  padding: 24px 0;
  margin-bottom: 30px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.header-stats {
  display: flex;
  gap: 30px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
  background: var(--bg-white);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.3s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.btn-secondary {
  background-color: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-body {
  padding: 20px;
}

/* ===== Column Grid ===== */
.column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.column-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f2937;
}

.column-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.column-item label {
  cursor: pointer;
  flex: 1;
  font-size: 14px;
}

/* ===== Table ===== */
.table-wrapper {
  background: var(--bg-white);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background-color: var(--bg-light);
  border-bottom: 2px solid var(--border);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  position: relative;
}

th:hover {
  background-color: #1f2937;
}

.sort-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-light);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: #1f2937;
}

td {
  padding: 12px 16px;
  color: var(--text-dark);
}

.checkbox-cell {
  width: 40px;
}

.checkbox-cell input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-active {
  background-color: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.badge-inactive {
  background-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.badge-autopay {
  background-color: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-view {
  background-color: var(--accent);
  color: white;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-view:hover {
  background-color: #0891b2;
}

.btn-delete {
  background-color: var(--danger);
  color: white;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-delete:hover {
  background-color: #dc2626;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-white);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pagination button {
  padding: 8px 12px;
  min-width: 36px;
  text-align: center;
}

.pagination button.active {
  background-color: var(--primary);
  color: white;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #e5e7eb;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-stats {
    width: 100%;
    justify-content: space-around;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px 12px;
  }

  .column-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Detail View ===== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.detail-item {
  padding: 12px;
  background: #1f2937;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.detail-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 6px;
}

.detail-value {
  font-size: 16px;
  font-weight: 500;
  color: #f3f4f6;
  word-break: break-word;
}

/* ===== Loader ===== */
.loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}