:root {
  --bg: #faf6f8;
  --surface: #ffffff;
  --border: #ecdfe6;
  --text: #241a20;
  --text-muted: #7a6b73;
  --primary: #da1570;
  --primary-dark: #ac1958;
  --primary-light: #fde8f1;
  --accent: #0d688f;
  --success: #16a34a;
  --danger: #d50241;
  --radius: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top header — approcx.com style */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  box-shadow: 0 1px 3px rgba(36, 26, 32, 0.05);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-product {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.topbar-product-name { font-weight: 800; font-size: 17px; color: var(--text); }
.topbar-product-tag { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-powered {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.topbar-approcx { display: flex; align-items: center; }
.topbar-logo { height: 28px; width: auto; display: block; }

.topbar-divider { width: 1px; height: 22px; background: var(--border); }
.topbar-user { font-size: 13px; font-weight: 700; color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 12.5px; text-decoration: none; }

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1f1420;
  color: #e6d4dc;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 24px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-style: italic;
  font-size: 17px;
  color: white;
  box-shadow: 0 2px 8px rgba(218, 21, 112, 0.35);
}

.brand-title { font-weight: 800; font-size: 16px; color: white; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: #a88b96; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: #c7aab5;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  font-weight: 500;
}

.nav-item:hover { background: #34202c; color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  font-size: 11px;
  color: #8a7079;
  padding: 8px;
  border-top: 1px solid #34202c;
  margin-top: 12px;
  padding-top: 16px;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: #8a7079;
}

.powered-by a {
  color: #e6a3c0;
  text-decoration: none;
  font-weight: 700;
}

.powered-by a:hover { text-decoration: underline; }

/* Content */
.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.panel-header { margin-bottom: 24px; }
.panel-header h1 { margin: 0 0 4px; font-size: 22px; }
.panel-header p { margin: 0; color: var(--text-muted); font-size: 14px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(20, 21, 43, 0.03);
}

.card h3 { margin-top: 0; font-size: 15px; }

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

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333549;
}
.field label .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}

.html-field-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.html-field-head label:first-child { flex: 1; }
.html-upload-btn { cursor: pointer; white-space: nowrap; margin-bottom: 6px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
}

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfbfd;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; font-family: "SF Mono", Menlo, monospace; font-size: 12.5px; }

.checkbox-field label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-field input { width: auto; }

.hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.hint a { color: var(--primary); font-weight: 600; text-decoration: none; }
.hint a:hover { text-decoration: underline; }

.preview-frame {
  width: 100%;
  height: 240px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.send-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
}

.send-summary { font-size: 13px; color: var(--text-muted); }

.progress-card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.progress-head-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
}

.progress-track {
  height: 8px;
  background: var(--primary-light);
  border-radius: 99px;
  overflow: hidden;
}

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

.queue-list {
  margin-top: 14px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.queue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.queue-row:last-child { border-bottom: none; }
.queue-row .q-name { font-weight: 600; min-width: 140px; }
.queue-row .q-email { color: var(--text-muted); flex: 1; }
.queue-row .q-status { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.q-status.pending { background: #f1eef0; color: var(--text-muted); }
.q-status.sending { background: var(--primary-light); color: var(--primary); }
.q-status.success { background: #dcfce7; color: #16a34a; }
.q-status.failed { background: #fee2e2; color: #dc2626; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  padding: 8px 16px;
  border: none;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.seg-btn.active { background: var(--primary); color: white; }

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

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

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

.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }

.preview-table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--border); border-radius: 8px; }
.preview-table th { background: #fafafd; }

.import-summary { font-size: 13px; color: var(--text-muted); margin: 10px 0; }

.sample-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.sample-row .field { flex: 1; margin-bottom: 0; }
.sample-row .btn { text-decoration: none; white-space: nowrap; margin-bottom: 16px; }

.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.link-btn.view-btn { color: var(--primary); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.badge.done { background: #dcfce7; color: #16a34a; }
.badge.running { background: #fef3c7; color: #b45309; }
.badge.stopped { background: #fee2e2; color: #dc2626; }
.badge.pending { background: #e5e7eb; color: #4b5563; }

.hidden { display: none !important; }

/* Recipients picker */
.recipients-card { padding: 18px 22px; }
.recipients-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.recipients-head h3 { margin: 0; font-size: 15px; }
.recipient-search { max-width: 260px; }

.recipients-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fafafd;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
}

.checkbox-inline { display: flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.checkbox-inline input { width: auto; }

.recipients-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
}

.recipient-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.recipient-row:last-child { border-bottom: none; }
.recipient-row input { width: auto; }
.recipient-row .r-name { font-weight: 600; min-width: 140px; }
.recipient-row .r-email { color: var(--text-muted); flex: 1; }
.recipient-row .r-sent { font-size: 11px; color: var(--accent); white-space: nowrap; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 26, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 640px;
  max-width: 92vw;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(36, 26, 32, 0.25);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
}
.modal-body { padding: 16px 20px; overflow-y: auto; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-row:last-child { border-bottom: none; }
.history-row .h-subject { font-weight: 600; }
.history-row .h-date { color: var(--text-muted); font-size: 12px; }

.add-contact-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.add-contact-row input { flex: 1; }
.add-contact-row .btn { white-space: nowrap; }

.row-edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.row-actions .link-btn.muted { color: var(--text-muted); }
