/* ─── Variables ───────────────────────────────────────────────────────────── */
:root {
  --blue:       #1a3a5c;
  --blue-light: #2a7de1;
  --blue-pale:  #e8f0fb;
  --green:      #16a34a;
  --red:        #dc2626;
  --orange:     #d97706;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --nav-h:      60px;
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.6;
}
a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }
pre { white-space: pre-wrap; word-break: break-word; }

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 2rem;
  height: var(--nav-h);
  background: var(--blue);
  padding: 0 2rem;
  box-shadow: var(--shadow-md);
}
.nav-brand {
  display: flex; align-items: center; gap: .5rem;
  color: #fff;
  font-size: 16px;
  white-space: nowrap;
}
.brand-icon { font-size: 20px; }
.brand-name strong { font-weight: 700; }
.nav-links {
  display: flex; gap: .5rem;
  list-style: none;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,.75);
  padding: .4rem .85rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}
.nav-user { margin-left: auto; }
.btn-logout {
  color: rgba(255,255,255,.7);
  font-size: 13px;
  padding: .35rem .8rem;
  border-radius: var(--radius);
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }

/* ─── Main ────────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.full-width { max-width: 100%; }

/* ─── Flash ───────────────────────────────────────────────────────────────── */
.flash-container { margin-bottom: 1.5rem; }
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: 13px;
  font-weight: 500;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef9c3; color: #713f12; border: 1px solid #fef08a; }
.flash-info    { background: var(--blue-pale); color: var(--blue); border: 1px solid #bcd6f5; }

/* ─── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px; font-weight: 700; color: var(--blue);
}
.header-actions {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}
.back-link {
  font-size: 12px; color: var(--gray-400);
  display: block; margin-bottom: .25rem;
}
.back-link:hover { color: var(--blue-light); }
.subtitle { color: var(--gray-600); font-size: 13px; margin-top: .25rem; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.card-header h2 { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.card-link { font-size: 12px; color: var(--blue-light); }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}

/* ─── Grid layouts ────────────────────────────────────────────────────────── */
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 700px) {
  .two-cols { grid-template-columns: 1fr; }
}

/* ─── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 3px solid var(--gray-200);
}
.stat-card.stat-highlight { border-top-color: var(--blue-light); }
.stat-card.stat-warn      { border-top-color: var(--orange); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--blue); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-600); margin-top: .35rem; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.93); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--blue-light); color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-danger    { background: #fee2e2; color: var(--red); }
.btn-sm { padding: .3rem .65rem; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-new      { background: #dbeafe; color: #1d4ed8; }
.badge-used     { background: #dcfce7; color: #166534; }
.badge-ignored  { background: var(--gray-100); color: var(--gray-400); }
.badge-review   { background: #fef9c3; color: #713f12; }
.badge-sent     { background: #dcfce7; color: #166534; }
.badge-draft    { background: #fef9c3; color: #713f12; }
.badge-neutral  { background: var(--gray-200); color: var(--gray-600); }
.badge-cat      { background: var(--blue-pale); color: var(--blue); }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue-pale); color: var(--blue);
  border-radius: 20px; font-size: 13px; font-weight: 600;
  padding: .1rem .5rem; margin-left: .5rem;
}
.source-tag { font-size: 11px; color: var(--gray-400); }
.source-tag.source-tag   { color: var(--green); font-weight:600; }
.source-tag.source-keyword { color: var(--blue-light); }

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: .6rem 1rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.table-hover tbody tr:hover { background: var(--gray-50); }
.nowrap { white-space: nowrap; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: .35rem; }
input[type="text"], input[type="password"], input[type="email"],
textarea, select {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(42,125,225,.12);
}
.input-full { width: 100%; }
.input-row { display: flex; gap: .5rem; align-items: center; }
.filter-bar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.action-form { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--gray-100); }
.action-form:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-100);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 20px; color: var(--blue); margin-top: .5rem; }
.login-subtitle { color: var(--gray-400); font-size: 13px; margin-top: .25rem; }
.login-form .form-group { margin-bottom: 1.25rem; }
.login-form input { width: 100%; padding: .65rem .9rem; }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2.5rem; color: var(--gray-400); font-size: 13px; }
.empty-state p { margin-bottom: .75rem; }
.meta-list > div { padding: .45rem 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.meta-list > div:last-child { border-bottom: none; }
.meta-list strong { display: inline-block; min-width: 120px; color: var(--gray-600); }
.text-muted { color: var(--gray-400); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 1rem; }
.newsletter-title { font-weight: 600; font-size: 14px; margin-bottom: .5rem; }
.newsletter-meta { font-size: 12px; color: var(--gray-600); margin-bottom: .75rem; }
.card-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.category-bar { display: flex; align-items: center; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--gray-100); }
.cat-label { font-size: 13px; }
.recipients-list { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ─── Email body ──────────────────────────────────────────────────────────── */
.email-body {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1rem;
  max-height: 600px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
}
.email-text { font-family: 'Courier New', monospace; font-size: 12px; }
.email-html img { max-width: 100%; }

/* ─── Preview ─────────────────────────────────────────────────────────────── */
.preview-container {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.preview-toolbar {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.preview-label { font-size: 12px; color: var(--gray-600); margin-right: .5rem; }
.device-btn.active { background: var(--blue); color: #fff; }
.preview-frame-wrapper { display: flex; justify-content: center; background: #e5e7eb; padding: 1.5rem; min-height: 600px; }
.preview-iframe { border: none; background: #fff; box-shadow: var(--shadow-md); }
.preview-iframe.desktop { width: 100%; max-width: 640px; height: 800px; }
.preview-iframe.mobile  { width: 380px; height: 700px; border-radius: 12px; }

/* ─── Email edit items ────────────────────────────────────────────────────── */
.email-edit-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
  transition: opacity .2s;
}
.email-edit-item.email-ignored { opacity: .45; }
.email-edit-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.email-edit-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.summary-form .input-row input { flex: 1; }

/* ─── Send page ───────────────────────────────────────────────────────────── */
.send-card { max-width: 600px; margin: 0 auto; }
.send-confirm-box { text-align: center; padding: 1.5rem; margin-bottom: 1.5rem; }
.send-icon { font-size: 3rem; margin-bottom: .75rem; }
.send-confirm-box p { font-size: 15px; color: var(--gray-800); margin-bottom: .35rem; }
.send-footer { justify-content: flex-end; }
.btn-send { padding: .6rem 1.5rem; font-size: 14px; }
