:root {
  --bg-color: #F3F5F9;
  --sidebar-bg: #06342E;
  --sidebar-text: #8FA7A3;
  --sidebar-active-bg: #10B981;
  --sidebar-active-text: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --panel-bg: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --primary: #10B981; /* Emerald */
  --primary-hover: #059669;
  --danger: #EF4444;
  --success: #10B981;
  --border: #E5E7EB;
  --border-radius: 16px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.03);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.04);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.logo {
  display: flex;
  align-items: center;
  padding: 0 16px 32px 16px;
  gap: 12px;
}

.logo-icon {
  background: var(--sidebar-active-bg);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

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

.nav-item {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 14px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

.nav-item .icon {
  font-size: 18px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Main Content */
.content {
  flex: 1;
  padding: 40px 48px;
  overflow-y: auto;
}

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

.header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #111827;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.btn.primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn.clear {
  background-color: transparent;
  color: var(--text-muted);
}
.btn.clear:hover {
  color: var(--text-main);
  background-color: var(--border);
}
.btn.danger {
  background-color: #FEF2F2;
  color: var(--danger);
}
.btn.danger:hover {
  background-color: var(--danger);
  color: #fff;
}

/* Cards & Lists */
.card {
  background-color: var(--panel-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid #F9FAFB;
}

.list {
  list-style: none;
}
.list li {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s;
}
.list li:hover {
  background-color: #F8FAFC;
}
.list li:last-child {
  border-bottom: none;
}
.list .empty-state {
  color: var(--text-muted);
  justify-content: center;
  padding: 40px;
  font-weight: 500;
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-title {
  font-weight: 600;
  font-size: 16px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 10px;
}
.item-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* Modals */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(17, 24, 39, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--panel-bg);
  padding: 40px;
  border-radius: 20px;
  width: 480px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s ease;
}
.modal-content.qr-modal-content.expanded {
  width: 850px;
}
.modal.hidden .modal-content {
  transform: translateY(30px) scale(0.95);
}

.modal h3 {
  margin-bottom: 12px;
  font-size: 22px;
  font-weight: 700;
  color: #111827;
}
.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

.form-group {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}
input[type="text"], input[type="password"], select, textarea {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #F9FAFB;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #FFF;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}
input[type="file"] {
  font-size: 14px;
  color: var(--text-muted);
  background: #F9FAFB;
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed var(--border);
}
.hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

/* Utilities */
.hidden { display: none !important; }
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge.success { background: #ECFDF5; color: #047857; }
.badge.offline { background: #FEF2F2; color: #B91C1C; }
.badge.pending { background: #FFFBEB; color: #D97706; }

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: #111827;
  color: #fff;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  font-size: 15px;
  font-weight: 500;
  z-index: 2100;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(0);
}
.toast.hidden {
  opacity: 0;
  transform: translateY(40px);
  pointer-events: none;
}

/* QR Code Modal Specifics */
.qr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.qr-modal-header h3 { margin: 0; }

.qr-layout {
  display: flex;
  gap: 40px;
}
.qr-left-pane {
  flex: 1;
  background: #F8FAFC;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  border: 1px solid var(--border);
  position: relative;
}
.qr-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.qr-right-pane h4 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #111827;
}

.qr-steps {
  list-style: none;
  padding: 0;
  margin: 0;
}
.qr-steps li {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  font-size: 15px;
  color: #111827;
  font-weight: 500;
}
.step-num {
  background: #F0FDF4;
  color: #059669;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.qr-status-msg {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 30px;
  color: var(--text-muted);
  font-size: 14px;
}
.small-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #E5E7EB;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.qr-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-weight: 500;
}
.spinner-ring {
  width: 64px;
  height: 64px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Schedule Config */
.day-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.day-chip input { display: none; }
.day-chip span {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: #F3F4F6;
  color: #6B7280;
  border: 1.5px solid #E5E7EB;
  transition: all 0.15s;
}
.day-chip input:checked + span {
  background: #ECFDF5;
  color: #059669;
  border-color: #6EE7B7;
}
.time-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  width: 110px;
  text-align: center;
}
.time-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s ease;
}
.auth-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-card {
  background: #0B2421; /* Darker green for premium look */
  padding: 50px;
  border-radius: 24px;
  width: 440px;
  max-width: 90%;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  color: #fff;
}

.auth-card .form-group label {
  color: #A3B8B5;
}

.auth-card input[type="text"], .auth-card input[type="password"] {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.auth-card input[type="text"]:focus, .auth-card input[type="password"]:focus {
  background: rgba(255, 255, 255, 0.1);
}

.auth-card h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--panel-bg);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid #F9FAFB;
  text-align: center;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

/* Opt-out badge */
.badge.opt-out {
  background: #FEF2F2;
  color: #B91C1C;
  font-size: 11px;
}

/* Contact tag */
.contact-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #EEF2FF;
  color: #4338CA;
  margin-right: 4px;
}

/* Bar chart */
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.bar {
  width: 100%;
  max-width: 48px;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.bar-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Campaign progress bar */
.campaign-progress {
  width: 100%;
  height: 6px;
  background: #E5E7EB;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.campaign-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Search input focus */
#contacts-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}
