:root {
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --card: #ffffff;
  --accent: #2563eb;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --gray: #4b5563;
  --gray-bg: #f3f4f6;
  --amber: #b45309;
  --amber-bg: #fef3c7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.25rem; margin: 0; }
.muted { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
.error { color: var(--red); font-size: 0.9rem; }

button {
  font: inherit;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

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

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

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-card input {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

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

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.header-actions { display: flex; gap: 0.5rem; }

/* --- stats -------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-num { font-size: 1.6rem; font-weight: 650; }
.stat-label { font-size: 0.8rem; color: var(--muted); }

/* --- tabs & table ------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 12px 12px 12px;
  padding: 0.25rem 1rem;
  overflow-x: auto;
}

.table-wrap > p { padding: 0.75rem 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0.7rem 0.75rem 0.4rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

.category { font-size: 0.8rem; }

/* --- badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--gray);
  background: var(--gray-bg);
}

.status-queued  { color: var(--blue);  background: var(--blue-bg); }
.status-sent    { color: var(--blue);  background: var(--blue-bg); }
.status-replied { color: var(--green); background: var(--green-bg); }
.status-bounced { color: var(--red);   background: var(--red-bg); }

.reply-genuine  { color: var(--green); background: var(--green-bg); }
.reply-bounce   { color: var(--red);   background: var(--red-bg); }
.reply-opt_out  { color: var(--amber); background: var(--amber-bg); }

/* --- phones ------------------------------------------------------------- */

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  header { flex-direction: column; }
  td, th { padding-left: 0.5rem; padding-right: 0.5rem; }
}
