@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,800&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink: #161514;
  --ink-soft: #2c2a27;
  --paper: #f5f1ea;
  --paper-soft: #ede8de;
  --paper-line: #d8d2c4;
  --rule: #c9c1b0;
  --accent: #d4451f;
  --accent-soft: #f4d8cf;
  --success: #5a7a3a;
  --warning: #b8862a;
  --danger: #a83825;
  --muted: #6b6660;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(22,21,20,0.04) 1px, transparent 0);
  background-size: 24px 24px;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 32px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 28px 32px;
  border-bottom: 1px solid rgba(245,241,234,0.1);
  margin-bottom: 24px;
}

.brand h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -1px;
  line-height: 1;
}

.brand h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.brand small {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(245,241,234,0.5);
  display: block;
  margin-top: 8px;
}

.nav { flex: 1; padding: 0 16px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: rgba(245,241,234,0.7);
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  margin-bottom: 2px;
  transition: all 0.15s;
}

.nav a:hover { background: rgba(245,241,234,0.06); color: var(--paper); }

.nav a.active {
  background: var(--paper);
  color: var(--ink);
}

.nav a.active::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent);
  margin-right: -3px;
  margin-left: -14px;
  border-radius: 2px;
}

.nav-section {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(245,241,234,0.4);
  padding: 16px 14px 8px;
  margin-top: 16px;
}

.user-strip {
  padding: 20px 28px;
  border-top: 1px solid rgba(245,241,234,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(245,241,234,0.7);
}

.user-strip a:hover { color: var(--accent); }

.main {
  padding: 40px 48px;
  max-width: 1280px;
  width: 100%;
}

/* ===== Headers ===== */
.page-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--paper-line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.page-header h1 {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -1.5px;
  line-height: 1;
}

.page-header h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.page-header .meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ===== Stat Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat {
  background: white;
  border: 1px solid var(--paper-line);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ink);
}

.stat.accent::before { background: var(--accent); }
.stat.success::before { background: var(--success); }
.stat.warning::before { background: var(--warning); }
.stat.danger::before { background: var(--danger); }

.stat .label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.stat .value {
  font-family: var(--display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -1.5px;
}

.stat .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

/* ===== Section ===== */
.section {
  background: white;
  border: 1px solid var(--paper-line);
  margin-bottom: 24px;
}

.section-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--paper-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.section-body { padding: 24px; }

/* ===== Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--paper-line);
  background: var(--paper-soft);
}

.data-table td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--paper-line);
  font-size: 13px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-soft); }

.data-table .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 2px;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.queued { background: #fdf3e0; color: #8b6914; }
.badge.sending { background: #e8f0fe; color: #1e5fbb; }
.badge.sent { background: #e6f0d9; color: #4d6b2d; }
.badge.failed { background: #f7d8d3; color: #8b2818; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.btn:hover { background: var(--accent); border-color: var(--accent); color: white; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

.btn.ghost:hover { background: var(--ink); color: var(--paper); }

.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { background: var(--danger); border-color: var(--danger); }

/* ===== Forms ===== */
.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: white;
  border: 1px solid var(--paper-line);
  border-radius: 2px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.field textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

/* ===== Chart ===== */
.chart-wrap {
  padding: 24px;
  background: white;
  border: 1px solid var(--paper-line);
  margin-bottom: 24px;
}

.chart-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.chart-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
}

.chart {
  display: flex;
  align-items: flex-end;
  height: 180px;
  gap: 8px;
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 8px;
  position: relative;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  gap: 2px;
}

.bar-sent {
  background: var(--ink);
  width: 100%;
  transition: all 0.3s;
}

.bar-failed {
  background: var(--accent);
  width: 100%;
}

.bar-group:hover .bar-sent { background: var(--accent); }

.bar-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
}

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card {
  width: 420px;
  background: white;
  border: 1px solid var(--paper-line);
  padding: 48px;
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
}

.login-card h1 {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.login-card h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.login-card .tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 36px;
}

.error-banner {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 20px;
}

/* ===== Misc ===== */
.flex { display: flex; align-items: center; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 32px; }
.mb-md { margin-bottom: 16px; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--mono); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state h3 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 20px;
  border-radius: 2px;
  font-size: 13px;
  z-index: 1000;
  animation: slideIn 0.3s;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 20px;
  gap: 4px;
}

.tab {
  padding: 10px 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

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

.preview-frame {
  width: 100%;
  height: 500px;
  border: 1px solid var(--paper-line);
  background: white;
  border-radius: 2px;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 24px; }
}
