/* Rail Proof customer dashboard — design system layer.
   Loaded after app.css; everything is scoped to .portal-shell so the public
   site is untouched. */

.portal-shell {
  --p-bg: #07080a;
  --p-surface: #0d0f12;
  --p-surface-2: #12151a;
  --p-surface-3: #181c22;
  --p-line: #1f242b;
  --p-line-strong: #2b313a;
  --p-text: #eceef1;
  --p-muted: #8b929c;
  --p-faint: #5c636d;
  --p-gold: #d7ad4a;
  --p-gold-soft: rgba(215, 173, 74, 0.12);
  --p-green: #5fd08a;
  --p-green-soft: rgba(95, 208, 138, 0.1);
  --p-amber: #f0b44c;
  --p-red: #f07a7a;
  --p-red-soft: rgba(240, 122, 122, 0.1);
  --p-radius: 14px;
  --p-radius-sm: 9px;
  --p-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  min-height: 100vh;
  padding: 0 clamp(16px, 3vw, 40px) 64px;
  background:
    radial-gradient(1200px 400px at 70% -120px, rgba(215, 173, 74, 0.06), transparent 70%),
    var(--p-bg);
  color: var(--p-text);
  font-size: 14px;
  line-height: 1.5;
}

.portal-shell *,
.portal-shell *::before,
.portal-shell *::after {
  box-sizing: border-box;
}

/* ---------- Top bar ---------- */
.portal-shell .portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 calc(-1 * clamp(16px, 3vw, 40px));
  padding: 14px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--p-line);
  background: rgba(7, 8, 10, 0.86);
  backdrop-filter: blur(12px);
}

.portal-shell .portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--p-text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.portal-shell .portal-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
  flex: none;
}

.portal-shell .portal-account {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-shell .portal-account form {
  margin: 0;
}

.portal-shell .portal-account-org {
  display: grid;
  justify-items: end;
  line-height: 1.25;
}

.portal-shell .portal-account-org strong {
  font-size: 13px;
  font-weight: 600;
}

.portal-shell .portal-account-org small {
  color: var(--p-muted);
  font-size: 11px;
}

/* ---------- Page header ---------- */
.portal-shell .portal-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 32px 0 24px;
}

.portal-shell .portal-hero h1 {
  margin: 6px 0 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.portal-shell .portal-kicker {
  margin: 0;
  color: var(--p-gold);
  font: 500 11px/1 var(--p-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.portal-shell .portal-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Pills ---------- */
.portal-shell .status-pill,
.portal-shell .plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--p-line-strong);
  border-radius: 999px;
  background: var(--p-surface-2);
  color: var(--p-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.portal-shell .status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.portal-shell .status-pill.status-active {
  border-color: rgba(95, 208, 138, 0.35);
  background: var(--p-green-soft);
  color: var(--p-green);
}

.portal-shell .status-pill.status-trialing {
  border-color: rgba(215, 173, 74, 0.35);
  background: var(--p-gold-soft);
  color: var(--p-gold);
}

.portal-shell .status-pill.status-past_due,
.portal-shell .status-pill.status-cancelled {
  border-color: rgba(240, 122, 122, 0.35);
  background: var(--p-red-soft);
  color: var(--p-red);
}

.portal-shell .plan-pill {
  color: var(--p-text);
}

/* ---------- Alerts ---------- */
.portal-shell .portal-alert,
.portal-shell .portal-secret {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid rgba(95, 208, 138, 0.3);
  border-radius: var(--p-radius-sm);
  background: var(--p-green-soft);
  color: #c9f0d6;
  font-size: 13px;
}

.portal-shell .portal-alert.error {
  border-color: rgba(240, 122, 122, 0.3);
  background: var(--p-red-soft);
  color: #f7caca;
}

.portal-shell .portal-secret {
  border-color: rgba(215, 173, 74, 0.35);
  background: var(--p-gold-soft);
  color: var(--p-text);
}

.portal-shell .portal-secret code {
  display: block;
  margin-top: 8px;
  color: var(--p-gold);
  font-family: var(--p-mono);
  overflow-wrap: anywhere;
}

/* ---------- Layout ---------- */
.portal-shell .portal-dashboard-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.portal-shell .portal-navigation {
  position: sticky;
  top: 76px;
  overflow: hidden;
  border: 1px solid var(--p-line);
  border-radius: var(--p-radius);
  background: var(--p-surface);
}

.portal-shell .portal-navigation-heading {
  display: grid;
  gap: 2px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--p-line);
}

.portal-shell .portal-navigation-heading small,
.portal-shell .portal-nav-group {
  margin: 0;
  color: var(--p-faint);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.portal-shell .portal-navigation-heading strong {
  font-size: 14px;
  font-weight: 600;
}

.portal-shell .portal-navigation nav {
  display: grid;
  gap: 2px;
  padding: 8px;
}

.portal-shell .portal-nav-group {
  padding: 12px 10px 6px;
}

.portal-shell .portal-navigation nav a {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--p-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.portal-shell .portal-navigation nav a span {
  color: var(--p-faint);
  font: 10px var(--p-mono);
}

.portal-shell .portal-navigation nav a:hover {
  background: var(--p-surface-2);
  color: var(--p-text);
}

.portal-shell .portal-navigation nav a.active {
  background: var(--p-surface-3);
  box-shadow: inset 2px 0 0 var(--p-gold);
  color: var(--p-text);
  font-weight: 600;
}

.portal-shell .portal-navigation nav a.active span {
  color: var(--p-gold);
}

.portal-shell .portal-navigation-footer {
  display: grid;
  gap: 8px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--p-line);
  color: var(--p-muted);
  font-size: 12px;
  text-decoration: none;
}

.portal-shell .portal-navigation-footer > span:first-child {
  color: var(--p-faint);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.portal-shell .portal-navigation-footer strong {
  color: var(--p-text);
  font-size: 12px;
  font-weight: 600;
}

.portal-shell .portal-dashboard-content {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.portal-shell .portal-dashboard-content > [data-portal-page] + [data-portal-page],
.portal-shell .portal-dashboard-content > [data-portal-page]:first-child {
  margin-top: 0;
}

.portal-shell .portal-dashboard-content > [hidden],
.portal-shell .portal-grid > [hidden] {
  display: none !important;
}

.portal-shell .portal-grid {
  display: grid;
  gap: 20px;
  margin: 0;
}

.portal-shell .portal-grid:not(:has(> :not([hidden]))) {
  display: none;
}

/* ---------- Cards and headings ---------- */
.portal-shell .portal-card {
  padding: 24px;
  border: 1px solid var(--p-line);
  border-radius: var(--p-radius);
  background: var(--p-surface);
}

.portal-shell .portal-card > small,
.portal-shell .portal-heading small,
.portal-shell .portal-onboarding > div > small {
  display: block;
  color: var(--p-gold);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.portal-shell .portal-card h2 {
  margin: 6px 0 12px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.portal-shell .portal-card h3 {
  margin: 6px 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.portal-shell .portal-card p {
  line-height: 1.6;
}

.portal-shell .portal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 4px;
}

.portal-shell .portal-card .portal-heading:not(:first-child) {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--p-line);
}

.portal-shell .portal-heading h2,
.portal-shell .portal-heading h3 {
  margin-bottom: 0;
}

.portal-shell .portal-heading > a,
.portal-shell .portal-heading > span:not(.status-pill) {
  flex-shrink: 0;
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell .portal-muted,
.portal-shell .portal-card > div > p {
  margin: 8px 0 16px;
  color: var(--p-muted);
  font-size: 13px;
}

.portal-shell hr {
  margin: 28px 0;
  border: 0;
  border-top: 1px solid var(--p-line);
}

/* ---------- Buttons and links ---------- */
.portal-shell button,
.portal-shell .portal-button,
.portal-shell .key-actions a,
.portal-shell .portal-heading > a,
.portal-shell .exchange-guidance a,
.portal-shell .history-public-link a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--p-text);
  border-radius: 8px;
  background: var(--p-text);
  color: var(--p-bg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.portal-shell button:hover,
.portal-shell .portal-button:hover {
  background: #fff;
  border-color: #fff;
}

.portal-shell .portal-button.secondary,
.portal-shell .key-actions a,
.portal-shell .portal-heading > a,
.portal-shell .exchange-guidance a,
.portal-shell .history-public-link a,
.portal-shell .portal-table button,
.portal-shell .key-actions button,
.portal-shell .supersession-control button {
  border-color: var(--p-line-strong);
  background: var(--p-surface-2);
  color: var(--p-text);
}

.portal-shell .portal-button.secondary:hover,
.portal-shell .key-actions a:hover,
.portal-shell .portal-heading > a:hover,
.portal-shell .exchange-guidance a:hover,
.portal-shell .history-public-link a:hover,
.portal-shell .portal-table button:hover,
.portal-shell .key-actions button:hover,
.portal-shell .supersession-control button:hover {
  border-color: #3b424d;
  background: var(--p-surface-3);
  color: #fff;
}

.portal-shell .portal-button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--p-muted);
}

.portal-shell .portal-button.ghost:hover {
  border-color: var(--p-line-strong);
  background: var(--p-surface-2);
  color: var(--p-text);
}

.portal-shell button.danger,
.portal-shell .key-actions button.danger {
  border-color: rgba(240, 122, 122, 0.35);
  background: transparent;
  color: var(--p-red);
}

.portal-shell button.danger:hover {
  background: var(--p-red-soft);
  color: #ffb3b3;
}

.portal-shell .key-actions,
.portal-shell .portal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.portal-shell .key-actions form,
.portal-shell .portal-actions form {
  margin: 0;
}

.portal-shell .portal-table a,
.portal-shell .portal-list a,
.portal-shell .bulk-result a {
  color: var(--p-gold);
  text-decoration: none;
}

.portal-shell .portal-table a:hover,
.portal-shell .portal-list a:hover {
  text-decoration: underline;
}

/* ---------- Forms ---------- */
.portal-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.portal-shell select,
.portal-shell textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--p-line-strong);
  border-radius: 8px;
  background: var(--p-bg);
  color: var(--p-text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.portal-shell input[type="file"] {
  padding: 6px 8px;
}

.portal-shell input::placeholder,
.portal-shell textarea::placeholder {
  color: var(--p-faint);
}

.portal-shell input:focus,
.portal-shell select:focus,
.portal-shell textarea:focus {
  border-color: var(--p-gold);
  outline: none;
  box-shadow: 0 0 0 3px var(--p-gold-soft);
}

.portal-shell input[type="checkbox"],
.portal-shell input[type="radio"] {
  accent-color: var(--p-gold);
}

.portal-shell label {
  color: var(--p-muted);
  font-size: 12px;
  font-weight: 500;
}

.portal-shell .portal-form,
.portal-shell .history-settings-form,
.portal-shell .wall-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin: 16px 0 0;
}

.portal-shell .portal-form label,
.portal-shell .history-settings-form label,
.portal-shell .wall-form label,
.portal-shell .organization-profile-form label,
.portal-shell .bulk-upload label,
.portal-shell .referral-record label,
.portal-shell .performance-issue-form label {
  display: grid;
  gap: 6px;
}

.portal-shell .portal-form > button,
.portal-shell .history-settings-form > button,
.portal-shell .wall-form > button,
.portal-shell .history-description-field,
.portal-shell .history-publish-control,
.portal-shell .wall-form-wide,
.portal-shell .wall-publish-toggle {
  grid-column: 1 / -1;
}

.portal-shell .portal-form > button,
.portal-shell .history-settings-form > button,
.portal-shell .wall-form > button {
  justify-self: start;
}

.portal-shell .portal-form.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}

.portal-shell .portal-form.compact button {
  grid-column: auto;
  justify-self: stretch;
}

.portal-shell .exchange-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-content: start;
  margin: 0;
}

.portal-shell .exchange-consent,
.portal-shell .wall-publish-toggle,
.portal-shell .profile-public-option {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--p-line);
  border-radius: var(--p-radius-sm);
  background: var(--p-surface-2);
  color: var(--p-muted);
  font-size: 12px;
  line-height: 1.5;
}

.portal-shell .exchange-consent input,
.portal-shell .wall-publish-toggle input,
.portal-shell .profile-public-option input {
  margin-top: 3px;
}

.portal-shell .exchange-consent strong,
.portal-shell .wall-publish-toggle strong,
.portal-shell .profile-public-option strong {
  display: block;
  color: var(--p-text);
  font-weight: 600;
}

.portal-shell .wall-publish-toggle span,
.portal-shell .profile-public-option span {
  display: grid;
  gap: 2px;
}

.portal-shell .portal-inline,
.portal-shell .portal-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.portal-shell .portal-inline input {
  flex: 1 1 220px;
  width: auto;
}

.portal-shell .portal-inline select {
  flex: 0 0 140px;
  width: auto;
}

.portal-shell .portal-search input {
  flex: 1 1 280px;
  width: auto;
}

/* Organization profile */
.portal-shell .organization-profile-form {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.portal-shell .organization-profile-form fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  background: var(--p-bg);
}

.portal-shell .organization-profile-form legend,
.portal-shell .performance-privacy-controls legend {
  padding: 0 6px;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
  color: var(--p-text);
  font-size: 13px;
  font-weight: 600;
}

.portal-shell .organization-profile-form .profile-wide,
.portal-shell .profile-public-fields > p {
  grid-column: 1 / -1;
}

.portal-shell .profile-public-fields {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
}

.portal-shell .profile-public-fields > p {
  margin: 0;
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell .profile-public-option small {
  color: var(--p-faint);
  font: 10px var(--p-mono);
  text-transform: uppercase;
}

.portal-shell .profile-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 4px;
}

.portal-shell .profile-form-footer p {
  margin: 0;
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell .profile-form-footer p strong {
  display: block;
  color: var(--p-text);
}

/* ---------- Lists and tables ---------- */
.portal-shell .portal-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.portal-shell .portal-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--p-line);
  font-size: 13px;
}

.portal-shell .portal-list li:first-child {
  border-top: 0;
}

.portal-shell .portal-list li div {
  display: grid;
  gap: 2px;
}

.portal-shell .portal-list span {
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell ol.portal-list {
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.portal-shell ol.portal-list li {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--p-line);
  border-radius: 10px;
  background: var(--p-bg);
}

.portal-shell .portal-table {
  overflow-x: auto;
  margin: 0 -24px -24px;
  border-top: 1px solid var(--p-line);
}

.portal-shell .portal-table table {
  width: 100%;
  border-collapse: collapse;
}

.portal-shell .portal-table th,
.portal-shell .portal-table td {
  padding: 11px 24px;
  border-bottom: 1px solid var(--p-line);
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.portal-shell .portal-table th {
  background: var(--p-surface-2);
  color: var(--p-faint);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-shell .portal-table tbody tr:hover {
  background: var(--p-surface-2);
}

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

.portal-shell .portal-table button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.portal-shell .portal-table form {
  margin: 0;
}

/* ---------- Metrics ---------- */
.portal-shell .portal-usage {
  display: grid;
  gap: 20px;
}

.portal-shell .portal-metrics,
.portal-shell .referral-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.portal-shell .referral-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.portal-shell .portal-metrics article,
.portal-shell .referral-metrics article {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  background: var(--p-surface);
}

.portal-shell .portal-metrics small,
.portal-shell .referral-metrics small {
  color: var(--p-faint);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-shell .portal-metrics strong,
.portal-shell .referral-metrics strong {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.portal-shell .portal-metrics span {
  color: var(--p-muted);
  font-size: 12px;
}

/* ---------- Usage meter ---------- */
.portal-shell .usage-meter {
  display: grid;
  gap: 20px;
}

.portal-shell .portal-usage > .usage-meter {
  padding: 24px;
  border: 1px solid var(--p-line);
  border-radius: var(--p-radius);
  background: var(--p-surface);
}

.portal-shell .usage-meter-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.portal-shell .usage-meter-head small {
  color: var(--p-gold);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.portal-shell .usage-meter-head h3 {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 650;
}

.portal-shell .usage-meter-note {
  color: var(--p-faint);
  font-size: 12px;
}

.portal-shell .usage-track {
  display: grid;
  gap: 8px;
}

.portal-shell .usage-track-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--p-muted);
  font-size: 13px;
}

.portal-shell .usage-track-label strong {
  color: var(--p-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.portal-shell .usage-track p {
  margin: 0;
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell .usage-bar {
  position: relative;
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--p-surface-3);
}

.portal-shell .usage-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #9fe3b8, var(--p-green));
  transition: width 0.4s ease;
}

.portal-shell .usage-bar.full i {
  background: linear-gradient(90deg, var(--p-amber), #f5c46f);
}

.portal-shell .usage-bar.accent i {
  background: linear-gradient(90deg, #b88a2c, var(--p-gold));
}

.portal-shell .portal-nav-usage .usage-bar {
  height: 4px;
}

.portal-shell .portal-nav-usage .usage-bar.full i {
  background: linear-gradient(90deg, var(--p-amber), #f5c46f);
}

.portal-shell .usage-summary,
.portal-shell .billing-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--p-line);
  border-radius: 10px;
  background: var(--p-line);
}

.portal-shell .usage-summary > div,
.portal-shell .billing-facts > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--p-bg);
}

.portal-shell .usage-summary dt,
.portal-shell .billing-facts dt {
  color: var(--p-faint);
  font-size: 11px;
}

.portal-shell .usage-summary dd,
.portal-shell .billing-facts dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.portal-shell .billing-facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 16px 0 4px;
  background: var(--p-bg);
}

.portal-shell .billing-facts > div {
  padding: 14px 16px;
}

/* ---------- Billing page ---------- */
.portal-shell .portal-billing-page {
  display: grid;
  gap: 20px;
}

.portal-shell .plan-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.portal-shell .plan-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.portal-shell .plan-option input {
  position: absolute;
  opacity: 0;
}

.portal-shell .plan-option span {
  display: grid;
  gap: 4px;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--p-line-strong);
  border-radius: 12px;
  background: var(--p-bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.portal-shell .plan-option strong {
  color: var(--p-text);
  font-size: 14px;
}

.portal-shell .plan-option em {
  margin: 4px 0 6px;
  color: var(--p-text);
  font-size: 20px;
  font-style: normal;
  font-weight: 650;
}

.portal-shell .plan-option em small {
  color: var(--p-muted);
  font-size: 12px;
  font-weight: 400;
}

.portal-shell .plan-option span > small {
  color: var(--p-muted);
  font-size: 12px;
}

.portal-shell .plan-option:hover span {
  border-color: #3b424d;
}

.portal-shell .plan-option input:checked + span {
  border-color: var(--p-gold);
  background: linear-gradient(180deg, var(--p-gold-soft), transparent 70%), var(--p-bg);
  box-shadow: 0 0 0 1px var(--p-gold);
}

.portal-shell .plan-option input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--p-gold-soft);
}

.portal-shell .plan-submit {
  grid-column: 1 / -1;
  justify-self: start;
}

/* ---------- Existing feature panels, harmonised ---------- */
.portal-shell .exchange-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.portal-shell .exchange-guidance,
.portal-shell .exchange-connection,
.portal-shell .referral-record,
.portal-shell .supersession-control,
.portal-shell .history-public-link,
.portal-shell .bulk-preview,
.portal-shell .bulk-result,
.portal-shell .profile-audit,
.portal-shell .exchange-audit,
.portal-shell .referral-audit,
.portal-shell .wall-audit {
  padding: 16px;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  background: var(--p-bg);
}

.portal-shell .exchange-guidance ol {
  margin: 10px 0 14px;
  padding-left: 18px;
  color: var(--p-muted);
  font-size: 13px;
  line-height: 1.8;
}

.portal-shell .exchange-connections,
.portal-shell .referral-records {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.portal-shell .profile-audit,
.portal-shell .exchange-audit,
.portal-shell .referral-audit,
.portal-shell .wall-audit,
.portal-shell .supersession-controls {
  margin-top: 20px;
}

.portal-shell .profile-audit > small,
.portal-shell .exchange-audit > small,
.portal-shell .referral-audit > small,
.portal-shell .wall-audit > small {
  color: var(--p-faint);
  font: 500 10px/1.4 var(--p-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-shell .bulk-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}

.portal-shell .bulk-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  margin-bottom: 12px;
}

.portal-shell .history-public-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.portal-shell .portal-menu-toggle {
  display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .portal-shell .portal-metrics,
  .portal-shell .plan-picker,
  .portal-shell .usage-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-shell ol.portal-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .portal-shell .portal-dashboard-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .portal-shell .portal-menu-toggle {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 12px;
    border-color: var(--p-line-strong);
    background: var(--p-surface);
    color: var(--p-text);
  }

  .portal-shell .portal-navigation {
    position: static;
    display: none;
  }

  .portal-shell .portal-navigation.open {
    display: block;
  }

  .portal-shell .exchange-layout,
  .portal-shell .bulk-upload {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .portal-shell .portal-account-org {
    display: none;
  }

  .portal-shell .portal-topbar {
    flex-direction: row;
    align-items: center;
  }

  .portal-shell .billing-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-shell .portal-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 24px 0 16px;
  }

  .portal-shell .portal-card {
    padding: 18px;
  }

  .portal-shell .portal-table {
    margin: 0 -18px -18px;
  }

  .portal-shell .portal-table th,
  .portal-shell .portal-table td {
    padding: 10px 18px;
  }

  .portal-shell .portal-metrics,
  .portal-shell .plan-picker,
  .portal-shell .usage-summary,
  .portal-shell .portal-form,
  .portal-shell .history-settings-form,
  .portal-shell .wall-form,
  .portal-shell .organization-profile-form fieldset,
  .portal-shell ol.portal-list {
    grid-template-columns: 1fr;
  }

  .portal-shell .usage-meter-head,
  .portal-shell .profile-form-footer,
  .portal-shell .portal-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

.portal-shell .support-tickets{margin-top:26px;padding-top:20px;border-top:1px solid var(--portal-border,#26302b)}
.portal-shell .support-tickets>small{display:block;margin-bottom:12px;color:#8a978f;font-size:11px;text-transform:uppercase;letter-spacing:.1em}
