/* ==========================================================================
   Veilway customer portal.

   Loaded after veilway.css, which owns the token layer, base elements and
   the shared primitives (buttons, inputs, cards, badges, alerts, tables).
   This sheet adds only what the customer-facing surfaces need: the public
   shell, the landing page (hero, value props, plans), the auth card, the
   account dashboard, and long-form prose for the security and canary
   pages.

   Class names the SPA's inline script touches (.hidden, #banner children,
   .device-row, .seg-btn, .pane) are part of that contract; keep them.
   ========================================================================== */

body.portal {
  /* A consumer surface reads a notch larger than the operator console. */
  --fs-body: 14.5px;
  --fs-sm: 13px;
  --fs-caption: 12px;
  --fs-title: 17px;
  --page-w: 1080px;
  font-size: var(--fs-body);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.portal main {
  flex: 1;
  /* body is a flex column; without this, one long unbreakable string
     (a URL, a code) widens main past the viewport on phones. */
  min-width: 0;
  width: 100%;
  padding: var(--sp-8) var(--sp-6) 72px;
}
body.portal.narrow main {
  max-width: 840px;
}

/* ---- Public shell ------------------------------------------------------ */

header.top .top-links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}
header.top .top-links a.quiet {
  padding: 6px 10px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
}
header.top .top-links a.quiet:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
@media (max-width: 720px) {
  header.top .top-links a.quiet {
    display: none;
  }
}

/* ---- Hero -------------------------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  padding: 56px var(--sp-5) 48px;
  margin-bottom: var(--sp-8);
}
.hero .logo {
  width: 64px;
  height: 64px;
  border-radius: var(--r-xl);
}
.hero h1 {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1.04;
  letter-spacing: -0.025em;
}
.hero p.lede {
  max-width: 62ch;
  margin: 0;
  color: var(--text-2);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.55;
}
.hero .cta-row {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--sp-2);
}
.hero .btn,
.hero button {
  min-height: 44px;
  padding: 0 22px;
  font-size: var(--fs-body);
}
.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-caption);
  font-family: var(--font-mono);
}
.trust-strip span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.trust-strip span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ---- Section headings -------------------------------------------------- */

.section {
  margin: 0 0 var(--sp-8);
}
.section-head {
  margin-bottom: var(--sp-5);
  text-align: center;
}
.section-head h2 {
  justify-content: center;
  margin: 0;
  font-size: clamp(21px, 3vw, 27px);
  letter-spacing: -0.015em;
}
.section-head p {
  max-width: 60ch;
  margin: var(--sp-2) auto 0;
  color: var(--text-2);
}

/* ---- Value props ------------------------------------------------------- */

.prop-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.prop {
  position: relative;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  transition: border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.prop:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
}
.prop .ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}
.prop .ico svg {
  width: 19px;
  height: 19px;
}
.prop h3 {
  margin: 0 0 6px;
  font-size: var(--fs-title);
  font-weight: 600;
}
.prop p {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* ---- Plans ------------------------------------------------------------- */

.plan-row {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: var(--sp-4);
}
.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.plan.featured {
  border-color: var(--accent-line);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(46, 232, 214, 0.1), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
}
.plan.featured::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.plan-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.plan-price {
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.plan-price strong {
  display: block;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
}
.plan .spacer {
  flex: 1;
}
.includes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}
.includes li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.includes li::before {
  content: "";
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  border-radius: 50%;
  background: url("icons/check.svg") center / 10px 10px no-repeat, var(--accent-grad);
  box-shadow: 0 0 10px rgba(46, 232, 214, 0.25);
}
.includes.two-col {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 9px var(--sp-5);
}

/* ---- Auth card --------------------------------------------------------- */

.auth-wrap {
  max-width: 460px;
  margin: 0 auto;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--line);
}
.seg-btn {
  min-height: 34px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  box-shadow: none;
  color: var(--text-2);
  font-weight: 600;
}
.seg-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: none;
  box-shadow: none;
}
.seg-btn[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.pane[hidden],
.hidden {
  display: none !important;
}
.auth-card form {
  display: grid;
  gap: var(--sp-4);
}
.auth-card input {
  width: 100%;
  min-height: 42px;
  font-size: var(--fs-body);
}
.auth-foot {
  margin: var(--sp-4) 0 0;
  color: var(--text-3);
  font-size: var(--fs-caption);
  line-height: 1.55;
}

/* ---- Account ----------------------------------------------------------- */

.account-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.account-head h1 {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
}
.who {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.sub-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
  border-radius: var(--r-xl);
  background:
    radial-gradient(90% 140% at 0% 0%, color-mix(in srgb, var(--tone, var(--accent)) 14%, transparent), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid color-mix(in srgb, var(--tone, var(--accent)) 28%, var(--line-2));
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.sub-card.is-active {
  --tone: var(--ok);
}
.sub-card.is-inactive {
  --tone: var(--warn);
}
.sub-card::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tone, var(--accent)), transparent);
  opacity: 0.7;
}
.sub-main {
  flex: 1 1 260px;
}
.sub-tier {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 600;
  letter-spacing: -0.015em;
  text-transform: capitalize;
}
.sub-tier.no-plan {
  text-transform: none;
  color: var(--text-2);
}
.account-head #logout {
  /* the header already carries a Log out button */
  display: none;
}
.sub-note {
  margin: 6px 0 0;
  color: var(--text-2);
}
.sub-side {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}
.sub-side .k {
  color: var(--text-3);
  font-size: var(--fs-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.sub-side .v {
  font-family: var(--font-mono);
  color: var(--text);
}
@media (max-width: 620px) {
  .sub-side {
    justify-items: start;
    text-align: left;
  }
}

.device-list {
  display: grid;
}
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.device-row:first-child {
  border-top: 0;
  padding-top: 0;
}
.device-row .d-label {
  display: block;
  font-weight: 600;
}
.device-row > div {
  min-width: 0;
}
.device-row .d-meta {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-3);
  font-size: var(--fs-caption);
  font-family: var(--font-mono);
}

.recovery-code {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
}
.recovery-code code {
  flex: 1 1 260px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.45);
  border-color: var(--accent-line);
  font-size: var(--fs-body);
  letter-spacing: 0.04em;
  user-select: all;
}

/* ---- Prose (security, canary) ------------------------------------------ */

.prose {
  max-width: 76ch;
}
.prose h1 {
  margin: 0 0 var(--sp-2);
  font-size: clamp(26px, 4vw, 34px);
}
.prose h2 {
  margin: var(--sp-8) 0 var(--sp-3);
  font-size: var(--fs-title);
  letter-spacing: 0.01em;
}
.prose h3 {
  margin: var(--sp-5) 0 var(--sp-2);
  font-size: var(--fs-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.prose p,
.prose li {
  color: var(--text-2);
  line-height: 1.65;
}
.prose strong {
  color: var(--text);
}
.prose ul,
.prose ol {
  padding-left: 20px;
}
.prose li {
  margin: 5px 0;
}
.prose .card p:first-child,
.prose .card ul:first-child {
  margin-top: 0;
}
.prose .card p:last-child,
.prose .card ul:last-child {
  margin-bottom: 0;
}
.prose pre {
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3) var(--sp-4);
  line-height: 1.5;
  overflow-x: auto;
}
/* Signed blocks keep their exact line breaks so a copy-paste still verifies. */
.prose pre.signed {
  white-space: pre;
  word-break: normal;
  max-height: 460px;
  overflow: auto;
  font-size: 12px;
}
.prose .card > pre:first-child {
  margin-top: 0;
}
.prose .card > pre + p {
  margin-top: var(--sp-3);
}
.prose .alert {
  margin: var(--sp-5) 0;
}
.kv-dl {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 10px var(--sp-4);
  margin: 0;
}
.kv-dl dt {
  color: var(--text-3);
  font-size: var(--fs-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kv-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 620px) {
  .kv-dl {
    grid-template-columns: 1fr;
    gap: 2px var(--sp-4);
  }
  .kv-dl dd {
    margin-bottom: var(--sp-2);
  }
}

/* ---- Admin dashboard ---------------------------------------------------- */

body.portal.admin {
  --page-w: 1240px;
}
body.portal.admin h2 {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin: var(--sp-8) 0 var(--sp-3);
  scroll-margin-top: var(--sp-6);
}
.count-strip {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-ui);
}
.nowrap {
  white-space: nowrap;
}
.push-right {
  margin-left: auto;
  align-self: center;
}
.fill-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 130px;
}
.fill-bar {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.fill-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--accent-grad);
}
.alert pre.minted {
  margin-top: var(--sp-3);
  white-space: pre;
  word-break: normal;
  overflow-x: auto;
  user-select: all;
  font-size: 13px;
  line-height: 1.6;
}
body.portal.admin main > .alert {
  margin: var(--sp-5) 0 0;
}
.admin-lower {
  margin-top: var(--sp-2);
}
.admin-lower h2 {
  margin-top: var(--sp-6);
}
.admin-lower .alert {
  margin: var(--sp-4) 0 0;
}
.key-rotate,
.mint-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-top: var(--sp-5);
}
.key-rotate p,
.mint-foot p {
  flex: 1 1 240px;
  margin: 0;
}

/* ---- Footer ------------------------------------------------------------ */

footer.site {
  max-width: var(--page-w);
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  font-size: var(--fs-caption);
  color: var(--text-3);
}
footer.site .f-links {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
footer.site a {
  color: var(--text-2);
}
footer.site a:hover {
  color: var(--accent);
}
