:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

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

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 8px 0; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}
.break { word-break: break-all; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.strong { font-weight: 650; }

/* Top bar */
.topbar {
  background: #0b1220;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  font-weight: 800;
}
.brand-mark.large { width: 46px; height: 46px; border-radius: 13px; font-size: 22px; }
.mainnav { display: flex; gap: 18px; flex: 1; }
.mainnav a { color: #cbd5e1; font-weight: 550; font-size: 14px; }
.mainnav a:hover { color: #fff; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 14px; color: #94a3b8; font-size: 13px; }
.userbox form { margin: 0; }
.link-button {
  background: none;
  border: 0;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { color: #fff; text-decoration: underline; }

/* Layout */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  flex: 1;
}
.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; }
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 17px; }
.subsection { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 18px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat strong { display: block; font-size: 30px; letter-spacing: -0.03em; margin-top: 4px; }
.stat strong.stat-small { font-size: 20px; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 15px;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.button:hover { background: #f8fafc; text-decoration: none; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-strong); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #991b1b; }
.button.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.button.full { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form input { flex: 1; min-width: 220px; }
.mailbox-form, .invite-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  align-items: end;
}
.mailbox-form .button, .invite-form .button { grid-column: 1 / -1; justify-self: start; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
.records-table td:nth-child(4) { min-width: 280px; }
.settings-table th { width: 190px; color: var(--ink); text-transform: none; font-size: 13px; }
.record-purpose { display: block; font-weight: 600; }

/* Copy rows */
.copy-row { display: flex; align-items: flex-start; gap: 8px; }
.copy-row code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 4px 8px;
  display: inline-block;
  max-width: 100%;
}
.copy-row .button { flex: none; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid transparent;
  vertical-align: middle;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.verified { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.badge.active { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.badge.suspended { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.neutral { background: #f1f5f9; color: var(--muted); border-color: var(--line); }

/* Flashes */
.flash {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}
.flash.success { border-left-color: var(--ok); background: #f0fdf4; }
.flash.error { border-left-color: var(--danger); background: #fef2f2; }
.flash.warning { border-left-color: var(--warn); background: #fffbeb; }
.flash.info { border-left-color: var(--info); background: #eff6ff; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.check.ok { background: #f0fdf4; border-color: #bbf7d0; }
.check.fail { background: #fef2f2; border-color: #fecaca; }
.check-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 800;
  flex: none;
}
.check.ok .check-icon { background: var(--ok); color: #fff; }
.check.fail .check-icon { background: var(--danger); color: #fff; }
.check-body { display: grid; gap: 2px; }
.check-body strong { font-size: 14px; }
.check-body .muted { font-size: 13px; word-break: break-word; }

/* Empty and notices */
.empty {
  text-align: center;
  padding: 34px 20px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fafcff;
}
.empty h3 { margin-bottom: 4px; }
.notice {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}

/* Credentials */
.credentials { display: grid; gap: 14px; }
.credential-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
}
.credential-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 6px; }

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding: 40px 0 60px; }
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { margin-top: 12px; font-size: 24px; }
.auth-brand p { color: var(--muted); margin-top: 4px; }
.auth-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }

/* Danger */
.danger-zone summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--danger);
  list-style: none;
}
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone[open] summary { margin-bottom: 10px; }

/* Error */
.error-card { text-align: center; padding: 40px 24px; }
.error-code { display: block; font-size: 54px; font-weight: 800; color: var(--brand); letter-spacing: -0.04em; }
.error-card .actions { justify-content: center; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .mainnav { order: 3; width: 100%; }
  .userbox { margin-left: auto; }
  .container { padding: 20px 14px 40px; }
  h1 { font-size: 23px; }
  .credential-row { grid-template-columns: 1fr; gap: 4px; }
  .page-head { flex-direction: column; }
}

/* Primera configuración */
.setup-wrap { display: flex; justify-content: center; padding: 32px 0 60px; }
.setup-card {
  width: 100%;
  max-width: 880px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.setup-form { display: grid; gap: 22px; }
.setup-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.setup-section:first-of-type { border-top: 0; padding-top: 0; }
.section-head { display: flex; align-items: flex-start; gap: 12px; }
.step {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 750;
  flex: none;
}
.section-head h2 { font-size: 16px; margin: 0; }
.section-head p { margin: 2px 0 0; font-size: 13px; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.checkbox input { width: auto; }
