@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap");

:root {
  --ink: #0e0e0c;
  --paper: #e4e1d7;
  --white: #f4f1e8;
  --acid: #d4ff00;
  --coral: #ff4d2e;
  --sky: #2f6bff;
  --muted: #6f6d64;
  --ok: #166534;
  --line: 2px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --font: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  background-image:
    linear-gradient(rgba(14,14,12,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14,14,12,.04) 1px, transparent 1px);
  background-size: 18px 18px;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); font-size: 0.8rem; display: block; }
code { font-size: 0.85em; }
.hidden { display: none !important; }

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 0;
  min-height: 56px;
  background: var(--white);
  border-bottom: var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 14px;
}
.top-left { border-right: 0; }
.top-right { margin-left: auto; }
.topbar strong {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: -.02em;
}
.logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--acid);
  font-weight: 700;
  font-size: 11px;
  box-shadow: 2px 2px 0 var(--ink);
  flex-shrink: 0;
}
.logo.sm { width: 28px; height: 28px; font-size: 10px; }
.badge {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--acid);
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--line);
  background: var(--white);
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  color: var(--ink);
}
.btn:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  background: var(--acid);
  border: var(--line);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
}
.btn.ghost:hover { background: #efece3; box-shadow: none; transform: none; }
.btn.danger {
  background: var(--coral);
  color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
}
.btn:disabled { opacity: .55; cursor: wait; }

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  position: relative;
}
.login-page::before {
  content: "";
  position: absolute;
  inset: 12% 8%;
  border: 1px dashed rgba(14,14,12,.25);
  pointer-events: none;
}
.login-wrap {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  border: var(--line);
  background: var(--white);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}
.login-wrap-simple {
  width: min(420px, 100%);
  grid-template-columns: 1fr;
}
.login-wrap-simple .card {
  padding: 32px 28px;
}
.login-wrap .brand {
  padding: 36px 28px;
  border-right: var(--line);
  background:
    repeating-linear-gradient(135deg, transparent 0 10px, rgba(14,14,12,.03) 10px 20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 380px;
}
.login-wrap .brand .logo {
  width: 40px;
  height: 40px;
  font-size: 13px;
}
.login-wrap .brand h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: .92;
  letter-spacing: -.07em;
  text-transform: uppercase;
}
.login-wrap .card {
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}
.login-wrap .card h2 {
  margin: 0 0 18px;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: -.03em;
}
label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 12px 0 6px;
  color: var(--muted);
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  border: var(--line);
  background: var(--paper);
  padding: 12px;
  font-size: 12px;
  outline: none;
  border-radius: 0;
  color: var(--ink);
}
input:focus, textarea:focus {
  background: var(--white);
  box-shadow: inset 3px 0 0 var(--sky);
}

.flash {
  padding: 10px 12px;
  border: 1px solid var(--ink);
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.flash.error {
  background: #ffd7ce;
  color: var(--ink);
}
.flash.message {
  background: var(--acid);
  color: var(--ink);
}

/* ── Inbox ── */
.inbox {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}
.empty {
  text-align: center;
  padding: 48px 20px;
  background: var(--white);
  border: var(--line);
  box-shadow: var(--shadow);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}
.empty h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
}
.mail-list {
  background: var(--white);
  border: var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mail-head, .mail-row {
  display: grid;
  grid-template-columns: 200px 1fr 140px;
  gap: 12px;
  padding: 12px 14px;
  align-items: center;
}
.mail-head {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #ebe8df;
  border-bottom: var(--line);
  font-weight: 700;
}
.mail-row {
  border-bottom: 1px solid var(--ink);
  background: var(--white);
  width: 100%;
  text-align: left;
}
.mail-row:hover { background: #f0ede4; }
.mail-row:last-child { border-bottom: none; }
.from {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 26px;
  height: 26px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--white);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 9px;
  flex-shrink: 0;
  border-radius: 0;
}
.subj { overflow: hidden; min-width: 0; }
.subj strong {
  display: block;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
.subj em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
  font-weight: 500;
}
.date {
  color: var(--ink);
  font-size: 9px;
  text-align: right;
  text-transform: uppercase;
  font-weight: 600;
}

/* ── Mail view ── */
.mail-view {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}
.mail-meta {
  background: var(--white);
  border: var(--line);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 11px;
  line-height: 1.65;
  text-transform: uppercase;
}
.mail-meta b { color: var(--muted); font-size: 9px; }
.body-html,
.body-html.full {
  width: 100%;
  min-height: 72vh;
  border: var(--line);
  background: #fff;
  display: block;
  border-radius: 0;
}

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(14,14,12,.55);
  display: grid;
  place-items: center;
}
.loading-box {
  width: min(320px, 90vw);
  border: var(--line);
  background: var(--white);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 22px;
  text-align: center;
}
.loading-box h3 {
  margin: 12px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ink);
  border-top-color: var(--acid);
  margin: 0 auto;
  animation: spin .7s linear infinite;
  border-radius: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Checker extras (shared tokens) ── */
.checker-wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.checker-card {
  background: var(--white);
  border: var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
  border-radius: 0;
}
.checker-card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: -.02em;
}
.hint {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.quota-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: var(--line);
  background: var(--white);
  box-shadow: var(--shadow);
  font-size: .85rem;
  text-transform: uppercase;
  font-weight: 600;
}
.stats-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.stat-pill {
  border: 1px solid var(--ink);
  padding: 5px 10px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--white);
  border-radius: 0;
}
.stat-pill.live { background: var(--acid); }
.stat-pill.die { background: var(--coral); color: #fff; }
.stat-pill.err { background: #ffd36b; }
.stat-pill.quota { background: var(--ink); color: var(--acid); }
.result-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.result-table th, .result-table td {
  border-bottom: 1px solid var(--ink);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}
.result-table th {
  background: var(--ink);
  color: var(--white);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-live { color: var(--ok); font-weight: 700; }
.badge-die { color: var(--coral); font-weight: 700; }
.badge-error { color: #a16207; font-weight: 700; }

@media (max-width: 720px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-wrap .brand {
    border-right: 0;
    border-bottom: var(--line);
    min-height: auto;
  }
  .mail-head { display: none; }
  .mail-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .date { text-align: left; }
  .topbar { flex-wrap: wrap; }
}
