.account-button {
  margin-inline-start: auto;
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.account-button:hover { border-color: var(--accent); }
.member-panel {
  --gutter: clamp(16px, 4vw, 28px);
  width: min(460px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;
  border: 1px solid #dcd9e7;
  border-radius: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 24px 80px #201c4033;
}
.member-panel:has(#member-data:not([hidden])) { width: min(640px, calc(100vw - 24px)); }
.member-head, .pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.member-notifications {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  display: flow-root;
  background: white;
}
.member-notifications > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 14px var(--gutter);
  background: white;
  border-bottom: 1px solid var(--line);
}
#member-title { grid-column: 2; font-size: 19px; }
#member-close { justify-self: end; }
.member-panel button, .account-admin button, .account-admin a.account-button { white-space: nowrap; }
.member-panel button, .account-admin button {
  padding: 7px 13px;
  min-height: 36px;
  border-radius: 7px;
  font-size: 14px;
}
.member-panel button:not(:disabled):not(.confirm):hover, .account-admin button:not(:disabled):not(.confirm):hover {
  border-color: #afa5ce;
  background-color: #f4f2f9;
  color: var(--accent);
}
#member-close { background: #f7f6fa; color: var(--muted); }
#member-message {
  margin: 8px var(--gutter);
}
#member-message:empty { margin: 0; padding: 0; }
.member-form { display: grid; gap: 14px; }
.member-form label, .account-admin label { display: grid; min-width: 0; gap: 6px; font-size: 13px; color: var(--muted); }
#auth-form { width: min(320px, calc(100% - 40px)); margin: 20px auto 26px; grid-template-columns: minmax(0, 1fr); }
.member-form input, .account-admin input, .account-admin select {
  width: 100%; min-width: 0; min-height: 40px; padding: 7px 11px; border: 1px solid var(--line);
  border-radius: 7px; background: white; color: var(--ink); font-size: 15px;
}
#auth-form .auth-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#auth-form button { min-height: 41px; }
#member-data { padding: 18px var(--gutter) 24px; }
.account-summary {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 20px;
  align-items: center; padding: 20px 24px; border-radius: 13px;
  background: linear-gradient(110deg,#302a47,#483e68); color: white;
}
.account-summary::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  right: -40px; top: -94px; width: 260px; height: 260px; border-radius: 50%;
  border: 1px solid #ffffff14; box-shadow: 0 0 0 12px #ffffff07,0 0 0 13px #ffffff11,0 0 0 56px #ffffff04;
}
.account-identity, #member-balance { display: grid; gap: 3px; min-width: 0; }
#member-tier, #member-balance > span { font-size: 12px; color: #e0dcec; line-height: 1.5; }
#member-name { font-size: 19px; font-weight: 650; overflow-wrap: anywhere; }
#member-balance { grid-column: 2; grid-row: 1 / 3; text-align: right; }
#credit-count { font-size: clamp(25px,5vw,38px); line-height: 1.08; font-variant-numeric: tabular-nums; }
.account-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.account-links a, .account-links #logout {
  min-height: 28px; display: inline-flex; align-items: center; padding: 0;
  color: #ece8f7; background: transparent; border: 0; border-radius: 3px; font-size: 12px;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #aba3bd;
}
.account-links #logout:hover, .account-links a:hover { color: white; background: transparent; text-decoration-color: currentColor; }
.member-section { margin-top: 22px; }
.member-section h3 { font-size: 16px; margin: 0 0 10px; }
.member-section p.section-note { margin: 8px 0; font-size: 12px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.history-tabs {
  display: flex; align-items: end; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.history-tabs button {
  padding: 6px 0 9px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); background: transparent;
}
.history-tabs button[aria-selected=true] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.member-list { min-width: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.member-list:not(:has(.member-row)) { padding: 12px 14px; border-radius: 8px; background: #f7f7fa; }
.member-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "name action" "meta action";
  column-gap: 14px; row-gap: 4px; align-items: center; padding: 13px 0;
}
.member-row + .member-row { border-top: 1px solid var(--line); }
.record-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 14px; font-weight: 650; }
.record-meta { grid-area: meta; display: flex; align-items: baseline; gap: 2px 10px; flex-wrap: wrap; min-width: 0; font-size: 12px; }
.record-meta span { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.plan-price { grid-area: price; font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-action { grid-area: action; justify-self: end; color: var(--accent); font-weight: 600; }
.row-actions { grid-area: action; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.row-actions .row-action + .row-action { color: var(--muted); font-weight: 400; }
#plans-list { display: grid; gap: 8px; }
#plans-list .member-row {
  grid-template-columns: minmax(0,1fr) auto auto; grid-template-areas: "name price action" "meta price action";
  border: 1px solid #ddd8ea; border-radius: 10px; padding: 13px 15px; background: #faf9fd;
}
#plans-list .row-action { color: white; background: var(--accent); border-color: var(--accent); }
#plans-list .row-action:hover { color: white; background: #43335f; }
#orders-list .member-row { grid-template-areas: "name price" "meta price"; }
#exports-list .member-row:not(:has(.row-action)) { grid-template-columns: minmax(0,1fr); grid-template-areas: "name" "meta"; }
.pager { justify-content: flex-end; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pager button:disabled { cursor: default; }
.account-admin { width: min(100%,1360px); margin: 26px auto; padding: 0 clamp(14px,3vw,44px); }
.account-admin > #notice:not(:empty) { position: sticky; top: 8px; z-index: 2; margin-block: 10px; }
#notice:empty { margin: 0; }
.account-admin .panel { padding: clamp(16px,3vw,28px); }
#login { max-width: 440px; margin: clamp(32px,8vh,80px) auto; gap: 18px; }
#login h2 { text-align: center; }
.admin-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-block: 16px; }
.admin-tabs { align-items: center; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-tabs button { border-color: transparent; color: var(--muted); }
.admin-tabs button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
#search input { min-width: min(240px,100%); }
#new-plan label { flex: 1 1 110px; }
.admin-table { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.admin-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.visit-totals { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 12px; }
.visit-totals > div { background: var(--accent-soft); border-radius: 8px; padding: 14px; }
.visit-totals dt, #visit-report p { color: var(--muted); font-size: 13px; }
.visit-totals dd { margin: 4px 0 0; font-size: 25px; font-weight: 650; font-variant-numeric: tabular-nums; }
.admin-table th { color: var(--muted); font-size: 12px; font-weight: 600; background: #f7f7fa; }
.admin-table td, .admin-table th { padding: 10px 12px; white-space: nowrap; }
.admin-table tbody tr + tr td { border-top: 1px solid var(--line); }
.admin-table thead th { border-bottom: 1px solid var(--line); }
.admin-table tbody tr:hover { background: #faf9fd; }
.admin-table button { color: var(--accent); }
.account-admin dialog { width: min(430px,92vw); }
.account-admin dialog p { margin: 0; overflow-wrap: anywhere; }
#action-form > div:last-child { display: flex; justify-content: flex-end; gap: 8px; }
.template .seal-thumb { width:40px; height:40px; flex:none; display:block; background-image:url(/api/thumbnails); background-repeat:no-repeat; }
@media (max-width: 650px) {
  .template .seal-thumb { width: 28px; height: 28px; }
  .account-button { padding: 6px 10px; font-size: 12px; }
  .brand h1 { font-size: 16px; }
  .admin-tabs { gap: 2px; }
  .admin-tabs button { padding: 6px 9px; }
}
@media (max-width: 440px) {
  .account-summary { padding: 16px; column-gap: 12px; }
  .member-notifications > header { padding-block: 10px; }
  .member-section { margin-top: 18px; }
  #plans-list .member-row { grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "name price" "meta action"; padding: 10px 12px; }
  .plan-price { justify-self: end; font-size: 17px; }
  #exports-list .member-row:has(.row-action) { grid-template-areas: "name name" "meta action"; }
  #new-plan label { flex-basis: 44%; }
}

.checkout { padding: 20px var(--gutter) 24px; overflow-wrap: anywhere; }
.checkout h3, .checkout p { margin: 0 0 7px; }
#checkout-terms, #checkout-number, .checkout small { color: var(--muted); font-size: 13px; }
#checkout-price { display: block; margin: 4px 0; font-size: 28px; font-variant-numeric: tabular-nums; }
.checkout-steps { display: flex; list-style: none; gap: 4px; padding: 0; margin: 18px 0; counter-reset: step; }
.checkout-steps li { flex: 1; padding: 8px 0; font-size: 13px; border-bottom: 2px solid var(--line); color: var(--muted); }
.checkout-steps li::before { counter-increment: step; content: counter(step) ". "; }
.checkout-steps [aria-current] { color: var(--accent); border-color: var(--accent); font-weight: bold; }
#checkout-state { margin: 10px 0 15px; }
#checkout-pay, #checkout-upload, .checkout label { display: grid; gap: 10px; }
.checkout select, .checkout input { width: 100%; padding: 8px; }
.payment-qr { display: block; width: min(235px, 100%); height: 235px; object-fit: contain; margin: 4px auto; }
.checkout-actions, .review-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#checkout-proof { display: block; margin: 8px 0; }
#checkout-done { margin-top: 12px; }
#orders-list .member-row { grid-template-areas: "name price" "meta action"; }
@media (max-width: 440px) {
  #orders-list .member-row { grid-template-areas: "name price" "meta meta" "action action"; }
}
.code-settings { padding: 12px 0; border-block-end: 1px solid var(--line); }
.code-settings img, #review-preview { display: block; max-width: 100%; max-height: 200px; object-fit: contain; }
.code-gallery { display: flex; gap: 16px; flex-wrap: wrap; }
.code-gallery figure { margin: 0; }
.code-gallery img { width: 100px; height: 100px; }
.account-admin dialog { max-height: 90dvh; overflow: auto; }
.checkout [hidden], #checkout[hidden], .account-admin [hidden] { display: none !important; }
