:root {
  --ink: #172033;
  --muted: #60708a;
  --line: #dce4ee;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --blue: #175cd3;
  --blue-soft: #e8f0ff;
  --orange: #f79009;
  --orange-soft: #fff0cf;
  --green: #039855;
  --green-soft: #d9f7e8;
  --red: #d92d20;
  --red-soft: #fee4e2;
  --gray: #98a2b3;
  --gray-soft: #eaecf0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.app-shell { min-height: 100vh; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #eaf2ff 0%, #f6f8fc 45%, #e8f7ef 100%); }
.login-panel { width: min(100%, 400px); padding: 32px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 42px rgba(19, 38, 69, .1); }
.brand { display: flex; gap: 11px; align-items: center; font-size: 18px; font-weight: 780; letter-spacing: 0; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: var(--blue); color: white; border-radius: 7px; font-size: 16px; }
.login-panel h1 { margin: 34px 0 8px; font-size: 26px; }
.login-panel p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.field { display: grid; gap: 7px; font-size: 13px; font-weight: 650; color: #344054; }
.field input, .field select { min-height: 42px; width: 100%; padding: 9px 11px; color: var(--ink); border: 1px solid #b9c5d5; border-radius: 6px; background: #fff; outline: none; }
.field input:focus, .field select:focus, .search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 92, 211, .13); }
.field-span { grid-column: 1 / -1; }

.button { min-height: 38px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 6px; font-size: 14px; font-weight: 700; letter-spacing: 0; }
.button-primary { color: white; background: var(--blue); border-color: var(--blue); }
.button-primary:hover { background: #0b4eb8; }
.button-secondary { color: #344054; background: white; border-color: #cbd5e1; }
.button-secondary:hover { background: #f8fafc; }
.button-danger { color: #b42318; background: #fff; border-color: #fecdca; }
.button-wide { width: 100%; margin-top: 18px; }
.button:disabled { opacity: .52; }
.text-button { padding: 7px 5px; color: var(--blue); background: transparent; border: none; font-size: 14px; font-weight: 700; }
.text-button.text-danger { color: #b42318; }
.status-link { padding: 0; color: #0b4eb8; background: transparent; border: 0; border-bottom: 1px solid currentColor; font: inherit; font-weight: 700; }
.status-link:hover { color: #063a8b; }
.class-display-actions { display: flex; justify-content: space-between; margin: -4px 0 12px; }
.class-display-list { max-height: min(52vh, 430px); overflow: auto; border-top: 1px solid var(--line); }
.class-display-option { min-height: 47px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid var(--line); color: #344054; font-size: 14px; font-weight: 650; }
.class-display-option input { width: 16px; height: 16px; accent-color: var(--blue); }
.class-display-option small { color: var(--muted); font-size: 12px; font-weight: 600; }

.topbar { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 max(20px, calc((100vw - 1200px) / 2)); background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar-left, .topbar-right, .view-tabs, .toolbar, .inline-actions { display: flex; align-items: center; gap: 10px; }
.view-tabs { margin-left: 22px; height: 64px; }
.tab { height: 64px; padding: 0 4px; margin: 0 8px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; }
.tab.is-active { border-color: var(--blue); color: var(--blue); }
.page { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: 0; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.view-controls { position: sticky; top: 64px; z-index: 6; padding: 24px 0 1px; margin-top: -24px; background: var(--canvas); }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 27px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: white; }
.summary-item { min-height: 84px; display: grid; align-content: center; padding: 14px 18px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span { color: var(--muted); font-size: 12px; font-weight: 650; }
.summary-item strong { margin-top: 5px; font-size: 24px; }
.toolbar { justify-content: space-between; padding: 10px 0; margin: 0 0 18px; }
.toolbar-filters { display: flex; align-items: center; gap: 10px; }
.search { position: relative; width: min(340px, 100%); }
.search input { width: 100%; height: 39px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; outline: none; }
.gender-filter { display: inline-flex; overflow: hidden; border: 1px solid #cbd5e1; border-radius: 6px; background: white; }
.filter-button { min-width: 76px; height: 37px; padding: 7px 12px; color: #475467; background: white; border: 0; border-right: 1px solid #cbd5e1; font-size: 13px; font-weight: 700; }
.filter-button:last-child { border-right: 0; }
.filter-button.is-active { color: #0b4eb8; background: var(--blue-soft); }
.color-filter { display: inline-flex; overflow: hidden; border: 1px solid #cbd5e1; border-radius: 6px; background: white; }
.color-filter .filter-button { min-width: 54px; }
.color-filter .filter-button span { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.color-filter .color-blue { color: var(--blue); }
.color-filter .color-orange { color: #b54708; }
.color-filter .color-green { color: var(--green); }
.color-filter .color-red { color: var(--red); }
.color-filter .color-gray { color: #667085; }
.color-filter .color-proxy { color: var(--red); }
.color-filter .color-proxy span { background: linear-gradient(90deg, var(--red) 0 50%, #667085 50% 100%); }
.class-filter select { height: 37px; min-width: 190px; padding: 7px 30px 7px 11px; color: #344054; border: 1px solid #cbd5e1; border-radius: 6px; background: white; font-size: 13px; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.gender-lock { min-height: 37px; display: inline-flex; align-items: center; padding: 7px 12px; color: #0b4eb8; border: 1px solid #9cc1ff; border-radius: 6px; background: var(--blue-soft); font-size: 13px; font-weight: 700; }
.gender-section + .gender-section { margin-top: 38px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 13px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.person-tile { min-height: 117px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 15px; border: 1px solid transparent; border-radius: 7px; text-align: left; transition: transform .15s, box-shadow .15s; }
.person-tile:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(25, 44, 76, .13); }
.person-tile:focus-visible { outline: 3px solid rgba(23, 92, 211, .35); outline-offset: 2px; }
.person-tile .tile-name { color: #172033; font-size: 17px; font-weight: 780; word-break: break-word; }
.person-tile .tile-meta { color: rgba(23,32,51,.72); font-size: 12px; }
.person-tile .tile-status { display: -webkit-box; overflow: hidden; margin-top: 8px; color: rgba(23,32,51,.78); font-size: 12px; line-height: 1.4; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.person-tile .tile-class { display: -webkit-box; overflow: hidden; margin-top: 5px; color: rgba(23,32,51,.68); font-size: 12px; line-height: 1.4; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.tone-blue { background: var(--blue-soft); border-color: #c7dbff; }
.tone-orange { background: var(--orange-soft); border-color: #fedf89; }
.tone-green { background: var(--green-soft); border-color: #a6edc8; }
.tone-red { background: var(--red-soft); border-color: #fecdca; }
.tone-gray { background: var(--gray-soft); border-color: #d0d5dd; opacity: .75; }
.delegate-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 15px; margin-bottom: 24px; border-left: 4px solid var(--blue); background: #eaf2ff; color: #1d3d79; font-size: 14px; }
.empty { display: grid; place-items: center; min-height: 230px; padding: 24px; border: 1px dashed #b9c5d5; background: #fafcff; color: var(--muted); text-align: center; }
.empty p { margin: 0 0 13px; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(16, 24, 40, .46); }
.modal { width: min(100%, 660px); max-height: calc(100vh - 36px); overflow: auto; padding: 24px; background: var(--paper); border-radius: 8px; box-shadow: 0 24px 65px rgba(16, 24, 40, .28); }
.modal.narrow { width: min(100%, 430px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; padding: 0; color: #475467; background: #f2f4f7; border: 1px solid #dfe3e8; border-radius: 6px; font-size: 21px; line-height: 1; }
.info-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.info-list div { min-height: 74px; padding: 12px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.info-list dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.info-list dd { margin: 0; overflow-wrap: anywhere; color: #1d2939; font-size: 14px; font-weight: 700; }
.detail-section { margin-top: 26px; }
.detail-section h3 { margin: 0 0 11px; font-size: 15px; }
.mode-select { display: flex; gap: 0; }
.mode-button { flex: 1; min-height: 39px; padding: 8px; color: #475467; background: white; border: 1px solid #cbd5e1; font-size: 14px; font-weight: 700; }
.mode-button:first-child { border-radius: 6px 0 0 6px; }
.mode-button:last-child { margin-left: -1px; border-radius: 0 6px 6px 0; }
.mode-button.is-active { position: relative; z-index: 1; color: #0b4eb8; border-color: var(--blue); background: var(--blue-soft); }
.status-panel { min-height: 46px; display: flex; align-items: center; padding: 11px 13px; border-left: 3px solid var(--blue); background: #f5f9ff; color: #344054; font-size: 14px; }
.status-panel.orange { border-left-color: var(--orange); background: #fffaeb; }
.status-panel.green { border-left-color: var(--green); background: #ecfdf3; }
.status-panel.red { border-left-color: var(--red); background: #fff5f4; }
.stage-line { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stage { min-height: 82px; display: grid; align-content: center; justify-items: center; gap: 7px; padding: 9px; border: 1px solid #d0d5dd; border-radius: 6px; background: white; color: #667085; font-size: 13px; font-weight: 700; }
.stage span { width: 11px; height: 11px; border-radius: 50%; background: #d0d5dd; }
.stage.current { color: #027a48; border-color: #81d4a8; background: var(--green-soft); animation: stage-pulse 1.1s ease-in-out infinite; }
.stage.current span { background: var(--green); }
.stage.next { color: #0b4eb8; border-color: #9cc1ff; background: var(--blue-soft); }
.stage.next span { background: var(--blue); }
.stage.previous { color: #027a48; border-color: #81d4a8; background: var(--green-soft); }
.stage.previous span { background: var(--green); }
.stage.unavailable { color: #667085; border-color: #d0d5dd; background: var(--gray-soft); }
.stage.unavailable span { background: var(--gray); }
.stage:disabled { cursor: default; }
@keyframes stage-pulse { 50% { box-shadow: 0 0 0 4px rgba(3, 152, 85, .18); } }
@media (prefers-reduced-motion: reduce) { .stage.current { animation: none; } }
.detail-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 27px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.notice { min-height: 20px; margin: 12px 0 0; color: #b42318; font-size: 13px; }
.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 44px)); padding: 12px 15px; color: #fff; background: #1d2939; border-radius: 6px; box-shadow: 0 10px 30px rgba(16,24,40,.24); font-size: 14px; }

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 62px; align-items: flex-start; padding: 12px 20px; }
  .topbar-left { flex-wrap: wrap; gap: 5px 10px; }
  .view-tabs { order: 3; width: 100%; height: 31px; margin: 0; }
  .tab { height: 31px; margin: 0 8px 0 0; }
  .topbar-right .button-secondary { width: 34px; overflow: hidden; padding: 0; font-size: 0; }
  .topbar-right .button-secondary:first-child::after { content: "◉"; font-size: 15px; }
  .topbar-right .button-secondary:last-child::after { content: "↪"; font-size: 18px; }
  .page { width: min(100% - 28px, 1200px); padding-top: 25px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .view-controls { top: 105px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-filters { width: 100%; flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .gender-filter { width: 100%; }
  .filter-button { flex: 1; }
  .color-filter { width: 100%; }
  .color-filter .filter-button { min-width: 0; }
  .class-filter, .class-filter select { width: 100%; }
  .gender-lock { width: 100%; justify-content: center; }
  .people-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .person-tile { min-height: 104px; padding: 12px; }
  .info-list, .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 19px; }
}
