:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #eef2f6;
  --text: #17212b;
  --text-muted: #5e6b78;
  --brand: #315ba6;
  --brand-strong: #244785;
  --brand-soft: #e8eef9;
  --success: #18794e;
  --success-soft: #e7f5ee;
  --danger: #b42318;
  --danger-soft: #fcebea;
  --warning: #9a6700;
  --border: #d9e0e7;
  --focus: #1d4ed8;
  --shadow: 0 16px 40px rgba(36, 71, 133, 0.1);
  --radius: 8px;
  --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100dvh; color: var(--text); background: var(--bg); font: 16px/1.55 var(--font-sans); }
button, input, select { font: inherit; }
button, a { touch-action: manipulation; }
a { color: var(--brand-strong); }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 12px; top: 12px; z-index: 1000; padding: 10px 14px; background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy small { margin-top: 4px; color: var(--text-muted); font-size: 12px; font-weight: 500; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; text-decoration: none; font-weight: 650; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease; }
.button:active { transform: scale(.98); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover { background: var(--brand-strong); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { border-color: #aeb9c5; background: var(--surface-subtle); }
.button-danger { background: var(--danger); color: #fff; }
.icon { width: 19px; height: 19px; stroke-width: 1.8; flex: 0 0 auto; }

.field { display: grid; gap: 7px; }
.field label { font-size: 14px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 10px 12px; }
.field input::placeholder { color: #7a8794; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-hint, .field-error { margin: 0; font-size: 13px; }
.field-hint { color: var(--text-muted); }
.field-error { color: var(--danger); }
.status-message { min-height: 24px; margin: 0; color: var(--text-muted); font-size: 14px; }
.status-message[data-tone="error"] { color: var(--danger); }
.status-message[data-tone="success"] { color: var(--success); }

.login-page { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(400px, .95fr); min-height: 100dvh; background: var(--surface); }
.login-context { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100dvh; overflow: hidden; padding: clamp(32px, 5vw, 72px); background: #17324a; color: #f7fafc; }
.login-context::after { content: ""; position: absolute; width: min(48vw, 620px); aspect-ratio: 1; right: -18%; bottom: -30%; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: inset 0 0 0 80px rgba(255,255,255,.025), inset 0 0 0 160px rgba(255,255,255,.02); pointer-events: none; }
.login-context .brand { color: #fff; position: relative; z-index: 1; }
.login-context .brand img { background: #fff; border-radius: 50%; }
.login-message { position: relative; z-index: 1; max-width: 580px; padding: 64px 0; }
.login-message h1 { max-width: 12ch; margin: 0 0 20px; font-size: clamp(38px, 5vw, 68px); line-height: 1.08; letter-spacing: 0; }
.login-message p { max-width: 42ch; margin: 0; color: #ccdae6; font-size: 18px; }
.login-trust { position: relative; z-index: 1; display: flex; gap: 24px; color: #ccdae6; font-size: 14px; }
.login-trust span { display: inline-flex; align-items: center; gap: 8px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-box { width: min(100%, 430px); }
.login-box h2 { margin: 0 0 8px; font-size: 30px; line-height: 1.2; }
.login-box > p { margin: 0 0 32px; color: var(--text-muted); }
.login-form { display: grid; gap: 22px; }
.form-actions { display: flex; gap: 12px; }
.form-actions .button { flex: 1; }
.step-indicator { display: flex; gap: 8px; margin-bottom: 28px; }
.step-indicator span { width: 32px; height: 4px; border-radius: 2px; background: var(--border); }
.step-indicator span.active { background: var(--brand); }
.filing { margin-top: 32px; color: var(--text-muted); font-size: 13px; }

.app-shell { min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); }
.topbar-inner { max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.top-actions form { margin: 0; }
.user-chip { display: grid; text-align: right; line-height: 1.2; }
.user-chip strong { font-size: 14px; }
.user-chip span { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }
.page { max-width: 1200px; margin: 0 auto; padding: 48px 24px 72px; }
.page-header { margin-bottom: 32px; }
.page-header h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 44px); line-height: 1.15; }
.page-header p { max-width: 62ch; margin: 0; color: var(--text-muted); }
.portal-content { max-width: 900px; }
.section { border-top: 1px solid var(--border); padding: 28px 0; }
.section:first-child { border-top: 0; padding-top: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.client-list { display: grid; gap: 12px; }
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.download-item { min-height: 76px; display: grid; grid-template-columns: 44px minmax(0, 1fr) 20px; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; transition: background-color 160ms ease, border-color 160ms ease; }
.download-item:hover { border-color: #aeb9c5; background: var(--surface-subtle); }
.download-item strong, .download-item small { display: block; }
.download-item small { margin-top: 3px; color: var(--text-muted); font-size: 13px; }
.platform-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); }
.client-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.client-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); }
.client-row h3 { margin: 0; font-size: 16px; }
.client-row p { margin: 3px 0 0; color: var(--text-muted); font-size: 13px; }
.notice { padding: 20px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 var(--radius) var(--radius) 0; }
.notice h2 { margin: 0 0 8px; font-size: 18px; }
.notice p { margin: 0; color: #31445a; }
.utility-panel { position: sticky; top: 96px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.utility-panel h2 { margin: 0 0 8px; font-size: 20px; }
.utility-panel > p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.url-preview { overflow: hidden; margin-bottom: 14px; padding: 12px; border-radius: var(--radius); background: var(--surface-subtle); color: var(--text-muted); font: 12px/1.5 var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.stack-actions { display: grid; gap: 10px; }
.security-note { display: flex; gap: 10px; margin-top: 18px; color: var(--text-muted); font-size: 13px; }
.skeleton { position: relative; overflow: hidden; background: #e8edf2; color: transparent !important; border-radius: 4px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.dialog { width: min(92vw, 480px); border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 24px 70px rgba(23,33,43,.28); }
.dialog::backdrop { background: rgba(23,33,43,.58); }
.dialog-body { padding: 24px; }
.dialog h2 { margin: 0 0 8px; font-size: 22px; }
.dialog p { color: var(--text-muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }

@media (max-width: 840px) {
  .login-page { grid-template-columns: 1fr; }
  .login-context { min-height: 260px; padding: 28px 24px; }
  .login-message { padding: 40px 0 20px; }
  .login-message h1 { max-width: 15ch; font-size: 38px; }
  .login-message p { font-size: 16px; }
  .login-trust { display: none; }
  .login-panel { align-items: flex-start; padding: 40px 24px 64px; }
  .download-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { height: 64px; }
  .topbar-inner, .page { padding-left: 16px; padding-right: 16px; }
  .brand-copy small, .user-chip { display: none; }
  #audit-entry span { display: none; }
  #audit-entry { width: 44px; padding: 10px; }
  .page { padding-top: 32px; }
  .page-header { margin-bottom: 24px; }
  .client-row { grid-template-columns: 44px minmax(0, 1fr); }
  .client-row .button { grid-column: 1 / -1; width: 100%; }
  .form-actions { flex-direction: column-reverse; }
}

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