:root {
  --ink: #16231f;
  --muted: #66736e;
  --line: #dce5e1;
  --surface: #ffffff;
  --surface-subtle: #f4f7f6;
  --brand: #08785d;
  --brand-dark: #075b48;
  --danger: #b42318;
  --shadow: 0 12px 40px rgba(21, 50, 42, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #eef3f1; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: var(--brand-dark); }
a:hover { color: var(--brand); }

.app-header { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(12px); }
.app-header__inner { width: min(1200px, calc(100% - 32px)); min-height: 68px; margin: 0 auto; display: flex; align-items: center; gap: 28px; }
.brand { color: var(--ink); font-weight: 800; text-decoration: none; letter-spacing: -0.025em; }
.main-nav, .user-nav { display: flex; align-items: center; gap: 18px; }
.main-nav a, .user-nav a { color: var(--muted); font-size: 0.94rem; font-weight: 600; text-decoration: none; }
.user-nav { margin-left: auto; }
.user-nav form { margin: 0; }
.page-shell { width: min(1200px, calc(100% - 32px)); margin: 32px auto 64px; }
.auth-shell { width: min(440px, calc(100% - 32px)); margin: 10vh auto; }
.legal-shell { width: min(900px, calc(100% - 32px)); margin: 32px auto 64px; }

.legal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; padding: 0 4px; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 16px; }
.legal-nav a { color: var(--muted); font-size: 0.92rem; font-weight: 600; text-decoration: none; }
.legal-document { padding: clamp(24px, 5vw, 52px); }
.legal-document__heading { margin-bottom: 36px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.legal-document__heading h1 { margin: 0 0 8px; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -0.035em; }
.legal-document__heading > p:last-child { margin: 0; color: var(--muted); }
.legal-document section + section { margin-top: 34px; }
.legal-document h2 { margin: 0 0 12px; font-size: 1.3rem; }
.legal-document p, .legal-document li { max-width: 75ch; }
.legal-document li + li { margin-top: 6px; }
.legal-document .eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); background: rgba(255, 255, 255, 0.72); }
.site-footer__inner { width: min(1200px, calc(100% - 32px)); min-height: 64px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 0.86rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer a { color: var(--muted); text-decoration: none; }

.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1, .section-heading h2 { margin: 0; }
.page-heading p { margin: 4px 0 0; color: var(--muted); }
.card { padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card h2, .card h3 { margin-top: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat__value { display: block; font-size: 2rem; font-weight: 800; }
.stat__label { color: var(--muted); font-size: 0.9rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 15px; border: 1px solid var(--brand); border-radius: 8px; color: white; background: var(--brand); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { color: white; background: var(--brand-dark); }
.button--secondary { color: var(--brand-dark); background: white; }
.button--secondary:hover { color: white; }
.button--danger { border-color: var(--danger); background: var(--danger); }
.button--quiet { min-height: 34px; padding: 5px 10px; color: var(--muted); border-color: var(--line); background: white; }
.button--quiet:hover { color: var(--ink); border-color: #b8c7c1; background: var(--surface-subtle); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions form { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; color: #34413c; background: #e8eeeb; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.badge--active, .badge--verified, .badge--delivered, .badge--redeemed { color: #05603a; background: #d9f4e7; }
.badge--pending, .badge--received, .badge--awaiting-site { color: #795100; background: #fff0c7; }
.badge--failed, .badge--revoked, .badge--inactive { color: #912018; background: #fee4e2; }
.badge--owner { color: #1849a9; background: #dbeafe; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { margin-bottom: 18px; }
.field--full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; font-weight: 700; }
.field small, .hint { color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="tel"], select, textarea { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #b8c7c1; border-radius: 8px; color: var(--ink); background: white; font: inherit; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(8, 120, 93, 0.16); border-color: var(--brand); }
.check-field { display: flex; align-items: center; gap: 8px; }

.flash { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #a6e1c4; border-radius: 9px; color: #075f3d; background: #e5f8ef; }
.flash--alert { border-color: #f2b8b5; color: #8d2119; background: #fff0ef; }
.errors { margin-bottom: 20px; padding: 14px 18px; border-left: 4px solid var(--danger); color: #7a271a; background: #fff3f2; }
.errors ul { margin-bottom: 0; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88rem; overflow-wrap: anywhere; }
.message-preview { max-width: 440px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-body, pre { padding: 16px; border-radius: 9px; background: var(--surface-subtle); white-space: pre-wrap; overflow-wrap: anywhere; }
.secret-box { border-color: #f2cf72; background: #fff9e9; }
.definition-list { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: 10px 18px; }
.definition-list dt { color: var(--muted); font-weight: 700; }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }
.auth-card { padding: 32px; }
.auth-card h1 { margin: 0 0 6px; }
.auth-card > p { margin-top: 0; color: var(--muted); }

@media (max-width: 760px) {
  .app-header__inner { min-height: auto; padding: 14px 0; flex-wrap: wrap; gap: 12px 18px; }
  .brand { width: 100%; }
  .user-nav { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field--full { grid-column: auto; }
  .page-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .definition-list { grid-template-columns: 1fr; gap: 3px; }
  .definition-list dd { margin-bottom: 10px; }
  .legal-header, .site-footer__inner { align-items: flex-start; flex-direction: column; }
  .site-footer__inner { padding: 18px 0; }
}
