:root {
  --navy-950: #0c2336;
  --navy-900: #12314a;
  --navy-700: #28516d;
  --teal-700: #126a65;
  --teal-600: #187c76;
  --teal-100: #dff1ee;
  --gold-600: #a97528;
  --gold-100: #f3ead8;
  --paper: #f5f3ee;
  --surface: #fffefa;
  --surface-strong: #fff;
  --line: #d9e1e3;
  --line-strong: #bdcbd0;
  --ink: #112f46;
  --muted: #617583;
  --danger: #a33737;
  --danger-soft: #f9e8e6;
  --success-soft: #dff2ed;
  --shadow-1: 0 4px 16px rgba(12, 35, 54, .055);
  --shadow-2: 0 14px 34px rgba(12, 35, 54, .1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(18, 49, 74, .025), transparent 260px), var(--paper);
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  text-rendering: optimizeLegibility;
}
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; transform: translateY(-140%); padding: 9px 14px; border-radius: var(--radius-sm); background: white; color: var(--ink); box-shadow: var(--shadow-2); }
.skip-link:focus { transform: translateY(0); }

.app-header { position: sticky; z-index: 20; top: 0; padding: 0; color: white; background: linear-gradient(115deg, var(--navy-950), var(--navy-900) 72%, #173d58); box-shadow: 0 2px 14px rgba(12, 35, 54, .18); }
.header-shell { width: min(1040px, 100%); min-height: 80px; margin: auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-block > div { min-width: 0; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border: 1px solid rgba(220, 188, 128, .72); border-radius: 11px; color: #f3dfb8; background: rgba(255, 255, 255, .045); font: 700 20px/1 "STSong", "SimSun", serif; }
.brand-block strong { display: block; font-size: 21px; line-height: 1.35; letter-spacing: .04em; }
.brand-block small { display: block; margin-top: 3px; color: #c8d9e1; font-size: 12px; letter-spacing: .06em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-button { min-height: 42px; border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); color: white; }
.header-button:hover { border-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .11); }

main { width: min(1040px, 100%); max-width: none; min-height: calc(100vh - 150px); margin: auto; padding: 22px 24px 68px; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
#environment-note { margin: 0; padding: 8px 12px; border: 1px solid #e5d9bd; border-radius: 999px; background: var(--gold-100); color: #73551e; font-size: 12px; }
#identity { min-height: 28px; margin-top: 0; padding: 4px 0; color: var(--teal-700); font-size: 13px; font-weight: 700; text-align: right; }
#identity:not(:empty)::before { content: "当前身份 · "; color: var(--muted); font-weight: 400; }

h1, h2, h3 { color: var(--navy-950); line-height: 1.38; text-wrap: balance; }
h1 { margin: 8px 0 10px; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.025em; }
h2 { margin: 4px 0 10px; font-size: 20px; }
h3 { margin: 12px 0 8px; font-size: 17px; }
p { margin: 9px 0; }
.page-heading { margin: 8px 0 22px; }
.page-heading .eyebrow, .eyebrow { margin-bottom: 5px; color: var(--teal-700); font-size: 12px; font-weight: 700; letter-spacing: .14em; }
.page-heading p { max-width: 680px; margin-bottom: 0; color: var(--muted); }

.card { margin: 14px 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-1); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 24px; }
.summary-card { min-height: 112px; padding: 17px 18px; border: 1px solid var(--line); border-top: 3px solid var(--teal-600); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-1); }
.summary-card strong { display: block; color: var(--teal-700); font-size: 30px; line-height: 1.25; }
.summary-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.summary-card.attention { border-top-color: var(--gold-600); }
.summary-card.attention strong { color: #8a5d18; }

.login-layout { display: grid; grid-template-columns: minmax(0, .92fr) minmax(360px, 1.08fr); max-width: 900px; margin: 38px auto 28px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-2); }
.login-intro { padding: 38px 34px; color: white; background: linear-gradient(145deg, var(--navy-950), #173d58); }
.login-intro h1, .login-intro h2 { color: white; }
.login-intro h1 { font-family: "STSong", "SimSun", serif; font-size: 31px; font-weight: 700; }
.login-intro p { color: #c8d9e1; }
.login-intro .eyebrow { color: #dfbd7d; }
.login-points { margin: 26px 0 0; padding: 0; list-style: none; }
.login-points li { position: relative; margin: 13px 0; padding-left: 20px; color: #e5eef2; font-size: 14px; }
.login-points li::before { content: ""; position: absolute; left: 0; top: .65em; width: 7px; height: 7px; border: 1px solid #dfbd7d; transform: rotate(45deg); }
.login-panel { padding: 34px; }
.login-panel h2 { font-size: 25px; }
.login-panel form { margin-top: 22px; }
.login-footnote { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); }

button, .button { min-height: 44px; padding: 9px 15px; border-color: var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); font-weight: 500; transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease; }
button:hover { border-color: var(--teal-600); box-shadow: 0 2px 8px rgba(12, 35, 54, .07); }
button:active { transform: translateY(1px); box-shadow: none; }
button.primary { border-color: var(--teal-700); background: var(--teal-700); }
button.primary:hover { border-color: #0e5b57; background: #0e5b57; }
button:disabled, body[data-busy="true"] button:disabled { opacity: .56; cursor: wait; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(24, 124, 118, .28); outline-offset: 2px; }

label { color: var(--ink); font-weight: 600; }
input, textarea, select { border-color: var(--line-strong); border-radius: var(--radius-sm); transition: border-color .15s ease, box-shadow .15s ease; }
input:hover, textarea:hover, select:hover { border-color: #91a9b2; }
textarea { min-height: 112px; resize: vertical; }
.password-field { position: relative; }
.password-field input { padding-right: 72px; }
.password-toggle { position: absolute; right: 5px; bottom: 5px; min-height: 36px; padding: 4px 9px; display: inline-flex; align-items: center; border: 0; border-radius: 6px; color: var(--teal-700); background: transparent; font-size: 13px; cursor: pointer; }
.password-toggle:hover { background: var(--teal-100); }
.check { padding: 7px 0; font-weight: 400; }

.tag { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; background: var(--teal-100); color: var(--teal-700); font-weight: 700; white-space: nowrap; }
.case { position: relative; margin: 11px 0; padding: 18px 20px; border-color: var(--line); border-radius: var(--radius-md); background: var(--surface); white-space: normal; }
.case:hover { border-color: #8eb2b2; background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-1); }
.case strong { font-size: 16px; }
.case small { margin-top: 5px; }
.case > p { margin-bottom: 0; }
.account-list { display: grid; gap: 10px; }
.account-row { margin: 0; }
.account-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 5px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-tools { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr); gap: 14px; margin-top: 22px; }
.admin-tools .card { margin: 0; }
.own-security { align-self: start; border-top: 3px solid var(--gold-600); }
#account-result .card { margin-top: 16px; background: var(--success-soft); }
#initial-password { font-family: ui-monospace, "Cascadia Mono", monospace; }
.empty { border-color: #b7c7cc; border-radius: var(--radius-md); }
.empty::before { content: "—"; display: block; margin-bottom: 6px; color: #9aaab0; font-size: 22px; }

#workflow-nav {
  position: sticky;
  z-index: 12;
  top: 80px;
  margin: -2px 0 22px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 254, 250, .94);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(12px);
}
#workflow-nav button { flex: 1; min-width: 128px; border: 0; background: transparent; color: var(--muted); }
#workflow-nav button:hover { color: var(--teal-700); background: var(--teal-100); box-shadow: none; }
.section-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.section-title > span { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; background: var(--navy-900); color: white; font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.section-title h2 { margin: 2px 0 3px; }
.section-title p { margin: 0; }
#routing-fields details { padding: 10px 0; }
#routing-fields summary { display: flex; align-items: center; min-height: 44px; color: var(--navy-900); }
#routing-fields summary::after { content: "展开／收起"; margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.recommendation { border-color: #bddad5; background: linear-gradient(135deg, #edf7f4, #f9fcfb); }
.recommendation h3 { color: var(--teal-700); font-size: 21px; }
.prewrap { line-height: 1.8; }
.wide { width: 100%; }

#message:not(:empty) { border: 1px solid #edc9c5; background: var(--danger-soft); }
#message[data-kind="success"] { border-color: #b8ddd3; background: var(--success-soft); }
.login-feedback:not(:empty) { margin: 14px 0 2px; padding: 11px 13px; border: 1px solid #edc9c5; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }
.login-feedback[data-kind="success"] { border-color: #b8ddd3; background: var(--success-soft); color: var(--teal); }
dl { grid-template-columns: 112px minmax(0, 1fr); gap: 10px 16px; }
footer { padding: 0 20px 26px; color: #7b8c95; font-size: 12px; text-align: center; }

@media (max-width: 760px) {
  .header-shell { min-height: 70px; padding: 11px 16px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; font-size: 18px; }
  .brand-block strong { font-size: 18px; }
  .brand-block small { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { gap: 5px; }
  .header-button { min-height: 40px; padding: 7px 10px; font-size: 13px; }
  main { padding: 16px 15px 54px; }
  .session-bar { align-items: flex-start; flex-direction: column; gap: 4px; }
  #identity { text-align: left; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .login-layout { display: block; margin: 20px auto; }
  .login-intro { padding: 25px 22px; }
  .login-intro h1 { font-size: 26px; }
  .login-points { display: none; }
  .login-panel { padding: 24px 22px; }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 17px; }
  dl { grid-template-columns: 88px minmax(0, 1fr); gap: 9px 12px; }
  .account-row { align-items: flex-start; }
  .account-actions { width: 100%; }
  .admin-tools { grid-template-columns: 1fr; }
  #workflow-nav { top: 70px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  #workflow-nav::-webkit-scrollbar { display: none; }
  #workflow-nav button { flex: 1 1 0; min-width: 0; padding-inline: 7px; font-size: 13px; }
}

@media (max-width: 430px) {
  .brand-block small, .brand-mark { display: none; }
  .header-button { padding-inline: 9px; }
  h1 { font-size: 27px; }
  .summary-card { min-height: 100px; padding: 14px; }
  .summary-card strong { font-size: 27px; }
  .row > button { max-width: 100%; }
}

@media (max-width: 350px) {
  #workflow-nav button { flex: 0 0 108px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .app-header, .session-bar, #workflow-nav, button, footer, .skip-link { display: none !important; }
  body { background: white; }
  main { width: auto; padding: 0; }
  .card, .case { box-shadow: none; break-inside: avoid; }
}
