/* OutlookSender - Instantly-style admin UI. Plain CSS, no build step. */

:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --indigo-soft: #eef2ff;
  --sidebar: #0b1220;
  --sidebar-hover: #1a2438;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --slate: #475569;
  --slate-soft: #f1f5f9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand .brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--indigo), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand .brand-mark svg { width: 18px; height: 18px; }

.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active { background: var(--indigo); color: #fff; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  color: #e2e8f0;
  font-weight: 500;
}
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #334155; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.logout-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: #94a3b8; font-weight: 500; text-decoration: none;
}
.logout-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.logout-link svg { width: 18px; height: 18px; }

.main { margin-left: 240px; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.account-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-soft); color: #166534;
  border: 1px solid #bbf7d0;
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.account-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.account-pill.none { background: var(--red-soft); color: #991b1b; border-color: #fecaca; }
.account-pill.none .dot { background: var(--red); }

.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #f0f1f4;
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header .card-title { margin: 0; }
.card-header .card-sub { margin: 4px 0 0; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #f0f1f4;
  padding: 16px 18px;
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-value.indigo { color: var(--indigo); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--slate-soft); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; color: var(--indigo); padding: 6px 10px; }
.btn-ghost:hover { background: var(--indigo-soft); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge-active, .badge-sent, .badge-running, .badge-connected, .badge-replied { background: var(--green-soft); color: #166534; }
.badge-paused, .badge-draft, .badge-pending, .badge-warmup { background: var(--amber-soft); color: #92400e; }
.badge-completed { background: var(--blue-soft); color: #1e40af; }
.badge-error, .badge-bounced, .badge-failed, .badge-expired { background: var(--red-soft); color: #991b1b; }
.badge-neutral, .badge-idle, .badge-uploaded { background: var(--slate-soft); color: var(--slate); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-input, .form-select, textarea.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form-input:focus, .form-select:focus, textarea.form-input:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
textarea.form-input { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.checkbox-item { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 14px; }
.checkbox-item input { width: 16px; height: 16px; accent-color: var(--indigo); }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.inline-form .form-input { width: auto; padding: 6px 10px; font-size: 13px; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px; transition: 0.15s;
}
.slider:before {
  position: absolute; content: "";
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .slider { background: var(--indigo); }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* progress bars */
.progress { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; min-width: 100px; }
.progress-bar { height: 100%; background: var(--indigo); border-radius: 999px; transition: width 0.3s; }
.progress-bar.hot { background: var(--red); }
.usage-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f2f4; }
.usage-row:last-child { border-bottom: none; }
.usage-email { font-weight: 600; min-width: 220px; }
.usage-bar { flex: 1; }
.usage-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert a { font-weight: 700; color: inherit; text-decoration: underline; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; opacity: 0.35; margin-bottom: 10px; }
.empty-state p { margin: 6px 0 16px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e1b4b 0%, var(--sidebar) 55%, #060b16 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 20px; font-weight: 800; }
.login-brand .brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo), #7c3aed);
  display: flex; align-items: center; justify-content: center;
}
.login-brand .brand-mark svg { width: 20px; height: 20px; }
.login-card h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card .btn-primary { width: 100%; padding: 11px; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 460px;
  padding: 32px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.modal h3 { margin: 0 0 8px; font-size: 19px; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.user-code {
  font-size: 40px; font-weight: 800; letter-spacing: 0.18em;
  background: var(--slate-soft); border: 2px dashed var(--border);
  border-radius: 12px; padding: 14px 10px 14px 24px; margin: 0 0 16px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.device-link { font-weight: 700; font-size: 16px; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--indigo-soft);
  border-top-color: var(--indigo); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -4px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.poll-status { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- Campaign detail ---------- */
.campaign-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.campaign-head h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.01em; }
.campaign-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.step-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 12px;
  display: flex; gap: 16px; align-items: flex-start;
  background: #fff;
}
.step-num {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.step-body { flex: 1; min-width: 0; }
.step-subject { font-weight: 700; margin-bottom: 4px; }
.step-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.step-preview { font-size: 13px; color: var(--slate); white-space: pre-wrap; }

/* ---------- Unibox ---------- */
.unibox-grid { display: grid; grid-template-columns: 380px 1fr; gap: 0; min-height: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.unibox-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 72vh; }
.unibox-item {
  display: block; padding: 14px 16px;
  border-bottom: 1px solid #f1f2f4;
  color: var(--text); text-decoration: none;
}
.unibox-item:hover { background: #fafbff; text-decoration: none; }
.unibox-item.selected { background: var(--indigo-soft); border-left: 3px solid var(--indigo); padding-left: 13px; }
.unibox-item .from { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.unibox-item .time { font-weight: 400; color: var(--muted); font-size: 12px; white-space: nowrap; }
.unibox-item .subject { font-weight: 600; font-size: 13px; margin: 3px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unibox-item .preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unibox-item .tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.account-tag { background: var(--slate-soft); color: var(--slate); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.unibox-reading { padding: 24px; overflow-y: auto; max-height: 72vh; }
.unibox-reading .msg-subject { font-size: 19px; font-weight: 700; margin: 0 0 8px; }
.unibox-reading .msg-meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.unibox-reading .msg-body { white-space: pre-wrap; margin-bottom: 24px; }
.reply-box { border-top: 1px solid var(--border); padding-top: 18px; }
.reply-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Misc ---------- */
.page-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-input { max-width: 280px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.funnel-table td .bar-cell { display: flex; align-items: center; gap: 10px; }

@media (max-width: 960px) {
  .sidebar { width: 72px; }
  .sidebar .brand span, .nav-item span, .nav-label, .sidebar-user span, .logout-link span { display: none; }
  .nav-item, .logout-link { justify-content: center; }
  .main { margin-left: 72px; }
  .unibox-grid { grid-template-columns: 1fr; }
  .unibox-list { max-height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
