/* LB Mailer — Design System v1.0
   Brand: Lalit Bahel | Dark theme | Orange accent */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: inherit; }

/* ---- Design Tokens ---- */
:root {
  --og:     #ff4d00;
  --og-h:   #e64400;
  --og-dim: rgba(255, 77, 0, 0.12);

  --bg:    #030506;
  --bg2:   #0b0e10;
  --card:  #0d1114;
  --bdr:   rgba(255, 255, 255, 0.08);
  --bdr2:  rgba(255, 255, 255, 0.04);

  --text:  #e8e8e6;
  --text2: #a8a8a8;
  --text3: #6b7280;

  --success: #22c55e;
  --warning: #f59e0b;
  --error:   #ef4444;
  --info:    #3b82f6;

  --font-s: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-d: 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --font-m: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;
  --r-full: 9999px;

  --shadow-sm:   0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, .4);
  --shadow-card: 0 0 0 1px var(--bdr), 0 4px 24px rgba(0, 0, 0, .2);

  --sidebar-w: 240px;
  --topbar-h:  60px;
}

/* ---- Base ---- */
body {
  font-family: var(--font-s);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .2s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--bdr);
  flex-shrink: 0;
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--og);
  color: #fff;
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: .5px;
}
.logo-text {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  letter-spacing: .3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color .12s, background .12s;
  border-left: 3px solid transparent;
  margin-left: -3px;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
}
.nav-item.active {
  color: var(--og);
  border-left-color: var(--og);
  background: var(--og-dim);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.smtp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--success); box-shadow: 0 0 6px rgba(34, 197, 94, .5); }
.status-dot.disconnected { background: var(--error); }
.logout-link {
  font-size: 13px;
  color: var(--text3);
  text-decoration: none;
  transition: color .12s;
}
.logout-link:hover { color: var(--text2); }

/* ---- Main area ---- */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--bdr);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 4px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text2);
  border-radius: 2px;
  transition: .2s;
}
.topbar-title {
  font-family: var(--font-d);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.global-search {
  position: relative;
  width: min(340px, 34vw);
  flex: 0 1 340px;
}
.global-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--bdr);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.global-search input:focus {
  border-color: rgba(255,77,0,.5);
  box-shadow: 0 0 0 3px rgba(255,77,0,.14);
}
.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, 88vw);
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--bdr);
  border-radius: var(--r-md);
  background: #0b0f12;
  box-shadow: 0 18px 70px rgba(0,0,0,.44);
  padding: 6px;
  z-index: 120;
}
.global-search-results.hidden { display: none; }
.global-result {
  display: block;
  padding: 10px 11px;
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
}
.global-result:hover,
.global-result.active {
  background: rgba(255,77,0,.12);
}
.global-result strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}
.global-result span {
  display: block;
  margin-top: 3px;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.35;
}
.global-empty {
  padding: 12px;
  color: var(--text3);
  font-size: 13px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.content {
  flex: 1;
  padding: 28px 24px;
  overflow-y: auto;
}

/* ---- Page headings ---- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.page-title {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}
.page-sub {
  margin-top: 5px;
  color: var(--text2);
  font-size: 14px;
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bdr);
}
.card-header h2 {
  font-family: var(--font-s);
  font-size: 14px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: 0;
}
.card-body { padding: 20px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-sm);
  min-height: 40px;
  padding: 0 18px;
  cursor: pointer;
  font-family: var(--font-s);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background .12s, opacity .12s, transform .1s;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:focus-visible {
  outline: 2px solid var(--og);
  outline-offset: 2px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-sm   { min-height: 32px; height: 32px; padding: 0 12px; font-size: 13px; }
.btn-md   { min-height: 40px; height: 40px; padding: 0 18px; font-size: 14px; }
.btn-lg   { min-height: 48px; height: 48px; padding: 0 24px; font-size: 15px; }
.btn-full { width: 100%; }

.btn-primary   { background: var(--og); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--og-h); }

.btn-secondary {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--bdr);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }

.btn-ghost     { background: transparent; color: var(--text2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .05); }

.btn-danger    { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.text-danger { color: var(--error) !important; }

/* ---- Forms ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}

.form-control {
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--bdr);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-s);
  font-size: 14px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input {
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--bdr);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-s);
  font-size: 14px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus {
  border-color: var(--og);
  box-shadow: 0 0 0 3px rgba(255, 77, 0, .15);
  background: rgba(0, 0, 0, .36);
}
.input::placeholder { color: var(--text3); }
select.input,
select.form-control {
  cursor: pointer;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text2) 50%),
    linear-gradient(135deg, var(--text2) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
select.input:focus,
select.form-control:focus {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--og) 50%),
    linear-gradient(135deg, var(--og) 50%, transparent 50%);
}
textarea.input { resize: vertical; }
.form-control:focus {
  border-color: var(--og);
  box-shadow: 0 0 0 3px rgba(255, 77, 0, .15);
}
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; }
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--og);
  cursor: pointer;
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--og);
  outline-offset: 2px;
}
select.form-control[multiple] {
  min-height: 150px;
  padding: 8px;
  line-height: 1.45;
  overflow: auto;
  appearance: auto;
  -webkit-appearance: auto;
  background-image: none;
  padding-right: 8px;
}
select.form-control[multiple] option {
  padding: 7px 9px;
  border-radius: 6px;
  margin-bottom: 2px;
  color: var(--text);
  background: transparent;
}
select.form-control[multiple] option:checked {
  background: linear-gradient(90deg, rgba(255,77,0,.28), rgba(255,77,0,.14));
  color: #fff;
}

.code-editor {
  font-family: var(--font-m);
  font-size: 13px;
  line-height: 1.7;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Stats ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}
.stat-value {
  font-family: var(--font-d);
  font-size: 38px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}
.stat-badge .stat-value { font-size: 18px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.badge-sent      { background: rgba(34, 197, 94, .15); color: #22c55e; }
.badge-draft     { background: rgba(107, 114, 128, .15); color: #9ca3af; }
.badge-scheduled { background: rgba(245, 158, 11, .15); color: #f59e0b; }
.badge-sending   { background: rgba(59, 130, 246, .15); color: #3b82f6; }
.badge-failed    { background: rgba(239, 68, 68, .15); color: #ef4444; }
.badge-queued    { background: rgba(107, 114, 128, .15); color: #9ca3af; }

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--bdr);
}
.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--bdr2);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.table-link { text-decoration: none; font-weight: 600; color: var(--text); }
.table-link:hover { color: var(--og); }
.actions-cell { display: flex; gap: 4px; align-items: center; }

/* ---- List polish, pagination, drawers ---- */
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--bdr2);
  color: var(--text3);
  font-size: 12px;
}
.list-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
}
.list-page-info { color: var(--text3); }
.list-per-page-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text3);
  font-size: 12px;
  font-weight: 650;
}
.list-per-page-select {
  height: 30px;
  border: 1px solid var(--bdr);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.045);
  color: var(--text);
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
}
.list-per-page-select:focus {
  border-color: rgba(255,77,0,.45);
  box-shadow: 0 0 0 3px rgba(255,77,0,.12);
}
.click-row, .click-card { cursor: pointer; }
.click-row:focus-visible, .click-card:focus-visible {
  outline: 2px solid var(--og);
  outline-offset: -2px;
}
.drag-card { cursor: grab; }
.drag-card:active { cursor: grabbing; }
.drag-card.dragging {
  opacity: .55;
  transform: rotate(.3deg) scale(.99);
}
.drop-active {
  border-color: rgba(255, 77, 0, .42) !important;
  background: rgba(255, 77, 0, .055) !important;
}
.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--bdr);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.035);
}
.view-switch button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: calc(var(--r-sm) - 2px);
  background: transparent;
  color: var(--text2);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.view-switch button.active {
  background: rgba(255, 77, 0, .16);
  color: var(--text);
}
.record-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  justify-content: flex-end;
  background: rgba(0,0,0,.45);
}
.record-drawer-backdrop.hidden { display: none; }
.record-drawer {
  width: min(440px, 100%);
  height: 100%;
  overflow: auto;
  background: #0b0f12;
  border-left: 1px solid var(--bdr);
  box-shadow: -24px 0 80px rgba(0,0,0,.36);
  padding: 18px;
}
.record-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bdr);
}
.record-drawer-head h2 {
  font-size: 20px;
  line-height: 1.2;
  color: var(--text);
  text-wrap: balance;
}
.record-drawer-head p {
  margin-top: 4px;
  color: var(--text3);
  font-size: 13px;
}
.record-drawer-badges,
.record-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.record-drawer-body {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.record-field {
  padding: 12px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.026);
}
.record-field span {
  display: block;
  color: var(--text3);
  font-size: 11px;
  font-weight: 750;
  margin-bottom: 5px;
}
.record-field strong,
.record-field a {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.record-field a { color: #fdba74; }
.record-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.055);
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}

/* ---- Dashboard grid ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
}
.alert-error   { background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .25); color: #fca5a5; }
.alert-success { background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .25); color: #86efac; }
.alert-warning { background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .25); color: #fcd34d; }
.alert-info    { background: rgba(59, 130, 246, .1); border: 1px solid rgba(59, 130, 246, .25); color: #93c5fd; }

/* ---- Login page ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 77, 0, .06) 0%, transparent 70%), var(--bg);
}
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }
.login-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.login-brand .logo-mark { width: 40px; height: 40px; font-size: 15px; }
.login-brand .logo-text { font-size: 24px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form button { margin-top: 8px; }

/* ---- Empty states ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 24px;
  text-align: center;
}
.empty-icon { width: 48px; height: 48px; color: var(--text3); }
.empty-state p { color: var(--text2); font-size: 15px; }

/* ---- Template editor ---- */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 56px - 28px);
}
.editor-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}

.variable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}
.chip {
  background: var(--og-dim);
  color: var(--og);
  border: 1px solid rgba(255, 77, 0, .25);
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-family: var(--font-m);
  cursor: pointer;
  transition: background .12s;
  line-height: 1.6;
}
.chip:hover { background: rgba(255, 77, 0, .22); }

.editor-preview-wrap {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--bdr);
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.preview-frame {
  flex: 1;
  border: none;
  background: #f5f3ef;
  display: block;
  width: 100%;
}

/* ---- Settings ---- */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 980px;
}
.token-display { display: flex; gap: 8px; }
.token-display .form-control { font-family: var(--font-m); font-size: 12px; }

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-backdrop.hidden { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-lg);
  padding: 0;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-md);
  animation: modal-in .16s ease-out;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.012));
}
.modal-head p { margin: 4px 0 0; color: var(--text2); font-size: 13px; line-height: 1.5; }
.icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.04);
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
}
.icon-btn:hover {
  background: rgba(255,77,0,.12);
  border-color: rgba(255,77,0,.28);
  color: var(--text);
}
.modal h3 {
  font-family: var(--font-s);
  font-size: 17px;
  font-weight: 750;
  margin: 0 0 4px;
  color: var(--text);
}
.modal > h3,
.modal > p,
.modal > .form-group,
.modal > label,
.modal > input,
.modal > select,
.modal > textarea {
  margin-left: 24px;
  margin-right: 24px;
}
.modal > input,
.modal > select,
.modal > textarea {
  display: block;
  width: calc(100% - 48px);
}
.modal > h3:first-child { margin-top: 24px; }
.modal > p { color: var(--text2); font-size: 13px; line-height: 1.55; }
.modal > label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 650;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.modal-actions .btn { height: 38px; padding: 0 14px; }
.modal-confirm { max-width: 440px; }
.modal-confirm-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.012));
  border-bottom: 1px solid var(--bdr);
}
.modal-confirm-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(255,77,0,.12);
  border: 1px solid rgba(255,77,0,.28);
  color: var(--og);
}
.modal-confirm-icon.danger {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.25);
  color: #fca5a5;
}
.modal-confirm-icon svg { width: 20px; height: 20px; }
.modal-confirm-message { margin: 0; color: var(--text2); font-size: 14px; line-height: 1.6; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Toast notifications ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  min-width: 240px;
  max-width: 360px;
  pointer-events: all;
  animation: toast-in .2s ease-out;
}
.toast::before {
  content: '';
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}
.toast.success::before { background: var(--success); }
.toast.error::before   { background: var(--error); }
.toast.warning::before { background: var(--warning); }
.toast.info::before    { background: var(--info); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Helpers ---- */
.text-muted { color: var(--text2); }
.small { font-size: 0.82rem; }
.mono  { font-family: var(--font-m); font-size: 0.85rem; }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 12px; }
.sr-only    { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
code {
  font-family: var(--font-m);
  font-size: .875em;
  background: rgba(255, 255, 255, .06);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0ms !important;
    transition-duration: 0ms !important;
  }
}

/* ---- Responsive: tablet (icon sidebar) ---- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 64px; }

  .sidebar-logo { justify-content: center; padding: 16px 0; }
  .sidebar-logo .logo-text { display: none; }

  .nav-item {
    justify-content: center;
    padding: 12px 0;
    border-left: none;
    border-bottom: 3px solid transparent;
    margin-left: 0;
    margin-bottom: -3px;
    border-radius: 0;
  }
  .nav-item span { display: none; }
  .nav-item.active { border-left: none; border-bottom-color: var(--og); background: var(--og-dim); }
  .nav-item svg { width: 20px; height: 20px; }

  .sidebar-footer { align-items: center; padding: 12px 0; }
  .smtp-status span, .logout-link { display: none; }
}

/* ---- Responsive: mobile ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .global-search { order: 3; width: 100%; flex: 1 0 100%; }

  .nav-item { justify-content: flex-start; padding: 9px 10px; border-radius: var(--r-sm); border-bottom: none; border-left: 3px solid transparent; margin-left: -3px; margin-bottom: 0; }
  .nav-item span { display: block; }
  .nav-item.active { border-bottom-color: transparent; border-left-color: var(--og); }
  .sidebar-logo .logo-text { display: block; }
  .smtp-status span, .logout-link { display: block; }

  .content { padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .preview-frame { height: 280px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .wizard-tabs { flex-wrap: wrap; }
  .card-grid { grid-template-columns: 1fr; }
  .page-header { align-items: stretch; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .modal-backdrop,
  .modal-overlay { align-items: flex-end; padding: 14px; }
  .modal { max-width: 100%; }
  .modal-actions { flex-direction: column-reverse; padding: 14px 18px 18px; }
  .modal-actions .btn { width: 100%; }
}

/* ============================================================
   Phase 2 — Contacts & Campaigns
   ============================================================ */

/* Filter bar */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-search { flex: 1 1 200px; }
.filter-select { flex: 0 1 180px; }
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text2); cursor: pointer; white-space: nowrap; }
.filter-check input { accent-color: var(--og); }

/* Bulk action bar */
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--bg2); border: 1px solid var(--bdr); border-radius: var(--r-sm); margin-bottom: 12px; flex-wrap: wrap; }
.bulk-bar span { font-size: 0.85rem; color: var(--text2); margin-right: auto; }

/* Table enhancements */
.table .row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.table .empty-row { text-align: center; padding: 32px; color: var(--text2); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text2); font-size: 1rem; padding: 4px 6px; border-radius: var(--r-sm); transition: color 0.15s, background 0.15s; line-height: 1; }
.btn-icon:hover { color: var(--text); background: var(--bg2); }
.btn-icon.danger:hover { color: #ef4444; }

/* Status badges */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; }
.badge-green  { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-red    { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-blue   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-yellow { background: rgba(234,179,8,.15);   color: #facc15; }
.badge-gray   { background: rgba(148,163,184,.15); color: #94a3b8; }

/* Card grid (lists page) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.list-card { display: flex; flex-direction: column; gap: 12px; }
.list-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.list-name { font-size: 1rem; font-weight: 600; margin: 0; }
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-actions { display: flex; gap: 4px; flex-shrink: 0; }
.stat-chip { background: var(--bg2); border: 1px solid var(--bdr); border-radius: 999px; padding: 2px 10px; font-size: 0.78rem; color: var(--text2); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-state .btn { margin-top: 16px; }

/* Pagination */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--bdr); color: var(--text2); font-size: 0.85rem; text-decoration: none; transition: background 0.15s, color 0.15s; }
.page-btn:hover { background: var(--bg2); color: var(--text); }
.page-btn.active { background: var(--og); color: #fff; border-color: var(--og); }

/* Wizard */
.wizard-tabs { display: flex; gap: 0; margin-bottom: 24px; border: 1px solid var(--bdr); border-radius: var(--r-md); overflow: hidden; }
.wizard-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; background: var(--card); border: none; color: var(--text2); font-size: 0.9rem; cursor: pointer; transition: background 0.15s, color 0.15s; }
.wizard-tab:not(:last-child) { border-right: 1px solid var(--bdr); }
.wizard-tab.active { background: var(--og-dim); color: var(--og); font-weight: 600; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bdr); color: var(--text2); font-size: 0.75rem; font-weight: 700; }
.wizard-tab.active .step-num { background: var(--og); color: #fff; }

.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-card { max-width: 560px; }
.wizard-card label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 4px; margin-top: 12px; }
.wizard-card label:first-of-type { margin-top: 0; }
.wizard-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }
.schedule-row { flex-wrap: wrap; }

/* Review grid */
.review-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.review-row { display: flex; align-items: baseline; gap: 12px; font-size: 0.9rem; }
.review-row span { color: var(--text2); width: 90px; flex-shrink: 0; }
.review-row strong { color: var(--text); }

/* Small button size: kept for old pages, base dimensions defined above. */
.btn-sm { padding: 0 12px; font-size: 13px; }
