:root {
  color-scheme: light;
  --navy-950: #071a2c;
  --navy-900: #0b2740;
  --navy-700: #17466a;
  --cyan-500: #11bfd0;
  --cyan-100: #e7fbfd;
  --ink: #102a43;
  --muted: #5e7183;
  --line: #d9e4eb;
  --surface: #ffffff;
  --canvas: #f5f9fb;
  --danger: #b42318;
  --danger-surface: #fff4f2;
  --success: #067647;
  --success-surface: #effaf5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  background: var(--canvas);
  color: var(--ink);
  margin: 0;
  min-width: 320px;
}

a { color: var(--navy-700); font-weight: 650; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy-900); }

:focus-visible { outline: 3px solid #00717c; outline-offset: 3px; }

.portal-shell { display: flex; flex-direction: column; min-height: 100vh; }
.skip-link { background: var(--navy-950); border-radius: 8px; color: #fff; left: 12px; padding: 12px 16px; position: fixed; top: 12px; transform: translateY(-180%); z-index: 10; }
.skip-link:focus { color: #fff; transform: translateY(0); }
.visually-hidden:not(:focus):not(:active) { clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
.portal-header, .portal-footer { align-items: center; display: flex; justify-content: space-between; margin: 0 auto; max-width: 1180px; padding: 24px 32px; width: 100%; }
.portal-header { color: var(--muted); }
.brand { align-items: center; color: var(--navy-950); display: inline-flex; font-size: 1.35rem; font-weight: 800; gap: 10px; letter-spacing: -.035em; text-decoration: none; }
.brand-mark { align-items: end; display: inline-flex; gap: 3px; height: 24px; }
.brand-mark span { background: var(--cyan-500); border-radius: 2px; display: block; height: 14px; width: 4px; }
.brand-mark span:nth-child(2) { height: 22px; }
.brand-mark span:nth-child(3) { height: 18px; }
.header-context, .portal-footer { font-size: .76rem; letter-spacing: .04em; }
.portal-main { align-items: center; display: flex; flex: 1; justify-content: center; padding: 32px 20px 72px; }
.portal-footer { color: var(--muted); padding-bottom: 28px; padding-top: 18px; }

.auth-card, .account-card { background: var(--surface); border: 1px solid rgba(217, 228, 235, .95); border-radius: 18px; box-shadow: 0 18px 50px rgba(7, 26, 44, .08); width: min(100%, 480px); }
.auth-card { padding: 42px; }
.account-card { padding: 44px; width: min(100%, 650px); }
.eyebrow { color: #00717c; font-size: .72rem; font-weight: 800; letter-spacing: .12em; margin-bottom: 14px; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { color: var(--navy-950); font-size: clamp(1.8rem, 4vw, 2.25rem); letter-spacing: -.04em; line-height: 1.08; margin-bottom: 12px; }
h2 { color: var(--navy-950); font-size: 1.12rem; letter-spacing: -.015em; margin-bottom: 10px; }
.lede { color: var(--muted); line-height: 1.55; margin-bottom: 28px; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
label { color: var(--navy-900); font-size: .9rem; font-weight: 700; }
.label-row { align-items: baseline; display: flex; justify-content: space-between; }
.label-row a { font-size: .78rem; }
.optional { color: var(--muted); font-size: .78rem; font-weight: 500; }
input { background: #fff; border: 1px solid #b9cbd6; border-radius: 9px; color: var(--ink); font: inherit; min-height: 48px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s; width: 100%; }
input:hover { border-color: #7fa4b8; }
input:focus { border-color: #00717c; box-shadow: 0 0 0 4px rgba(17, 191, 208, .14); }
input:focus-visible { outline: 3px solid #00717c; outline-offset: 3px; }
input:user-invalid { border-color: #d87970; }
.field-help { color: var(--muted); font-size: .76rem; margin: 0; }
.button { align-items: center; border: 0; border-radius: 9px; cursor: pointer; display: inline-flex; font: inherit; font-size: .92rem; font-weight: 750; justify-content: center; min-height: 48px; padding: 12px 16px; text-decoration: none; transition: background .15s, transform .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { background: var(--navy-950); box-shadow: 0 7px 16px rgba(7, 26, 44, .16); color: white; }
.button-primary:hover { background: var(--navy-700); color: white; }
.button-secondary { background: var(--cyan-100); color: var(--navy-900); }
.button-secondary:hover { background: #d4f5f8; color: var(--navy-950); }
.button-danger { background: var(--danger-surface); border: 1px solid #f3b8b0; color: var(--danger); }
.button-danger:hover { background: #fee4df; color: #912018; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row .button { flex: 1 1 160px; width: auto; }
.button-github { background: #101828; color: white; gap: 10px; width: 100%; }
.button-github:hover { background: #263548; color: white; }
.github-mark {
  display: inline-block; flex: 0 0 28px; width: 28px; height: 28px;
  background: center / contain no-repeat url("/brand/github-invertocat.svg");
  font-size: 0;
}
.divider { align-items: center; color: var(--muted); display: flex; font-size: .75rem; gap: 12px; margin: 26px 0 18px; }
.divider::before, .divider::after { background: var(--line); content: ""; flex: 1; height: 1px; }
.switch-copy { color: var(--muted); font-size: .86rem; margin: 25px 0 0; text-align: center; }
.form-message { color: var(--danger); font-size: .82rem; line-height: 1.45; margin: 0; min-height: 1.2em; }
.form-message[data-kind="success"] { color: var(--success); }
.form-message:empty { display: none; }
.success-panel, .error-panel, .state-panel, .account-note { border-radius: 12px; line-height: 1.5; padding: 18px; }
.success-panel { background: var(--success-surface); color: #175b42; }
.success-panel p, .error-panel p, .state-panel p, .account-note p { margin-bottom: 16px; }
.success-panel .button, .error-panel .button { width: 100%; }
.error-panel { background: var(--danger-surface); color: #7a271a; }
.status-icon { align-items: center; background: #ccefe0; border-radius: 50%; color: var(--success); display: inline-flex; font-weight: 850; height: 28px; justify-content: center; margin-bottom: 14px; width: 28px; }
.status-icon-error { background: #fbd8d3; color: var(--danger); }
.state-panel { background: #f4f8fa; color: var(--muted); min-height: 82px; }
.state-panel p { margin: 0; }
.loading-dot { background: var(--cyan-500); border-radius: 50%; display: inline-block; height: 8px; margin: 0 8px 1px 0; width: 8px; }
.resend-panel { margin-top: 22px; }
.resend-panel > p { color: var(--muted); font-size: .88rem; }

.account-heading { align-items: flex-start; display: flex; gap: 20px; justify-content: space-between; }
.account-heading .lede { margin-bottom: 0; }
.session-badge { align-items: center; background: var(--success-surface); border-radius: 999px; color: var(--success); display: inline-flex; font-size: .72rem; font-weight: 750; gap: 6px; padding: 7px 10px; white-space: nowrap; }
.session-badge span { background: #12b76a; border-radius: 50%; height: 7px; width: 7px; }
.identity-summary { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 14px; margin: 32px 0 24px; padding-bottom: 24px; }
.avatar { align-items: center; background: var(--navy-950); border-radius: 50%; color: var(--cyan-500); display: inline-flex; font-size: 1.2rem; font-weight: 800; height: 46px; justify-content: center; width: 46px; }
.identity-summary strong, .identity-summary span { display: block; }
.identity-summary strong { color: var(--navy-950); margin-bottom: 4px; }
.identity-summary span { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.identity-summary .avatar { display: inline-flex; }
.account-note { background: #f3f8fb; border: 1px solid #deebf1; color: var(--muted); margin-bottom: 26px; }
.account-note strong { color: var(--navy-900); display: block; font-size: .9rem; margin-bottom: 6px; }
.account-note p { font-size: .86rem; margin: 0; }
.account-overview { background: #fbfdfe; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 26px; padding: 20px; }
.account-overview h2 { margin-bottom: 16px; }
.account-overview dl { display: grid; gap: 0 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.account-overview dl > div { border-top: 1px solid var(--line); min-width: 0; padding: 12px 0; }
.account-overview dt { color: var(--muted); font-size: .78rem; margin-bottom: 5px; }
.account-overview dd { color: var(--navy-900); font-size: .9rem; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.profile-editor { max-width: 100%; }
.profile-editor #account-profile-view { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 14px 24px; justify-content: space-between; }
.profile-editor #account-profile-view dl { flex: 1 1 220px; }
.profile-editor #account-profile-form { max-width: 480px; }
.profile-editor .button-row { justify-content: flex-start; margin-top: 4px; }
.profile-editor .form-message { min-height: 1.5em; }
.profile-editor [aria-busy="true"] { cursor: progress; }
.quickstart h3 { color: var(--navy-900); font-size: .96rem; margin: 20px 0 10px; }
.quickstart-base { align-items: center; display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 16px 0; }
.quickstart-base span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.quickstart-base code { color: var(--navy-900); overflow-wrap: anywhere; }
.quickstart-links { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 16px 0 22px; }
.quickstart-links a { min-height: 44px; padding: 10px 0; }
.quickstart-code { background: var(--navy-950); border-radius: 9px; color: #f4fbff; font-size: .78rem; line-height: 1.6; margin: 12px 0 20px; max-width: 100%; overflow-wrap: anywhere; overflow-x: auto; padding: 14px; white-space: pre-wrap; }
.quickstart-code code { font: inherit; }
.quickstart-security { background: #f3f8fb; border: 1px solid #deebf1; border-radius: 10px; color: var(--muted); padding: 14px 16px; }
.quickstart-security h3 { margin-top: 0; }
.quickstart-security ul { margin: 0; padding-left: 20px; }
.quickstart-security li { line-height: 1.55; margin: 6px 0; overflow-wrap: anywhere; }
#api-keys-list { display: grid; gap: 12px; list-style: none; margin: 16px 0 22px; padding: 0; }
#api-keys-list li { align-items: center; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: space-between; padding-top: 12px; }
#api-keys-list li > span { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.invoice-list { display: grid; gap: 12px; list-style: none; margin: 16px 0; padding: 0; }
.invoice-list li { border-top: 1px solid var(--line); display: grid; gap: 8px; min-width: 0; padding: 14px 0 2px; }
.invoice-heading, .invoice-meta, .invoice-links { align-items: center; display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: space-between; }
.invoice-heading { font-size: .95rem; margin: 0; }
.invoice-heading > span { color: var(--navy-900); overflow-wrap: anywhere; }
.invoice-meta { color: var(--muted); font-size: .84rem; justify-content: flex-start; }
.invoice-links { justify-content: flex-start; }
.invoice-links a { min-height: 44px; padding: 10px 0; }
.invoice-actions { margin-top: 12px; }
.usage-history-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.usage-history-table { border-collapse: collapse; min-width: 600px; width: 100%; }
.usage-history-table caption { color: var(--muted); font-size: .76rem; padding: 0 0 10px; text-align: left; }
.usage-history-table th, .usage-history-table td { border-top: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
.usage-history-table thead th { color: var(--muted); font-size: .76rem; font-weight: 700; }
.usage-history-table tbody th { color: var(--navy-900); font-size: .84rem; font-weight: 700; text-transform: capitalize; }
.usage-history-table td { color: var(--ink); font-size: .82rem; overflow-wrap: anywhere; }
#api-key-one-time-secret { background: #fff; border: 1px solid #c7ded4; border-radius: 8px; display: block; font-size: .88rem; margin: 12px 0 16px; overflow-wrap: anywhere; padding: 12px; user-select: all; }
#api-key-step-up-panel, #api-key-secret-panel, #api-key-revoke-confirm, #api-key-rotate-confirm { margin-top: 18px; }
#api-key-step-up-panel h3, #api-key-secret-panel h3, #api-key-revoke-confirm h3, #api-key-rotate-confirm h3 { font-size: 1rem; margin: 0 0 10px; }
#api-key-step-up-panel > .button { margin: 8px 0 20px; }
#api-key-revoke-confirm .button-danger { background: var(--danger); color: #fff; }
#api-key-revoke-confirm .button-danger:hover { background: #912018; }
.logout-form { align-items: center; display: flex; gap: 14px; }
.logout-form .button { min-width: 100px; }
.logout-form .form-message { flex: 1; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .portal-header, .portal-footer { padding-left: 20px; padding-right: 20px; }
  .header-context { display: none; }
  .portal-main { padding: 16px 12px 48px; }
  .auth-card, .account-card { border-radius: 14px; padding: 30px 22px; }
  .account-heading { flex-direction: column; }
  .account-overview dl { grid-template-columns: 1fr; }
  .logout-form { align-items: stretch; flex-direction: column; }
  .logout-form .form-message { min-height: 0; }
  .portal-footer { align-items: flex-start; flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .button:hover { transform: none; }
}
