:root {
  --bg: #f4efe6;
  --ink: #13211c;
  --muted: #5a665d;
  --panel: rgba(255, 252, 247, 0.82);
  --line: rgba(19, 33, 28, 0.12);
  --accent: #d95d39;
  --accent-dark: #a84427;
  --success: #23724d;
  --warning: #b7791f;
  --danger: #a62d2d;
}

* {
  box-sizing: border-box;
}

body.portal-shell {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(217, 93, 57, 0.24), transparent 28%),
    radial-gradient(circle at left bottom, rgba(35, 114, 77, 0.18), transparent 30%),
    linear-gradient(180deg, #f9f5ee 0%, var(--bg) 100%);
  font-family: Georgia, "Times New Roman", serif;
}

.portal-frame {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 72px;
}

.dashboard-grid,
.download-layout {
  display: grid;
  gap: 20px;
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.download-layout {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(19, 33, 28, 0.08);
}

.panel-wide {
  grid-column: span 12;
}

.panel:not(.panel-wide) {
  grid-column: span 6;
}

.hero-panel,
.error-panel {
  max-width: 760px;
  margin: 8vh auto 0;
}

.panel-header,
.grant-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

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

.hero-title,
.section-title,
.card-title {
  margin: 0;
  line-height: 1.05;
  font-weight: 600;
}

.hero-title {
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  max-width: 12ch;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.card-title {
  font-size: 1.28rem;
}

.muted,
.grant-meta dt {
  color: var(--muted);
}

.hero-copy,
.token-strip,
.notice,
.stack {
  margin-top: 20px;
}

.hero-actions,
.token-row,
.card-actions,
.chip-cloud,
.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-button,
.ghost-button,
.token-input {
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  color: #fffaf5;
  background: linear-gradient(135deg, var(--accent) 0%, #ef7f54 100%);
}

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

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.token-input {
  flex: 1 1 360px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(19, 33, 28, 0.06);
}

.inbound-grid,
.grant-grid {
  display: grid;
  gap: 16px;
}

.inbound-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grant-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 20px;
}

.grant-card,
.empty-state,
.notice {
  border-radius: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.notice-danger,
.tone-danger {
  border-color: rgba(166, 45, 45, 0.28);
  background: rgba(166, 45, 45, 0.06);
}

.tone-success {
  border-color: rgba(35, 114, 77, 0.24);
}

.tone-warning {
  border-color: rgba(183, 121, 31, 0.24);
}

.grant-meta {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.grant-meta dd {
  margin: 4px 0 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
}

.status-success {
  color: var(--success);
  background: rgba(35, 114, 77, 0.12);
}

.status-warning {
  color: var(--warning);
  background: rgba(183, 121, 31, 0.12);
}

.status-danger {
  color: var(--danger);
  background: rgba(166, 45, 45, 0.1);
}

.status-neutral,
.status-pending {
  color: var(--muted);
  background: rgba(19, 33, 28, 0.08);
}

.qr-image {
  width: min(220px, 100%);
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: white;
}

.break-all {
  word-break: break-all;
}

.key-wrapper {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.key-pre {
  margin: 0;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  color: var(--ink);
  user-select: all;
}

@media (max-width: 820px) {
  .panel:not(.panel-wide) {
    grid-column: span 12;
  }

  .portal-frame {
    padding: 20px 14px 40px;
  }
}

/* ── Dashboard ──────────────────────────────────────────── */

.dash-wrap {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 40px;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(19, 33, 28, 0.08);
}

.dash-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #ef7f54 100%);
  color: #fffaf5;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-username {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.dash-email {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.dash-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 32px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(19, 33, 28, 0.08);
}

.dash-section-title {
  margin: 6px 0 20px;
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  font-weight: 600;
  line-height: 1.15;
}

.mt-8 {
  margin-top: 8px;
}

.small {
  font-size: 0.82rem;
}

.inbound-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.proto-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--accent-dark);
  background: rgba(169, 68, 39, 0.1);
  border: 1px solid rgba(169, 68, 39, 0.18);
  width: fit-content;
  margin-bottom: 4px;
}

.inbound-card {
  border-radius: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ── Login page ─────────────────────────────────────────── */

.login-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 40px 36px 36px;
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 64px rgba(19, 33, 28, 0.10);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #ef7f54 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo-mark {
  color: #fffaf5;
  font-size: 1.6rem;
  font-weight: 700;
  font-family: Georgia, serif;
  line-height: 1;
}

.login-brand {
  margin: 0 0 20px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-dark);
}

.login-title {
  margin: 0 0 10px;
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.15;
}

.login-sub {
  margin: 0 0 28px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.login-btn {
  width: 100%;
  justify-content: center;
}

/* ── Admin panel ─────────────────────────────────────────── */

.admin-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(19, 33, 28, 0.07);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-avatar {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.admin-brand-title {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.admin-brand-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  gap: 4px;
}

.admin-tab {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s;
}

.admin-tab:hover {
  color: var(--ink);
  background: rgba(19, 33, 28, 0.05);
}

.admin-tab--active {
  color: var(--accent-dark);
  background: rgba(169, 68, 39, 0.08);
  border-color: rgba(169, 68, 39, 0.18);
  font-weight: 600;
}

.admin-header-actions {
  display: flex;
  gap: 8px;
}

/* ── Filters bar ───────────────────────────────────────── */

.admin-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-select {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
}

.admin-total {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Admin table card ──────────────────────────────────── */

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(19, 33, 28, 0.07);
  overflow: hidden;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table thead {
  border-bottom: 1px solid var(--line);
}

.admin-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.admin-table td {
  padding: 13px 16px;
  vertical-align: top;
  border-bottom: 1px solid rgba(19, 33, 28, 0.06);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: rgba(19, 33, 28, 0.02);
}

.tbl-primary {
  display: block;
  font-weight: 600;
  color: var(--ink);
}

.tbl-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.tbl-mono {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
}

.tbl-nowrap {
  white-space: nowrap;
}

.tbl-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.admin-revoke-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(166, 45, 45, 0.3);
  background: rgba(166, 45, 45, 0.06);
  color: var(--danger);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.admin-revoke-btn:hover {
  background: rgba(166, 45, 45, 0.14);
}

/* ── Pagination ─────────────────────────────────────────── */

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.admin-page-info {
  font-size: 0.84rem;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
}
