:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111827;
  --panel-2: #0f172a;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #3b4bff;
  --primary-2: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(59, 75, 255, 0.15);
}

.sidebar-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-tab {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sidebar-tab.active {
  border-color: var(--primary);
  background: rgba(59, 75, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.main-content {
  flex: 1;
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.card-body {
  padding: 18px 20px;
}

.mode-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mode-btn.active {
  border-color: var(--primary);
  color: #cbd5ff;
}

.week-selector,
.custom-selector {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.week-select,
.input,
.search-input,
select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
}

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

.date-inputs {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.week-dates {
  color: var(--muted);
  font-size: 13px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.btn-success {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.progress-container {
  display: none;
  margin-top: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  transition: width 0.2s ease;
}

.progress-text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.table-container {
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
  position: relative;
}

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

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

.data-table th {
  font-size: 12px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: #1a1a2e;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.4px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 12px;
}

.empty-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.empty-text {
  font-size: 14px;
}

.actions-bar,
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  flex: 1;
  min-width: 250px;
}

.search-box .search-input {
  border: none;
  background: transparent;
  padding: 4px;
  flex: 1;
}

.search-icon {
  color: var(--muted);
}

.sent-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  margin-left: auto;
}

.sent-counter .counter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sent-counter .counter-value {
  font-size: 20px;
  font-weight: 700;
  color: #60a5fa;
  min-width: 40px;
  text-align: center;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.sent {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

.single-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.single-form .input {
  flex: 1;
  min-width: 250px;
}

.btn-icon {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
}

.modal-content {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(900px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 0;
  flex: 1;
}

#preview-iframe {
  width: 100%;
  height: 70vh;
  border: none;
  background: white;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.loading {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-footer {
    width: 100%;
  }

  .main-content {
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-bar,
  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }

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