:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #52525b;
  --text-subtle: #71717a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

main.container,
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

h1, h2, h3 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.5rem 0 0.75rem;
}

h1 { font-size: 1.75rem; margin-top: 0.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0.5rem 0 1rem; }

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

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

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

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  overflow-x: auto;
}

pre.wrap {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Topbar */
.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  padding: 0.625rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.topbar-nav {
  display: flex;
  gap: 1.25rem;
}

.topbar-nav a {
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar-user {
  align-items: center;
  display: flex;
  gap: 0.875rem;
}

.topbar-user a { color: var(--text-muted); }
.topbar-user a:hover { color: var(--text); }

/* Flash messages */
.flash {
  margin: 1rem auto 0;
  max-width: 960px;
  padding: 0 1.25rem;
}

.flash p {
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: var(--success);
  margin: 0 0 0.5rem;
  padding: 0.625rem 0.875rem;
}

.flash p + p {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

/* Tables */
table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
  margin: 0.5rem 0 1.5rem;
  width: 100%;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.625rem 0.875rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f4f4f5;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafafa; }

/* Stat cards (dashboard) */
.stats ul {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  list-style: none;
  margin: 0.5rem 0 1.5rem;
  padding: 0;
}

.stats li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.875rem 1rem;
}

/* Definition list */
dl {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 160px 1fr;
  margin: 0.5rem 0 1.5rem;
  padding: 0.5rem 1rem;
}

dt {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

dd {
  margin: 0;
  padding: 0.5rem 0;
}

/* Forms */
form { margin: 1rem 0; }

form > div { margin-bottom: 1rem; }

label {
  color: var(--text-muted);
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
textarea,
select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.625rem;
  width: 100%;
  max-width: 480px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

textarea {
  font-family: inherit;
  min-height: 120px;
  max-width: 640px;
  resize: vertical;
}

input[type="checkbox"] {
  margin-right: 0.4rem;
}

/* Buttons */
input[type="submit"],
button {
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background-color 0.1s ease;
}

input[type="submit"]:hover,
button:hover {
  background: var(--accent-hover);
}

/* Sections */
section { margin-bottom: 2rem; }

/* Hero / sign-in landing */
.hero {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

/* Primary button (anchor styled as button) */
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.18);
  color: #fff;
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.7rem 1.6rem;
  text-decoration: none;
  transition: background-color 0.12s ease, box-shadow 0.12s ease, transform 0.04s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  color: #fff;
  text-decoration: none;
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

/* Status pills (forwarded / pending / spam) */
.status {
  background: #f4f4f5;
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.55rem;
  text-transform: uppercase;
}

.status-forwarded { background: var(--success-bg); color: var(--success); }
.status-spam { background: var(--danger-bg); color: var(--danger); }

/* Inline link list (dashboard nav) */
.links {
  color: var(--text-subtle);
  font-size: 0.95rem;
}

/* Subtle muted text */
.muted, small {
  color: var(--text-subtle);
  font-size: 0.85rem;
}

/* Form errors */
.errors {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--danger);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}

.errors h2 {
  color: var(--danger);
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}

.errors ul { margin: 0; padding-left: 1.25rem; }
