/* ============ MailXGrow — professional UI ============ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #16202e;
  --text-muted: #667081;
  --accent: #10897A;
  --accent-dark: #0C6C60;
  --accent-soft: #E6F6F2;
  --brand-navy: #0C3A55;
  --brand-teal: #3BD9A4;
  --ok: #157f4a;
  --ok-soft: #e8f6ee;
  --warn: #9a6400;
  --warn-soft: #fdf3e2;
  --err: #c02626;
  --err-soft: #fdeded;
  --radius: 8px;
  /* Pin form controls to the light theme. Without this, a machine set to dark
     mode draws native <select> popups dark, and the options become unreadable
     against this light interface. */
  color-scheme: light;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden, [hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
a { color: var(--accent); }
code {
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.86em;
  font-family: "Cascadia Mono", Consolas, monospace;
}

/* ---------- brand ---------- */
.logo-mark { width: 32px; height: 32px; flex-shrink: 0; display: block; object-fit: contain; }
/* The supplied logo is a square lockup that already contains the wordmark,
   so the sign-in screen shows it large and on its own. */
.login-brand { justify-content: center; }
.login-brand .logo-mark { width: 132px; height: 132px; }
.logo-text {
  font-weight: 750; font-size: 0.98rem; letter-spacing: 0.08em;
  color: var(--brand-navy);
}
.logo-x { color: var(--accent); }

/* ---------- sign in ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.06);
  padding: 32px;
  width: min(380px, 92vw);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-card h1 { font-size: 1.3rem; font-weight: 620; }
.login-card > .muted { margin-bottom: 20px; font-size: 0.9rem; }
.login-foot { font-size: 0.82rem; }

/* auth tabs, google button */
.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  background: #f1f3f5; border-radius: 8px; padding: 3px;
}
.auth-tab {
  flex: 1; padding: 7px 10px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  font: inherit; font-size: 0.88rem; font-weight: 550; cursor: pointer;
}
.auth-tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: #fff; border: 1px solid var(--border-strong); color: var(--text);
  margin-bottom: 12px;
}
.btn-google:hover { background: #f7f8fa; }
.g-mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(#EA4335 0 25%, #FBBC05 0 50%, #34A853 0 75%, #4285F4 0);
  color: #fff; font-weight: 800; font-size: 0.72rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.or-line {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 0.8rem; margin: 4px 0 16px;
}
.or-line::before, .or-line::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: block; width: 100%;
  text-align: left;
  padding: 9px 12px;
  background: none; border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font: inherit; font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-btn:hover { background: #f2f4f7; color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; }

.content { flex: 1; padding: 28px 34px 64px; max-width: 1180px; }

.view-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.view-head h2 { font-size: 1.35rem; font-weight: 620; letter-spacing: -0.01em; }
.view-head .muted { font-size: 0.9rem; margin-top: 3px; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 0.98rem; font-weight: 620; }
.panel-body { padding: 18px; }
.panel-accent { border-color: var(--border-strong); }

.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.78rem; font-weight: 700;
}

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wizard { max-width: 780px; }

/* ---------- forms ---------- */
label { display: block; font-size: 0.86rem; font-weight: 550; color: var(--text); margin-bottom: 14px; }
.label-only { margin-bottom: 6px; }
input, textarea, select {
  display: block; width: 100%;
  margin-top: 5px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit; font-size: 0.92rem;
  font-weight: 400;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 92, 255, 0.13);
}
label .muted { display: block; margin-top: 4px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

.btn {
  display: inline-block;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit; font-size: 0.9rem; font-weight: 550;
  cursor: pointer;
  background: #eef0f3; color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #e5e8ec; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-quiet { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-quiet:hover { background: #f6f7f9; }
.btn-danger { background: #fff; border-color: var(--border-strong); color: var(--err); }
.btn-danger:hover { background: var(--err-soft); }
.btn-block { width: 100%; }
.btn-lg { padding: 11px 22px; font-size: 0.96rem; }
.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 8px; }

.alert {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 0.87rem;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error { background: var(--err-soft); border-color: #f5c6c6; color: var(--err); }
.alert-ok { background: var(--ok-soft); border-color: #bfe3ce; color: var(--ok); }

/* ---------- provider guide ---------- */
.guide {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 13px 15px;
  margin-bottom: 16px;
}
.guide-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.guide-head strong { font-size: 0.88rem; }
.guide-link { font-size: 0.82rem; }
.guide ol { margin: 0 0 8px 18px; }
.guide li { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 5px; }
.guide-limits { margin-top: 6px; }
.guide-warning {
  margin-top: 8px;
  background: var(--warn-soft);
  border: 1px solid #f0dcb4;
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.84rem;
  color: var(--warn);
}

/* ---------- rich text editor ---------- */
.editor-shell {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.editor-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 8px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.tool {
  min-width: 28px; height: 27px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font: inherit; font-size: 0.86rem;
  cursor: pointer;
}
.tool:hover { background: #eceff3; }
.tool.is-active { background: var(--accent-soft); border-color: #c9d5ff; color: var(--accent); }
.tool.chip { font-family: "Cascadia Mono", Consolas, monospace; font-size: 0.78rem; color: var(--text-muted); }
.tool.right { margin-left: auto; }
.tool-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }

.editor {
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 0.93rem;
  background: #fff;
}
.editor:focus { outline: none; }
.editor:empty::before {
  content: "Write your message here...";
  color: #9aa3b0;
}
.editor p { margin-bottom: 10px; }
.editor ul, .editor ol { margin: 0 0 10px 20px; }
.editor-source {
  border: none; border-radius: 0;
  min-height: 260px;
  margin-top: 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.85rem;
}
.editor-source:focus { box-shadow: none; }

/* ---------- dropzone & tables ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 6px;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-title { font-weight: 550; font-size: 0.92rem; margin-bottom: 4px; }

.inline-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.8rem; font-weight: 550;
  border: 1px solid transparent;
}
.tag-ok { background: var(--ok-soft); border-color: #c6e6d4; color: var(--ok); }
.tag-warn { background: var(--warn-soft); border-color: #f0dcb4; color: var(--warn); }

.table-wrap {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table th, .table td {
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.table th {
  position: sticky; top: 0;
  background: #f7f8fa;
  font-weight: 600; font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.table tr:last-child td { border-bottom: none; }

.preview-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 13px 15px;
  background: #fafbfc;
  font-size: 0.89rem;
  max-height: 220px; overflow-y: auto;
}
.preview-subject {
  font-weight: 600;
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------- pacing choices ---------- */
.choice {
  display: flex; gap: 11px; align-items: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 13px 15px;
  margin-bottom: 10px;
  cursor: pointer;
  font-weight: 400;
  transition: border-color 0.12s, background 0.12s;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input[type="radio"] { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
.choice-body { display: block; flex: 1; }
.choice-title { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
.choice-controls {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.87rem; color: var(--text-muted);
}
.choice:not(:has(input:checked)) .choice-controls { opacity: 0.45; pointer-events: none; }
.num { width: 72px; margin-top: 0; }
.unit { width: auto; margin-top: 0; }

/* ---------- scorecards & charts ---------- */
.scorecards {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.scorecard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
.scorecard-label {
  font-size: 0.74rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.scorecard-value { font-size: 1.6rem; font-weight: 680; line-height: 1.25; margin-top: 4px; }
.scorecard-sub { font-size: 0.79rem; color: var(--text-muted); }
.scorecard.accent .scorecard-value { color: var(--accent); }
.scorecard.good .scorecard-value { color: var(--ok); }
.scorecard.bad .scorecard-value { color: var(--err); }
.scorecard.warn .scorecard-value { color: var(--warn); }

.chart-grid {
  display: grid; gap: 18px; margin-bottom: 8px;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.chart-body { min-height: 170px; }
.chart-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar-col rect { transition: opacity 0.12s; }
.bar-col:hover rect { opacity: 0.75; }
.axis-label { font-size: 9px; fill: #8b94a3; }
.donut-value { font-size: 20px; font-weight: 700; fill: var(--text); }
.donut-label { font-size: 8.5px; fill: #8b94a3; letter-spacing: 0.05em; }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); }
.swatch { width: 10px; height: 10px; border-radius: 2px; }
.section-title { font-size: 1rem; font-weight: 620; margin: 22px 0 12px; }
.chart-empty { color: var(--text-muted); font-size: 0.87rem; text-align: center; padding: 40px 0; }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* ---------- contacts, lists, segmented control ---------- */
.segmented { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.segmented label {
  display: flex; align-items: center; gap: 7px;
  margin: 0; padding: 7px 13px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font-weight: 500; font-size: 0.89rem; cursor: pointer;
}
.segmented label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.segmented input { width: auto; margin: 0; accent-color: var(--accent); }

.divider { height: 1px; background: var(--border); margin: 18px 0; }
.grow { flex: 1; min-width: 130px; margin-top: 0; }
.table-wrap.tall { max-height: 420px; }
#contact-add-form { margin-bottom: 12px; }
#import-file { margin-bottom: 14px; }

.note-inline {
  background: var(--warn-soft); border: 1px solid #f0dcb4; color: var(--warn);
  border-radius: 6px; padding: 9px 12px; font-size: 0.84rem; margin-top: 4px;
}
.status-scheduled { background: var(--accent-soft); border-color: #b9e2d9; color: var(--accent-dark); }
.sched-line { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; }
.sched-time { font-weight: 600; color: var(--text); }

/* ---------- how many recipients ---------- */
.selection-box {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.selection-head { font-size: 0.88rem; font-weight: 600; margin-bottom: 10px; }
#pick-summary { margin-top: 2px; }
.selection-box.is-waiting .choice { opacity: 0.5; }

/* ---------- campaigns ---------- */
.campaign-list { display: flex; flex-direction: column; gap: 14px; }
.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.campaign-card.running { border-color: #b9c8ff; }
.campaign-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.campaign-title { font-weight: 620; font-size: 1rem; }
.campaign-meta { color: var(--text-muted); font-size: 0.83rem; margin-top: 3px; }

.status-badge {
  padding: 3px 10px; border-radius: 100px;
  font-size: 0.76rem; font-weight: 650;
  border: 1px solid transparent;
}
.status-running { background: var(--accent-soft); border-color: #c9d5ff; color: var(--accent); }
.status-completed { background: var(--ok-soft); border-color: #c6e6d4; color: var(--ok); }
.status-stopped { background: var(--warn-soft); border-color: #f0dcb4; color: var(--warn); }

.metrics { display: flex; gap: 28px; margin: 16px 0 12px; flex-wrap: wrap; }
.metric-value { font-size: 1.3rem; font-weight: 650; line-height: 1.2; }
.metric-label { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric.sent .metric-value { color: var(--ok); }
.metric.failed .metric-value { color: var(--err); }
.metric.waiting .metric-value { color: var(--warn); }

.bar { height: 6px; border-radius: 100px; background: #eceff3; overflow: hidden; display: flex; }
.bar-sent { background: var(--ok); transition: width 0.4s ease; }
.bar-failed { background: var(--err); transition: width 0.4s ease; }

.campaign-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.detail { margin-top: 14px; }
.detail summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); }
.detail .table-wrap { margin-top: 10px; max-height: 280px; }

.pill {
  display: inline-block;
  padding: 2px 9px; border-radius: 100px;
  font-size: 0.78rem; font-weight: 550;
  border: 1px solid transparent;
}
.pill-pending { background: #f2f4f7; border-color: var(--border); color: var(--text-muted); }
.pill-sending { background: var(--accent-soft); border-color: #c9d5ff; color: var(--accent); }
.pill-sent { background: var(--ok-soft); border-color: #c6e6d4; color: var(--ok); }
.pill-failed { background: var(--err-soft); border-color: #f5c6c6; color: var(--err); }
.err-text { color: var(--err); font-size: 0.8rem; }
.pad { padding: 12px 14px; }

/* ---------- list items ---------- */
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.item-title { font-weight: 600; font-size: 0.93rem; }
.item-sub { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- misc ---------- */
.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
}
.empty-title { font-weight: 600; margin-bottom: 4px; }

.checklist { margin-left: 18px; }
.checklist li { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 8px; }

/* ---------- contact history dialog ---------- */
.modal {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(16, 24, 40, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.24);
  width: min(760px, 100%);
  max-height: 86vh;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.05rem; font-weight: 650; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.mini-stats { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 16px; }
.mini-stat-value { font-size: 1.25rem; font-weight: 650; }
.mini-stat-label {
  font-size: 0.73rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.mini-stat.sent .mini-stat-value { color: var(--ok); }
.mini-stat.failed .mini-stat-value { color: var(--err); }
.contact-lists { margin-bottom: 16px; font-size: 0.86rem; color: var(--text-muted); }
.row-link { cursor: pointer; }
.row-link:hover { background: #fafbfc; }
.when { white-space: nowrap; }
.when-time { color: var(--text-muted); font-size: 0.8rem; }

.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: #1d2733; color: #fff;
  border-radius: 7px;
  padding: 10px 18px;
  font-size: 0.89rem;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.22);
  z-index: 100;
  max-width: min(560px, 92vw);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .brand { padding: 0 14px 0 4px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-left: auto; }
  .sidebar-foot .btn { width: auto; }
  .content { padding: 20px 16px 48px; }
}

/* Native dropdown options: force readable colours regardless of OS theme. */
select option,
select optgroup {
  background-color: #ffffff;
  color: #16202e;
}
