:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #666b73;
  --line: #d8dadd;
  --accent: #146c5c;
  --accent-hover: #0d574a;
  --danger: #a83232;
  --warn: #91610f;
  --ok: #1d7d4a;
  --info: #1f6feb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #1f2726;
  color: #fff;
  padding: 20px 16px;
}

.brand {
  font-size: 19px;
  font-weight: 700;
  margin: 0 4px 24px;
  color: #fff;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a,
.logout-button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #eef4f2;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.nav a:hover,
.logout-button:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.content { padding: 28px; max-width: 100%; }

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 { margin: 0; font-size: 24px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel h3 { margin: 16px 0 8px; font-size: 15px; }

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 2px;
}

.metric .muted { display: block; font-size: 12px; }

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.auth-card h1 { margin: 0 0 12px; }

label {
  display: block;
  font-weight: 600;
  margin: 12px 0 4px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 9px 10px;
  width: 100%;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

button,
.button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 9px 14px;
  text-decoration: none;
  margin: 0 4px 0 0;
}

button:hover, .button:hover { background: var(--accent-hover); text-decoration: none; }

.button.secondary,
button.secondary { background: #59636a; }
.button.secondary:hover,
button.secondary:hover { background: #40474d; }

.button.danger,
button.danger { background: var(--danger); }
.button.danger:hover,
button.danger:hover { background: #812525; }

.link-button {
  background: transparent;
  color: var(--danger);
  padding: 2px 4px;
  font-weight: 500;
}

.flash {
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
}

.flash.success { background: #e3f5ed; color: #12483a; border-color: #b7dcc6; }
.flash.error   { background: #fae8e8; color: var(--danger); border-color: #e8b6b6; }

.table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #f1f3f4;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.table tr:hover td { background: #f9fafb; }

.muted { color: var(--muted); }
.small { font-size: 11px; }
.error { color: var(--danger); }

.badge {
  display: inline-block;
  background: #e1e4e6;
  border-radius: 12px;
  color: #333;
  font-size: 11px;
  padding: 1px 8px;
  margin-left: 4px;
}

.badge-success { background: #d8eede; color: #12483a; }
.badge-warn    { background: #fcefd1; color: #6b4807; }
.badge-error   { background: #f9d8d8; color: #812525; }
.badge.delivery { background: #d0e1ff; color: #0d3b8a; }
.badge.bounce   { background: #f9d8d8; color: #812525; }
.badge.deferred { background: #fcefd1; color: #6b4807; }
.badge.other    { background: #e1e4e6; color: #333; }

.form-grid {
  display: grid;
  gap: 8px 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.form-grid label { margin-bottom: 0; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-row form { display: inline; }

pre {
  background: #1f2726;
  color: #eef4f2;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.bar-label { color: var(--muted); }

.bar {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
  min-width: 1px;
}

.bar-sent   { background: var(--accent); }
.bar-opens  { background: var(--info); }
.bar-clicks { background: #7d4cb3; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 4px 0 12px;
  vertical-align: middle;
}
.dot-sent   { background: var(--accent); }
.dot-opens  { background: var(--info); }
.dot-clicks { background: #7d4cb3; }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .content { padding: 16px; }
  .topbar h1 { font-size: 20px; }
}
