:root {
  --primary: #25D366;
  --primary-hover: #1EBE5D;
  --primary-light: #E8FBF0;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-light: #FEF2F2;
  --secondary: #6B7280;
  --bg: #F0F4F3;
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E5E7EB;
  --ring: rgba(37, 211, 102, 0.25);
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  --topbar-h: 60px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Auth pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: linear-gradient(135deg, #E8FBF0 0%, #F0F4F3 50%, #E0F2FE 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.install-card {
  max-width: 520px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 14px;
  color: var(--muted);
}

.auth-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.auth-form legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 8px;
  color: var(--muted);
}

.install-warning {
  margin-top: 20px;
  padding: 12px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #92400E;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* ── Form elements ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  font-size: 13px;
  font-weight: 600;
}

input, textarea, select {
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

input:focus, textarea:focus, select:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.hint code {
  background: #F3F4F6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--ring);
}

.btn-secondary {
  background: #F3F4F6;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
}

.btn-secondary:hover {
  background: #E5E7EB;
}

.btn-danger {
  background: var(--danger-light);
  color: #991B1B;
  border: 1px solid #FECACA;
  padding: 8px 14px;
}

.btn-danger:hover {
  background: #FEE2E2;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: #F3F4F6;
  color: var(--text);
}

.btn-block { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn:disabled {
  background: #D1D5DB;
  color: #9CA3AF;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
}

.btn-icon:hover {
  background: #F3F4F6;
  color: var(--text);
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--danger-light);
  color: #991B1B;
  border: 1px solid #FECACA;
}

.alert-success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.topbar-brand i {
  color: var(--primary);
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

/* ── Main layout ── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.total { background: #EEF2FF; color: #4F46E5; }
.stat-icon.sent { background: #ECFDF5; color: #059669; }
.stat-icon.pending { background: #FFFBEB; color: #D97706; }

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--primary);
}

.sub-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.divider {
  border-top: 1px dashed var(--border);
  margin: 20px 0;
}

.import-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.file-input {
  flex: 1;
  font-size: 13px;
}

/* ── Guest list ── */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.list-toolbar .card-title {
  margin-bottom: 0;
}

.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
}

.search-box input {
  padding-left: 36px;
  width: 220px;
}

.select-filter {
  width: auto;
  min-width: 140px;
}

.guest-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.25s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #085041;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.guest-info {
  flex: 1;
  min-width: 0;
}

.guest-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.guest-wa {
  font-size: 13px;
  color: var(--muted);
}

.guest-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-wa {
  background: var(--primary-light);
  color: #166534;
  border: 1px solid #BBF7D0;
  padding: 6px 12px;
  font-size: 13px;
}

.btn-wa:hover {
  background: #DCFCE7;
}

.badge-sent {
  background: #DEF7EC;
  color: #03543F;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

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

.empty-state i {
  font-size: 36px;
  color: #D1D5DB;
  display: block;
  margin-bottom: 12px;
}

.bulk-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.footer-note {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-sm { max-width: 420px; }

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

.modal-header h3 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { background: #059669; }
.toast.error { background: #DC2626; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .search-box input { width: 160px; }
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { flex-wrap: wrap; }
  .guest-item { flex-wrap: wrap; }
  .guest-actions { width: 100%; margin-top: 4px; }
  .guest-actions .btn { flex: 1; }
}
