:root {
  --bg: #f4efe7;
  --panel: #fffdfa;
  --ink: #1e1f24;
  --muted: #6b6f76;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #027a48;
  --success-bg: #ecfdf3;
  --border: #ded6ca;
  --shadow: 0 18px 50px rgba(30, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.18), transparent 28%),
    linear-gradient(180deg, #f7f3ed 0%, #f1ebe3 100%);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.panel,
.stat-card {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(222, 214, 202, 0.9);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.auth-card {
  width: min(100%, 420px);
  padding: 32px;
  display: grid;
  gap: 20px;
}

.topbar {
  padding: 32px 24px 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.page {
  padding: 12px 24px 32px;
  display: grid;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
}

.subtle {
  color: var(--muted);
}

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

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 34px;
}

.panel {
  padding: 20px;
}

.filters,
.auth-form {
  display: grid;
  gap: 16px;
}

.filters {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
button {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font: inherit;
}

input,
select {
  background: #fff;
}

button,
a,
.ghost-link {
  transition: 180ms ease;
}

button {
  background: var(--accent);
  color: white;
  border-color: transparent;
  cursor: pointer;
  font-weight: 700;
}

button:hover,
a:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

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

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(222, 214, 202, 0.8);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success {
  color: var(--success);
  background: var(--success-bg);
}

.badge-failed {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge-already-sent {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.12);
}

.error-cell {
  max-width: 280px;
  word-break: break-word;
}

.table-link {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.inline-link {
  min-height: 40px;
  padding: 10px 12px;
}

.action-group {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.detail-shell {
  display: grid;
  gap: 20px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.detail-header h2 {
  margin: 0;
  font-size: clamp(24px, 2.5vw, 34px);
}

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

.detail-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(247, 243, 237, 0.7);
  border: 1px solid rgba(222, 214, 202, 0.85);
}

.detail-card span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.detail-card strong {
  word-break: break-word;
}

.detail-stack {
  display: grid;
  gap: 18px;
}

.detail-block {
  border: 1px solid rgba(222, 214, 202, 0.85);
  border-radius: 16px;
  background: #fff;
  padding: 16px;
  overflow-x: auto;
}

.detail-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

.empty-state,
.disabled {
  color: var(--muted);
}

.two-column {
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  align-items: start;
}

.section-title {
  margin-top: 0;
}

.badge-role {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.12);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.pagination a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions,
  .two-column,
  .detail-header {
    width: 100%;
  }

  .detail-header {
    flex-direction: column;
  }

  .page,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
}
