:root {
  --bg: #0a1628;
  --panel: #13233b;
  --panel-alt: #0e1d33;
  --border: #24405c;
  --border-soft: #1b3049;
  --text: #e0e0e0;
  --text-dim: #8a94a6;
  --text-dimmer: #64707f;
  --label: #9aa3b5;
  --accent: #3b82f6;
  --accent-dark: #142a4d;
  --warn: #e67e22;
  --caution: #f39c12;
  --safe: #27ae60;
  --link: #378ADD;
  --link-text: #85B7EB;
  font-family: 'DM Sans', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title .mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.app-title h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-title .sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.partner-logo-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 6px;
}

.partner-logo {
  height: 34px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.env-badge {
  font-size: 11px;
  color: var(--caution);
  border: 1px solid #3a2a10;
  background: #1a1408;
  padding: 5px 10px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

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

.section-label {
  font-size: 11px;
  color: #7e8898;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* Templates tab layout */
.templates-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 20px;
  align-items: start;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}

.template-card:hover { border-color: #3a3a3a; }

.template-card.selected {
  border-color: var(--accent);
  background: var(--accent-dark);
}

.template-card .icon { font-size: 18px; margin-bottom: 6px; }
.template-card .name { font-size: 13px; font-weight: 600; }

.editor-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}

label.field-label {
  font-size: 12px;
  color: var(--label);
  display: block;
  margin-bottom: 6px;
}

.input, textarea.input, select.input {
  width: 100%;
  padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  box-sizing: border-box;
}

textarea.input {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 220px;
  resize: vertical;
}

.field-row { margin-bottom: 14px; }
.field-row.split { display: flex; gap: 12px; }
.field-row.split > div { flex: 1; }

.ai-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}

.btn-accent { background: var(--accent); }
.btn-accent:disabled { background: #333; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.hint { font-size: 11px; color: var(--text-dimmer); margin-top: 8px; }

/* Attachment chip in preview */
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  background: #f3f4f6;
  border: 1px solid #e2e4e8;
  border-radius: 8px;
  max-width: 320px;
}

.attachment-chip .file-icon { font-size: 22px; line-height: 1; }
.attachment-chip .file-meta { display: flex; flex-direction: column; }
.attachment-chip .file-name { font-size: 12.5px; color: #222; font-weight: 500; }
.attachment-chip .file-size { font-size: 11px; color: #888; margin-top: 2px; }

/* Custom template badge + delete control */
.template-card {
  position: relative;
}

.template-card .custom-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #85B7EB;
  background: #101a2e;
  border: 1px solid #1d3a5f;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.template-card .delete-x {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #7e8898;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}

.template-card .delete-x:hover { color: #e0e0e0; background: #2a1210; }

.template-card .rename-x {
  position: absolute;
  top: 8px;
  right: 30px;
  background: transparent;
  border: none;
  color: #7e8898;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}

.template-card .rename-x:hover { color: #85B7EB; background: #101a2e; }

/* Preview email chrome */
.preview-window {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.preview-topbar {
  background: var(--panel-alt);
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.preview-body {
  background: #101010;
  padding: 20px;
  font-size: 13px;
  line-height: 1.65;
  color: #ccc;
  white-space: pre-wrap;
  font-family: 'DM Sans', sans-serif;
}

.preview-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

/* Campaign tab */
.campaign-form { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }

.dropzone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #7e8898;
  font-size: 13px;
  cursor: pointer;
}

.dropzone .icon { font-size: 24px; margin-bottom: 6px; }
.dropzone .hint { margin-top: 6px; }

.timing-row { display: flex; gap: 8px; }

.timing-btn {
  flex: 1;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  text-transform: capitalize;
}

.timing-btn.selected {
  background: var(--accent-dark);
  border-color: var(--accent);
  color: var(--text);
}

.sender-box {
  background: var(--panel-alt);
  border: 1px solid #222;
  border-radius: 8px;
  padding: 14px;
}

.sender-options { display: flex; gap: 8px; margin-bottom: 10px; }

.sender-btn {
  flex: 1;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #7e8898;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.sender-btn.selected {
  background: #1a1a2e;
  border-color: var(--link);
  color: var(--link-text);
}

.launch-btn {
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
}

/* Analytics tab */
.launch-banner {
  background: #0d1f0d;
  border: 1px solid #1a3d1a;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #4caf50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-row { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  flex: 1;
  min-width: 130px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  line-height: 1;
}

.stat-card .pct { font-size: 12px; color: #7e8898; margin-top: 4px; }

.risk-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}

.risk-legend { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }

.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

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

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 20px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  text-transform: capitalize;
}

.pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.report-table thead tr { border-bottom: 1px solid #222; }

.report-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  color: #7e8898;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.report-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
.report-table td.name { color: #ccc; font-weight: 500; }
.report-table td.dept { color: #8a94a6; }

.reported-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--safe);
  cursor: pointer;
}

@media (max-width: 720px) {
  .templates-layout { grid-template-columns: 1fr; }
  .stat-row { flex-direction: column; }
}

/* Landing page preview modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.visible { display: flex; }

.modal-window {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.modal-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}

.modal-hint code {
  font-family: 'DM Mono', monospace;
  color: #85B7EB;
}

.modal-iframe {
  width: 100%;
  flex: 1;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}