:root {
  color-scheme: dark;
  --page: #060914;
  --surface: rgba(15,22,39,.76);
  --surface-strong: #111a2c;
  --panel: var(--surface-strong);
  --panel-glass: linear-gradient(135deg, #8299cb21, #26314c47 55%, #58809114);
  --text: #f5f7ff;
  --muted: #9ba8bd;
  --dim: #66748b;
  --accent: #80e5d6;
  --accent-secondary: #a99df6;
  --line: rgba(190,208,248,.14);
  --line-strong: rgba(128,229,214,.34);
  --glass-line: var(--line);
  --field: #060b15;
  --success: #78e4ad;
  --warning: #ffd37d;
  --danger: #ff958d;
  --focus: #80e5d6;
  --shadow: 0 24px 70px #00000040;
  --radius-card: 18px;
  --radius-input: 10px;
  --radius-button: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 0; background: var(--page); }
body.app-shell {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 16% -10%, #80e5d617, transparent 36rem),
    radial-gradient(circle at 92% 8%, #8c76dd1c, transparent 32rem),
    var(--page);
  font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell a { color: var(--accent); text-underline-offset: 4px; }
.app-shell :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.app-shell input[type="date"]:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.app-shell .skip-link {
  position: fixed;
  z-index: 20;
  top: 10px;
  left: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-button);
  color: #07110f;
  background: var(--accent);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header { border-bottom: 1px solid var(--line); background: rgba(6,9,20,.8); }
.site-header__inner {
  width: min(1180px, 100%);
  min-height: 76px;
  margin: 0 auto;
  padding: 14px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text) !important;
  font-size: 14px;
  font-weight: 760;
  letter-spacing: .08em;
  text-decoration: none;
}
.brand img { width: 40px; height: 40px; display: block; flex: 0 0 auto; border-radius: 10px; object-fit: cover; }
.brand b { color: var(--accent); font-weight: 900; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  min-height: 44px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-button);
  color: var(--muted) !important;
  font-size: 14px;
  text-decoration: none;
}
.nav-link:hover, .nav-link--current { color: var(--text) !important; background: #ffffff0b; }

.page-shell {
  width: min(100% - 48px, 1180px);
  min-width: 0;
  margin: 0 auto;
  padding: 72px 0 88px;
}
.auth-shell, .transaction-shell, .secure-shell { width: min(100% - 48px, 680px); }
.status-shell { width: min(100% - 48px, 720px); min-height: 60vh; display: grid; align-content: center; }
.workspace-shell {
  width: min(100% - 48px, 1240px);
  min-width: 0;
  margin: 0 auto;
  padding: 56px 0 88px;
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}
.workspace-shell > .page-shell { width: 100%; margin: 0; padding: 0; }
.workspace-sidebar { min-width: 0; }
.page-header { min-width: 0; margin-bottom: 30px; }
.eyebrow {
  margin: 0 0 13px;
  color: var(--accent);
  font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.page-header h1 {
  max-width: 820px;
  margin: 0;
  color: var(--text);
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
.public-shell .page-header h1 { text-wrap: balance; }
.auth-shell .page-header h1, .transaction-shell .page-header h1, .secure-shell .page-header h1,
.status-shell .page-header h1, .workspace-shell .page-header h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
.page-description { max-width: 700px; margin: 22px 0 0; color: var(--muted); font-size: 18px; }
.page-actions, .actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }

.panel, .page-shell form, .card {
  min-width: 0;
  margin: 16px 0;
  padding: 25px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: inset 0 1px 0 #ffffff06;
}
.page-shell h2 { margin: 34px 0 15px; color: var(--text); font-size: 20px; line-height: 1.25; }
.page-shell p, .page-shell small { color: var(--muted); }
.page-shell ul { padding-left: 22px; }
.page-shell code, .page-shell pre, .page-shell td { overflow-wrap: anywhere; }
.page-shell pre { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #050a12; white-space: pre-wrap; }

.button, .page-shell button {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #061210 !important;
  background: var(--accent);
  cursor: pointer;
  font: 700 15px/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.button:hover, .page-shell button:hover { background: #a0f3e7; transform: translateY(-1px); }
.button--secondary, .button.secondary, .page-shell button.secondary {
  border-color: var(--line);
  color: var(--text) !important;
  background: #ffffff0b;
}

.page-shell label { margin-bottom: 20px; display: block; color: var(--text); font-size: 14px; font-weight: 650; }
.page-shell input, .page-shell select, .page-shell textarea {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 11px 13px;
  border: 1px solid #bed0f842;
  border-radius: var(--radius-input);
  color: var(--text);
  background: var(--field);
  font: 16px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}
.page-shell textarea { min-height: 120px; resize: vertical; }
.page-shell input:focus, .page-shell select:focus, .page-shell textarea:focus { border-color: var(--accent); }
.password-control { margin-bottom: 20px; }
.password-control > label { margin-bottom: 0; }
.password-field { position: relative; }
.password-field input { padding-right: 54px; }
.page-shell .password-toggle {
  position: absolute;
  top: 10px;
  right: 2px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  color: var(--muted) !important;
  background: transparent;
}
.page-shell .password-toggle:hover { color: var(--text) !important; background: transparent; transform: none; }
.password-eye { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-eye--hide, .password-toggle[aria-pressed="true"] .password-eye--show { display: none; }
.password-toggle[aria-pressed="true"] .password-eye--hide { display: block; }

.public-home { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 64px; align-items: center; }
.public-home .page-header { margin: 0; }
.public-feature { margin: 0; }
.public-feature h2 { margin-top: 12px; font-size: clamp(1.5rem, 3vw, 2rem); }
.public-shell #identity-feature-title { text-wrap: balance; }
.feature-list { margin: 24px 0 0; display: grid; gap: 11px; color: var(--muted); }
.feature-list li::marker { color: var(--accent); }
.status-panel { border-left: 3px solid var(--accent); }

.workspace-nav { position: sticky; top: 24px; display: grid; gap: 8px; }
.workspace-nav .nav-link { border: 1px solid var(--line); }
.workspace-nav .nav-link--current { border-color: var(--line-strong); color: var(--text) !important; background: #80e5d612; }
.admin-navigation summary { min-height: 44px; padding: 10px 12px; cursor: pointer; color: var(--text); }
.admin-navigation .workspace-nav { display: grid; }
.admin-nav-group { display: grid; gap: 8px; min-width: 0; }
.admin-nav-group .eyebrow { margin: 16px 0 0; }
.admin-shell { overflow-wrap: anywhere; }
.admin-shell > .section-card, .admin-shell > .empty-state { margin-top: 24px; }
.admin-activity-list { list-style: none; padding: 0; }
.admin-activity-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-activity-list p { margin: 8px 0; }
.status-badge {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  background: #ffffff09;
  font-size: 13px;
  font-weight: 700;
}
.status-badge--info { border-color: #8fc7ff66; color: #b9dcff; }
.status-badge--success { border-color: #7ee2a866; color: var(--success); }
.status-badge--warning { border-color: #ffd27d66; color: var(--warning); }
.status-badge--danger { border-color: #ff9b9266; color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-card { display: grid; gap: 6px; }
.stat-card--link { color: inherit !important; text-decoration: none; }
.stat-card__label, .stat-card__detail { color: var(--muted); }
.stat-card__value { color: var(--text); font-size: 30px; overflow-wrap: anywhere; }
.empty-state { text-align: center; }
.empty-state h2, .section-card h2 { margin-top: 0; }
.empty-state__action { margin-top: 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.page-shell table { width: 100%; border-collapse: collapse; }
.page-shell th, .page-shell td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.danger-zone { margin-top: 32px; padding: 24px; border: 1px solid #ff9b9257; border-radius: var(--radius-card); background: #ff62580a; }
.notice { padding: 12px 18px; border-left: 3px solid var(--accent); color: var(--muted); background: #80e5d60b; }
.device { display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.device form { flex-shrink: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
.device button { white-space: nowrap; }
.device > span { min-width: 0; overflow-wrap: anywhere; }
.directory-nav, .pager { margin: 24px 0; display: flex; flex-wrap: wrap; gap: 16px; }
.directory-filter { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-items: end; }
.directory-filter label { margin: 0; }
.metadata-value { white-space: pre-wrap; }
.pager span { color: var(--muted); font-size: 14px; }
.portal-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.portal-list .card { margin: 0; display: block; color: inherit; text-decoration: none; }
.developer-shell .portal-list { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.developer-shell .portal-list strong, .developer-shell .section-card, .developer-shell .metadata, .developer-shell .version-timeline { overflow-wrap: anywhere; }
.developer-shell .metadata { margin: 20px 0 0; }
.developer-shell .metadata > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.developer-shell .metadata dt { color: var(--muted); }
.developer-shell .metadata dd { margin: 0; min-width: 0; }
.developer-shell .version-timeline { list-style: none; padding: 0; }
.developer-shell .version-timeline > li { border-left: 3px solid var(--accent-secondary); }
.developer-shell .danger-zone h2 { margin-top: 0; }
@media (max-width: 560px) {
  .developer-shell .metadata > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .developer-shell .danger-zone { padding: 16px; }
  .developer-shell .section-card form, .developer-shell .danger-zone form { padding: 14px; }
}

.site-footer {
  width: min(1180px, calc(100% - 60px));
  margin: 0 auto;
  padding: 24px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .public-home { gap: 36px; }
  .workspace-shell { width: min(100% - 48px, 960px); grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .workspace-nav { position: static; padding-bottom: 12px; display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .page-shell { padding-top: 48px; }
  .public-home { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .device { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  :root { --radius-card: 16px; }
  .site-header__inner { min-height: 68px; padding: 10px 16px; gap: 8px; }
  .site-header__inner { flex-wrap: wrap; }
  .site-nav { gap: 0; }
  .nav-link { padding-inline: 8px; }
  .page-shell, .auth-shell, .transaction-shell, .secure-shell, .status-shell, .workspace-shell { width: calc(100% - 32px); padding: 40px 0 56px; }
  .workspace-shell > .page-shell { width: 100%; padding: 0; }
  .page-header h1 { font-size: 2.25rem; }
  .page-description { font-size: 16px; }
  .page-actions, .actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .page-actions .button, .actions .button, .page-shell form > button { width: 100%; }
  .panel, .page-shell form, .card { padding: 20px; }
  .site-footer { width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell *, .app-shell *::before, .app-shell *::after {
    scroll-behavior: auto !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
  }
}

/* Server-rendered authentication methods keep native link navigation. */
.method-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 24px 0; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.method-tabs .nav-link { flex: 1 1 auto; justify-content: center; text-align: center; border: 1px solid transparent; }
.method-tabs .nav-link--current { border-color: var(--accent); background: #80e5d612; color: var(--accent) !important; }
.auth-shell, .transaction-shell, .status-shell { overflow-wrap: anywhere; }
.captcha-widget { max-width: 100%; }
.captcha-widget .captcha-slider-track, .captcha-widget .captcha-slider-progress { height: 48px !important; }
.captcha-widget .captcha-slider-btn { width: 44px !important; height: 44px !important; }
.captcha-widget button { min-width: 44px; min-height: 44px; }
@media (max-width: 560px) {
  .page-shell form[data-captcha-form] { padding: 12px; }
}

/* Account navigation is native and remains available without scripts. */
.workspace-shell .account-navigation summary { min-height: 44px; padding: 10px 12px; cursor: pointer; color: var(--text); }
.account-shell, .secure-shell { overflow-wrap: anywhere; }
#devices > details > summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.secure-shell summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.account-shell .identity-steps { padding: 0; list-style: none; }
.account-shell .proof-step { margin: 28px 0; padding-top: 4px; border-top: 1px solid var(--line); }
.account-shell .danger-zone h2 { margin-top: 0; }
.secure-shell .recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0; list-style: none; }
.secure-shell .recovery-codes li { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--field); }
@media (max-width: 560px) {
  .account-shell .danger-zone { padding: 16px; }
  .account-shell .identity-card { padding: 16px; }
  .account-shell .identity-card form { padding: 14px; }
  .secure-shell .recovery-codes { grid-template-columns: minmax(0, 1fr); }
}

/* Admin directories keep long identifiers and operations within their own cells. */
.admin-shell .directory-filter { grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
.admin-shell .directory-filter > * { min-width: 0; }
.admin-shell .directory-filter > a, .admin-shell .page-actions > a { min-height: 44px; display: inline-flex; align-items: center; }
.admin-shell .metadata { margin: 20px 0 0; }
.admin-shell .metadata > div { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 3fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-shell .metadata dt { color: var(--muted); }
.admin-shell .metadata dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.admin-shell .admin-table { table-layout: fixed; }
.admin-shell .admin-table td form { margin: 8px 0; padding: 12px; }
.admin-shell .admin-table td a { display: inline-flex; min-height: 44px; align-items: center; }
.admin-shell .danger-zone h2 { margin-top: 0; }
.admin-shell .danger-zone form:last-child { margin-bottom: 0; }
.admin-shell .pager { align-items: center; }
@media (max-width: 760px) {
  .admin-shell .directory-filter { grid-template-columns: minmax(0, 1fr); }
  .admin-shell .metadata > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .admin-shell .admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .admin-shell .admin-table, .admin-shell .admin-table tbody, .admin-shell .admin-table tr, .admin-shell .admin-table td { display: block; width: 100%; }
  .admin-shell .admin-table tr { margin: 16px 0; padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--panel); }
  .admin-shell .admin-table td { padding: 12px 0; }
  .admin-shell .admin-table td:last-child { border-bottom: 0; }
  .admin-shell .admin-table td::before { content: attr(data-label); display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
  .admin-shell .danger-zone { padding: 16px; }
  .admin-shell .danger-zone form { padding: 14px; }
}


/* V2 shared primitives; all visual hooks stay inside the application shell. */
.app-shell .form-field { margin-bottom: 20px; min-width: 0; }
.app-shell .form-field > label { margin-bottom: 0; }
.app-shell .form-field .field-help, .app-shell .form-field .field-error { margin: 8px 0 0; font-size: 13px; font-weight: 400; }
.app-shell .form-field .field-error { color: var(--danger); }
.app-shell .form-field [aria-invalid="true"] { border-color: var(--danger); }
.app-shell .field-required { color: var(--accent); }
.app-shell .password-toggle[hidden] { display: none; }
.app-shell .password-toggle { min-width: 44px; }
.app-shell .button-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.app-shell .metadata { margin: 20px 0; overflow-wrap: anywhere; }
.app-shell .metadata > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.app-shell .metadata dt { color: var(--muted); }
.app-shell .metadata dd { min-width: 0; margin: 0; white-space: pre-wrap; }
.app-shell .secure-result h2, .app-shell .danger-zone h2 { margin-top: 0; }
.app-shell .secure-result, .app-shell .auth-shell > form { border-radius: 24px; box-shadow: var(--shadow), inset 0 1px 0 #ffffff08; }
.app-shell .secure-result__value { background: var(--field); }
.app-shell .workspace-sidebar { position: sticky; top: 24px; }
.app-shell .workspace-navigation > summary { min-height: 44px; padding: 10px 12px; cursor: pointer; }
.app-shell .workspace-nav .nav-link--current::before { content: '›'; margin-right: 8px; font-weight: 900; }
.app-shell .auth-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.app-shell .auth-introduction h2 { font-size: clamp(36px, 6vw, 76px); }
@media (min-width: 1101px) {
  .app-shell .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .app-shell .workspace-sidebar { position: static; }
  .app-shell .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .app-shell .auth-layout { grid-template-columns: minmax(0, 1fr); }
  .app-shell .auth-introduction { display: none; }
}
@media (max-width: 760px) {
  .app-shell .workspace-nav { display: grid; }
  .app-shell .page-actions > * { width: 100%; }
  .app-shell .metadata > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .app-shell .button-group { display: grid; grid-template-columns: minmax(0, 1fr); }
  .app-shell .button-group > * { width: 100%; }
}
@media (max-width: 560px) {
  .app-shell .stat-card { padding: 16px; }
}

/* Immersive authentication remains a single task on compact screens. */
.app-shell .immersive-shell { width: min(100% - 48px, 1180px); }
.app-shell .auth-panel { min-width: 0; padding: 32px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.app-shell .auth-panel form { padding: 0; border: 0; background: transparent; box-shadow: none; }
@media (max-width: 899px) {
  .app-shell .immersive-shell { width: min(100% - 32px, 640px); }
  .app-shell .auth-panel { padding: 16px; }
}

.account-shell > section[id] { scroll-margin-top: 24px; }

/* Administration keeps work queues ahead of audit history in reading order. */
.app-shell .admin-nav-group > h2 { font-size: 11px; line-height: 1.6; }
.app-shell .admin-overview-work { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 24px; margin-top: 24px; align-items: start; }
.app-shell .admin-overview-work:empty { display: none; }
.app-shell .admin-overview-work > .panel { margin: 0; }
.app-shell .admin-queue-alerts { color: var(--warning); padding-left: 20px; }
.app-shell .admin-create-form > form { padding: 0; border: 0; background: transparent; box-shadow: none; }
.app-shell .admin-create-form .section-card { margin-bottom: 20px; }
.app-shell .admin-create-form .form-field + .form-field { margin-top: 20px; }
@media (max-width: 760px) {
  .app-shell .admin-shell .stat-grid { grid-template-columns: minmax(0, 1fr); }
}
