.portal-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 4%, rgba(220, 239, 231, 0.9), transparent 34rem),
    linear-gradient(145deg, #f7faf8 0%, #f3f7f5 52%, #edf4f1 100%);
}

.portal-body [hidden] {
  display: none !important;
}

.portal-body a {
  color: var(--brand-dark);
  font-weight: 700;
  text-underline-offset: 3px;
}

.portal-body a:hover {
  color: var(--brand);
}

.portal-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.88fr) minmax(480px, 1.12fr);
  min-height: 100vh;
}

.portal-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(34px, 6vw, 78px);
  background: linear-gradient(150deg, #eaf5f0 0%, #f5f9f7 64%, #fff9ef 100%);
}

.portal-brand-panel::after {
  position: absolute;
  right: -110px;
  bottom: -120px;
  width: 350px;
  height: 350px;
  border: 64px solid rgba(18, 102, 83, 0.08);
  border-radius: 50%;
  content: "";
}

.portal-brand-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 12px;
  color: var(--ink) !important;
  text-decoration: none;
}

.portal-brand-link .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.portal-brand-link strong,
.portal-brand-link small {
  display: block;
  line-height: 1.3;
}

.portal-brand-link strong {
  font-size: 16px;
}

.portal-brand-link small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.portal-brand-copy {
  position: relative;
  z-index: 1;
  max-width: 590px;
  margin: clamp(70px, 12vh, 150px) 0 56px;
}

.portal-kicker {
  margin-bottom: 14px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.portal-brand-copy h1 {
  max-width: 10em;
  margin-bottom: 22px;
  font-size: clamp(36px, 4.6vw, 62px);
  line-height: 1.18;
}

.portal-brand-copy > p:not(.portal-kicker) {
  max-width: 37em;
  margin-bottom: 0;
  color: #3f5149;
  font-size: 16px;
}

.portal-feature-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-feature-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border: 1px solid rgba(18, 102, 83, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
  padding: 9px 12px;
  color: #30453c;
  font-size: 13px;
  font-weight: 700;
}

.portal-feature-list li::before {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  content: "✓";
  font-size: 11px;
  font-weight: 900;
}

.portal-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(30px, 7vw, 94px);
}

.portal-form-card {
  width: min(100%, 570px);
  margin: auto;
}

.portal-form-card.compact-card {
  width: min(100%, 500px);
}

.portal-form-heading {
  margin-bottom: 28px;
}

.portal-form-heading h2,
.portal-form-heading h1 {
  margin-bottom: 9px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.3;
}

.portal-form-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.portal-form {
  display: grid;
  gap: 20px;
}

.portal-field {
  display: grid;
  gap: 7px;
}

.portal-field > span:first-child,
.portal-field legend {
  color: #293c33;
  font-size: 13px;
  font-weight: 800;
}

.portal-field input,
.portal-field select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 11px 14px;
  color: var(--ink);
}

.portal-field input::placeholder {
  color: #7d8983;
}

.portal-field input:hover {
  border-color: #9fb1a8;
}

.portal-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(18, 102, 83, 0.1);
  outline: 0;
}

.portal-field small {
  color: var(--muted);
  font-size: 12px;
}

.portal-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.password-control {
  position: relative;
}

.password-control input {
  padding-right: 78px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  min-width: 64px;
  min-height: 36px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.password-toggle:hover {
  background: var(--brand-soft);
}

.portal-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #394b42;
  font-size: 13px;
}

.portal-check input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--brand);
}

.portal-check > span {
  flex: 1 1 auto;
  min-width: 0;
}

.portal-primary-btn,
.portal-secondary-btn,
.portal-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 800;
  text-decoration: none !important;
}

.portal-primary-btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(18, 102, 83, 0.16);
}

.portal-primary-btn:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
}

.portal-secondary-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink) !important;
}

.portal-secondary-btn:hover {
  border-color: var(--brand);
  background: var(--surface-accent);
}

.portal-text-btn {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--brand-dark) !important;
  padding-right: 10px;
  padding-left: 10px;
}

.portal-primary-btn[aria-busy="true"],
.portal-secondary-btn[aria-busy="true"] {
  cursor: wait;
}

.portal-primary-btn[aria-busy="true"]::before,
.portal-secondary-btn[aria-busy="true"]::before {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: portal-spin 700ms linear infinite;
}

@keyframes portal-spin {
  to { transform: rotate(360deg); }
}

.portal-form-footer {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.portal-help {
  margin: 22px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.portal-notice {
  margin-bottom: 20px;
  border: 1px solid #e1a49e;
  border-radius: 12px;
  background: var(--danger-soft);
  padding: 12px 14px;
  color: #7c2c25;
  font-size: 13px;
  font-weight: 700;
}

.portal-notice[data-tone="success"] {
  border-color: #afd3c7;
  background: #eef8f4;
  color: var(--brand-dark);
}

.portal-notice[data-tone="info"] {
  border-color: #c7d8d0;
  background: var(--surface-soft);
  color: #34473e;
}

.portal-notice:empty,
.portal-notice[hidden] {
  display: none;
}

.portal-signup-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 620px);
  gap: clamp(30px, 7vw, 96px);
  width: min(1160px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 64px;
}

.signup-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 0;
}

.signup-intro-copy {
  margin: 80px 0 60px;
}

.signup-intro-copy h1 {
  max-width: 11em;
  margin-bottom: 20px;
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.18;
}

.signup-intro-copy > p:last-of-type {
  max-width: 35em;
  color: var(--muted);
}

.signup-steps {
  display: grid;
  gap: 12px;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: signup-step;
}

.signup-steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: center;
  color: #33483e;
  font-size: 14px;
  font-weight: 700;
  counter-increment: signup-step;
}

.signup-steps li::before {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #bdd3c9;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand-dark);
  content: counter(signup-step);
  font-size: 12px;
  font-weight: 900;
}

.signup-card {
  align-self: center;
  border: 1px solid rgba(188, 201, 194, 0.82);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  padding: clamp(25px, 4vw, 44px);
  box-shadow: var(--shadow-md);
}

.signup-card .portal-form-heading h2 {
  font-size: 30px;
}

.signup-plan-picker {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
}

.signup-plan-picker > legend {
  margin-bottom: 2px;
  color: #293c33;
  font-size: 13px;
  font-weight: 800;
}

.signup-plan-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 11px;
  align-items: start;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.signup-plan-option:hover {
  border-color: #91ab9f;
}

.signup-plan-option.is-selected {
  border-color: var(--brand);
  background: #f1f8f5;
  box-shadow: 0 0 0 3px rgba(18, 102, 83, 0.08);
}

.signup-plan-option > input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--brand);
}

.signup-plan-copy {
  display: block;
}

.signup-plan-copy > span {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  align-items: center;
}

.signup-plan-copy strong {
  color: var(--ink);
  font-size: 15px;
}

.signup-plan-copy b {
  margin-left: auto;
  color: var(--brand-dark);
  font-size: 15px;
}

.signup-plan-copy em {
  border-radius: 999px;
  background: var(--brand);
  padding: 3px 8px;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.signup-plan-copy small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.signup-plan-copy small.signup-plan-billed,
.signup-selected-billed {
  color: var(--ink);
  font-weight: 900;
}

.signup-price-summary {
  display: grid;
  grid-template-columns: minmax(190px, 0.82fr) minmax(0, 1.18fr);
  gap: 18px;
  align-items: center;
  border: 1px solid #c8dcd3;
  border-radius: 14px;
  background: #f1f8f5;
  padding: 17px 18px;
}

.signup-price-summary small,
.signup-price-summary strong {
  display: block;
}

.signup-price-summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.signup-price-summary strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
}

.signup-price-summary strong span {
  display: block;
  color: var(--brand-dark);
  font-size: 22px;
  line-height: 1.35;
}

.signup-price-summary ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 20px;
  color: #405249;
  font-size: 12px;
}

.signup-complete {
  display: grid;
  gap: 20px;
}

.signup-complete[hidden] {
  display: none;
}

.complete-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 26px;
  font-weight: 900;
}

.signup-complete h2 {
  margin-bottom: 7px;
  font-size: 30px;
}

.signup-complete p {
  margin-bottom: 0;
  color: var(--muted);
}

.billing-card {
  border: 1px solid #d9c79d;
  border-radius: 14px;
  background: #fffaf0;
  padding: 18px;
}

.billing-card strong,
.billing-card small {
  display: block;
}

.billing-card small {
  margin-top: 5px;
  color: #665b44;
}

.completion-actions {
  display: grid;
  gap: 10px;
}

.billing-result-shell {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 30px;
  width: min(100% - 32px, 650px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 38px 0;
}

.billing-result-shell .portal-brand-link {
  justify-self: start;
}

.billing-result-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  padding: clamp(28px, 6vw, 54px);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.billing-result-card h1 {
  margin-bottom: 14px;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.3;
}

.billing-result-card > p:not(.portal-kicker) {
  max-width: 36em;
  margin: 0 auto;
  color: var(--muted);
}

.billing-result-icon {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: 0 auto 22px;
  border-radius: 22px;
  font-size: 30px;
  font-weight: 900;
}

.billing-result-icon.is-success {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.billing-result-icon.is-cancel {
  background: var(--accent-soft);
  color: #86550c;
}

.billing-result-note {
  margin: 26px 0 22px;
  border: 1px solid #c8ddd4;
  border-radius: 14px;
  background: #f1f8f5;
  padding: 16px;
  color: #33483f;
  text-align: left;
}

.billing-result-note.is-cancel {
  border-color: #e8d1a3;
  background: #fffaf0;
}

.billing-result-note strong,
.billing-result-note p {
  display: block;
}

.billing-result-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.billing-result-actions {
  display: grid;
  gap: 10px;
}

/* Existing application account menu */
.account-menu {
  position: relative;
  flex: 0 0 auto;
  margin-left: 10px;
}

.account-menu > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  max-width: 190px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 5px 9px 5px 6px;
  list-style: none;
}

.account-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu > summary::after {
  color: var(--muted);
  content: "▾";
  font-size: 10px;
}

.account-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.account-summary-copy {
  overflow: hidden;
  min-width: 0;
}

.account-summary-copy strong,
.account-summary-copy small {
  display: block;
  overflow: hidden;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary-copy strong {
  font-size: 11px;
}

.account-summary-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 130;
  display: grid;
  width: 250px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow-md);
}

.account-popover p {
  overflow: hidden;
  margin: 0 4px 8px;
}

.account-popover p small,
.account-popover p strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-popover p small {
  color: var(--muted);
  font-size: 10px;
}

.account-popover p strong {
  font-size: 12px;
}

.account-popover a,
.account-popover button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 9px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

.account-popover a:hover,
.account-popover button:hover {
  background: var(--surface-soft);
}

.account-menu-status {
  color: var(--danger) !important;
  font-size: 10px !important;
}

/* Administration */
.admin-body {
  background: var(--canvas);
}

.portal-admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  padding: 10px max(24px, calc((100vw - 1220px) / 2));
  backdrop-filter: blur(16px);
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.admin-header-user {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-header-actions .portal-secondary-btn,
.admin-header-actions .portal-text-btn {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 12px;
}

.admin-main {
  width: min(1220px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.admin-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.admin-title-row h1 {
  margin-bottom: 7px;
  font-size: clamp(30px, 4vw, 44px);
}

.admin-title-row p {
  margin-bottom: 0;
  color: var(--muted);
}

.read-only-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 34px;
  border: 1px solid #bfd5ca;
  border-radius: 999px;
  background: var(--brand-soft);
  padding: 6px 12px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
}

.admin-client-switcher {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(420px, 1.1fr);
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
  border: 1px solid #b7d8ca;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #eff9f5 0%, #fff 72%);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.admin-client-switcher-copy h2 {
  margin-bottom: 5px;
  font-size: 21px;
}

.admin-client-switcher-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-client-switcher-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.admin-client-switcher-form label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.admin-client-switcher-form label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.admin-client-switcher-form select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #fff;
  padding: 9px 34px 9px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.admin-client-switcher-form select:focus-visible {
  outline: 3px solid rgba(30, 113, 86, 0.2);
  outline-offset: 2px;
}

.admin-client-switcher-form .portal-primary-btn {
  min-height: 46px;
  padding: 9px 16px;
  white-space: nowrap;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.admin-summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.admin-summary-card small,
.admin-summary-card strong,
.admin-summary-card span {
  display: block;
}

.admin-summary-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-summary-card strong {
  margin: 5px 0 3px;
  font-size: 32px;
  line-height: 1.2;
}

.admin-summary-card span {
  color: var(--muted);
  font-size: 11px;
}

.admin-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.admin-panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 22px 24px 18px;
}

.admin-panel-head h2 {
  margin-bottom: 3px;
  font-size: 21px;
}

.admin-panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.admin-filters label {
  display: grid;
  gap: 3px;
}

.admin-filters label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.admin-filters input,
.admin-filters select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 7px 11px;
  color: var(--ink);
  font-size: 12px;
}

.admin-invite-form {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-invite-form label:first-child input {
  min-width: 230px;
}

.admin-compact-btn {
  min-height: 38px;
  border-radius: 10px;
  box-shadow: none;
  padding: 7px 11px;
  font-size: 11px;
  line-height: 1.35;
}

.admin-invite-form .admin-compact-btn {
  align-self: end;
}

.admin-issued-code {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, auto) auto;
  align-items: center;
  gap: 16px;
  margin: 18px 24px;
  border: 1px solid #afd3c7;
  border-radius: 14px;
  background: #eef8f4;
  padding: 16px;
}

.admin-issued-code[hidden] {
  display: none;
}

.admin-issued-code strong,
.admin-issued-code span,
.admin-issued-code small {
  display: block;
}

.admin-issued-code span {
  margin-top: 3px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.admin-issued-code small {
  max-width: 52em;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.admin-issued-code code {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 10px 13px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  user-select: all;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.admin-row-actions .admin-compact-btn[data-tone="danger"] {
  border-color: #dfaaa4;
  background: #fff7f6;
  color: #8b3029 !important;
}

.admin-application-actions {
  min-width: 230px;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e7ece9;
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: #f8faf9;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

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

.admin-table tbody tr:hover {
  background: #fbfdfc;
}

.admin-table-primary {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.admin-table-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #edf1ef;
  padding: 4px 9px;
  color: #46564e;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge[data-tone="success"] {
  background: #e3f3ed;
  color: #17634f;
}

.status-badge[data-tone="warning"] {
  background: #fff2d8;
  color: #81530a;
}

.status-badge[data-tone="danger"] {
  background: #ffebe8;
  color: #9a312a;
}

.status-badge[data-tone="info"] {
  background: #e9f1f7;
  color: #315e7a;
}

.admin-empty-cell {
  height: 110px;
  color: var(--muted);
  text-align: center !important;
}

.admin-panel-foot {
  border-top: 1px solid var(--line);
  padding: 11px 16px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.admin-refresh-actions {
  margin-top: 22px;
}

.admin-access-state {
  display: grid;
  place-items: center;
  min-height: 48vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 42px;
  text-align: center;
}

.admin-access-state[hidden] {
  display: none;
}

.admin-access-state h1 {
  margin-bottom: 10px;
  font-size: 28px;
}

.admin-access-state p {
  max-width: 38em;
  margin-bottom: 20px;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .app-header .account-menu {
    position: absolute;
    top: 12px;
    right: 20px;
  }

  body.is-impersonating .app-header .account-menu {
    top: 58px;
  }

  .portal-layout {
    grid-template-columns: minmax(300px, 0.78fr) minmax(430px, 1.22fr);
  }

  .portal-brand-copy h1 {
    font-size: 42px;
  }

  .portal-feature-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .portal-layout {
    display: block;
  }

  .portal-brand-panel {
    min-height: auto;
    padding: 24px;
  }

  .portal-brand-panel::after,
  .portal-feature-list {
    display: none;
  }

  .portal-brand-copy {
    margin: 46px 0 10px;
  }

  .portal-brand-copy h1 {
    max-width: 14em;
    margin-bottom: 12px;
    font-size: 34px;
  }

  .portal-form-panel {
    padding: 38px 24px 54px;
  }

  .portal-signup-shell {
    display: block;
    width: min(100% - 32px, 620px);
    padding: 24px 0 48px;
  }

  .signup-intro {
    padding: 0;
  }

  .signup-intro-copy {
    margin: 44px 0 32px;
  }

  .signup-intro-copy h1 {
    font-size: 38px;
  }

  .signup-steps {
    margin-bottom: 30px;
  }

  .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  .admin-client-switcher {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .admin-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-filters {
    display: grid;
    grid-template-columns: 1fr 150px;
  }

  .admin-issued-code {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-header .account-menu {
    position: relative;
    top: auto;
    right: auto;
    grid-column: 1 / -1;
    justify-self: end;
    margin: -5px 0 4px;
  }

  body.is-impersonating .app-header .account-menu {
    position: relative;
    top: auto;
    right: auto;
  }

  .account-menu > summary {
    max-width: min(220px, 70vw);
  }

  .portal-admin-header {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .portal-admin-header .portal-brand-link small,
  .admin-header-user {
    display: none;
  }

  .admin-header-actions {
    align-items: flex-end;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .admin-header-actions .portal-secondary-btn {
    display: none;
  }

  .admin-main {
    width: min(100% - 24px, 650px);
    padding: 30px 0 56px;
  }

  .admin-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .admin-client-switcher {
    padding: 19px 18px;
  }

  .admin-client-switcher-form {
    grid-template-columns: 1fr;
  }

  .admin-client-switcher-form .portal-primary-btn {
    width: 100%;
  }

  .admin-table-wrap {
    overflow: visible;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .admin-table tr {
    border-bottom: 8px solid var(--surface-soft);
    padding: 10px 14px;
  }

  .admin-table td {
    display: grid;
    grid-template-columns: minmax(88px, 0.38fr) minmax(0, 1fr);
    gap: 12px;
    border: 0;
    padding: 7px 0;
  }

  .admin-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 800;
  }

  .admin-table .admin-empty-cell {
    display: block;
    height: auto;
    padding: 28px 4px;
  }

  .admin-table .admin-empty-cell::before {
    content: none;
  }

  .admin-panel-foot {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .portal-field-row {
    grid-template-columns: 1fr;
  }

  .portal-brand-panel,
  .portal-form-panel {
    padding-right: 18px;
    padding-left: 18px;
  }

  .portal-brand-copy h1,
  .signup-intro-copy h1 {
    font-size: 31px;
  }

  .signup-card {
    padding: 24px 18px;
  }

  .signup-price-summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .admin-filters {
    grid-template-columns: 1fr;
  }

  .portal-admin-header .brand-mark {
    width: 34px;
    height: 34px;
  }

  .admin-header-actions .portal-text-btn {
    min-height: 38px;
    padding: 6px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-primary-btn[aria-busy="true"]::before,
  .portal-secondary-btn[aria-busy="true"]::before {
    animation-duration: 1400ms;
  }
}

.terms-shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 42px 0 72px;
}

.terms-header {
  margin-bottom: 24px;
}

.terms-header .portal-brand-link {
  margin-bottom: 42px;
}

.terms-header h1 {
  margin: 8px 0 10px;
  color: var(--ink);
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.15;
}

.terms-header > p:last-child,
.terms-lead {
  color: var(--muted);
}

.terms-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.98);
  padding: clamp(24px, 5vw, 54px);
  box-shadow: var(--shadow-md);
}

.terms-card section + section {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.terms-card h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 20px;
}

.terms-card p,
.terms-card li {
  color: #394b42;
  font-size: 14px;
  line-height: 1.9;
}

.terms-card ol {
  margin: 0;
  padding-left: 1.6em;
}

.terms-card a,
.portal-check a {
  color: var(--brand-dark);
  font-weight: 800;
}

.terms-actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.terms-actions .portal-primary-btn {
  min-width: 240px;
}

.account-main {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 48px 0 72px;
}

.account-page-heading {
  margin-bottom: 28px;
}

.account-page-heading h1 {
  margin: 8px 0 10px;
  color: var(--ink);
  font-size: clamp(34px, 6vw, 52px);
}

.account-page-heading > p:last-child,
.account-plan-card p,
.account-action-list p,
.account-action-help,
.account-contract-note {
  color: var(--muted);
}

.account-plan-card,
.account-usage-card,
.account-detail-card,
.account-pending-card,
.account-actions-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.98);
  padding: clamp(22px, 4vw, 34px);
  box-shadow: var(--shadow-sm);
}

.account-plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-color: rgba(18, 102, 83, 0.38);
  background: linear-gradient(135deg, #fff 0%, #eef8f3 100%);
}

.account-plan-card small,
.account-usage-card small {
  color: var(--brand-dark);
  font-weight: 900;
}

.account-plan-card h2,
.account-usage-card h2 {
  margin: 5px 0 7px;
  color: var(--ink);
  font-size: 30px;
}

.account-price-summary {
  flex: 0 0 auto;
  text-align: right;
}

.account-price-summary > strong,
.account-price-summary > small {
  display: block;
}

.account-price-summary > strong {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-size: 24px;
  white-space: nowrap;
}

.account-price-summary > small {
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.account-usage-card,
.account-detail-card,
.account-pending-card,
.account-actions-card {
  margin-top: 18px;
}

.account-usage-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--brand-soft);
}

.account-usage-card p {
  color: var(--brand-dark);
  font-weight: 800;
}

.account-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.account-section-head h2,
.account-pending-card h2,
.billing-confirm-dialog h2 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 23px;
}

.account-section-head > a {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.account-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.account-detail-list > div {
  padding: 16px 18px;
}

.account-detail-list > div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.account-detail-list > div:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.account-detail-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.account-detail-list dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.account-contract-note,
.account-action-help {
  margin: 16px 0 0;
  font-size: 12px;
}

.account-pending-card {
  border-color: #e4cf99;
  background: #fffaf0;
}

.account-pending-card p:last-child {
  margin-top: 10px;
  color: #604a17;
  font-weight: 700;
}

.account-action-list {
  display: grid;
  gap: 12px;
}

.account-action-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.account-action-list h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 16px;
}

.account-action-list p {
  margin: 0;
  font-size: 12px;
}

.portal-danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid #b8443d;
  border-radius: 12px;
  background: #fff;
  padding: 10px 18px;
  color: #a12e28;
  font-size: 13px;
  font-weight: 900;
}

.portal-danger-btn:hover {
  background: #fff4f3;
}

.portal-danger-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.billing-confirm-dialog {
  width: min(100% - 32px, 560px);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
}

.billing-confirm-dialog::backdrop {
  background: rgba(20, 33, 27, 0.48);
  backdrop-filter: blur(3px);
}

.billing-confirm-dialog form {
  padding: clamp(24px, 5vw, 38px);
}

.billing-confirm-dialog > form > p:not(.portal-kicker) {
  margin-top: 12px;
  color: var(--muted);
}

.billing-confirm-points {
  margin-top: 18px;
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 14px 18px;
}

.billing-confirm-points ul {
  margin: 0;
  padding-left: 1.4em;
  color: #394b42;
  font-size: 13px;
  line-height: 1.8;
}

@media (max-width: 640px) {
  .account-main,
  .terms-shell {
    width: min(100% - 24px, 920px);
    padding-top: 30px;
  }

  .account-plan-card,
  .account-usage-card,
  .account-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-price-summary {
    text-align: left;
  }

  .account-price-summary > strong {
    font-size: 22px;
  }

  .account-detail-list {
    grid-template-columns: 1fr;
  }

  .account-detail-list > div:nth-child(odd) {
    border-right: 0;
  }

  .account-detail-list > div + div {
    border-top: 1px solid var(--line);
  }

  .account-action-list article {
    grid-template-columns: 1fr;
  }

  .account-action-list button,
  .billing-confirm-dialog .completion-actions button {
    width: 100%;
  }
}
