/* AfricanIntellect CMS — internal admin tool, on the org palette:
   cream page, white cards, gold primary, terracotta danger, green success. */

:root {
  --cream: #faf4ea;
  --ink: #241c14;
  --gold: #c98a2c;
  --gold-dark: #8a5e1c;
  --muted: #55483a;
  --border: #e3d5bd;
  --terracotta: #b5502f;
  --green: #35533f;
  --white: #fff;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

.wordmark {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: normal;
  margin: 0;
  white-space: nowrap;
}
.wordmark span { color: var(--gold); }

/* ---------------------------------------------------------------- login */

#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.login-card .wordmark {
  font-size: 24px;
  margin-bottom: 22px;
  text-align: center;
}

/* ---------------------------------------------------------------- shell */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.topbar nav a:hover { color: var(--ink); background: var(--cream); }
.topbar nav a.active { color: var(--ink); font-weight: 600; background: var(--cream); }
.whoami { margin-left: auto; color: var(--muted); font-size: 13px; }

.banner {
  background: #f2e2c2;
  border-bottom: 1px solid var(--gold);
  padding: 10px 24px;
  font-size: 14px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.view-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.view-head h2 {
  font-family: var(--serif);
  font-weight: normal;
  font-size: 24px;
  margin: 0;
}
.head-side { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.back-row { margin: 0 0 8px; }
.back-row a { color: var(--muted); text-decoration: none; }
.back-row a:hover { color: var(--ink); }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.settings-card { max-width: 560px; }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea { width: 100%; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 0;
  border-color: var(--gold);
}
input:disabled, textarea:disabled { background: var(--cream); color: var(--muted); }

textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  min-height: 440px;
  resize: vertical;
}

.btn {
  font: inherit;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
  font-weight: 600;
}
.btn-primary:hover { background: #b87e26; border-color: #b87e26; }
.btn-danger {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
  font-weight: 600;
}
.btn-danger:hover { background: #a04628; border-color: #a04628; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.msg { font-size: 14px; color: var(--green); margin: 10px 0 0; }
.msg:empty { display: none; }
.msg-error { color: var(--terracotta); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.loading { color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- tables */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar input[type="search"] { flex: 1; min-width: 160px; }
.add-form { display: flex; gap: 8px; margin-left: auto; }

.countline { color: var(--muted); font-size: 13px; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }
td.empty { color: var(--muted); text-align: center; padding: 24px; }
.email-cell { font-weight: 500; overflow-wrap: anywhere; }
.subject-link { color: var(--ink); font-weight: 500; text-decoration: none; }
.subject-link:hover { color: var(--gold-dark); }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-green { background: #e3ebe4; color: var(--green); }
.pill-gold { background: #f5e7cb; color: var(--gold-dark); }
.pill-grey { background: #ece5d8; color: var(--muted); }
.pill-terracotta { background: #f4ded4; color: var(--terracotta); }
.pill.sending { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------------------------------------------------------------- editor */

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.preview {
  width: 100%;
  height: 440px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--cream);
}
.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 14px;
}
.test-group { display: flex; gap: 8px; margin-left: auto; }
.test-group input { width: 220px; }

.progress { font-weight: 600; color: var(--gold-dark); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.stat {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.stat-value { font-family: var(--serif); font-size: 22px; }
.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .add-form { margin-left: 0; }
  .test-group { margin-left: 0; }
  .whoami { margin-left: 0; }
  main { padding: 16px; }
}
