:root {
  color-scheme: light;
  --page: #f6f8fb;
  --surface: #ffffff;
  --line: #d7dee8;
  --line-strong: #c9d2df;
  --text: #172033;
  --muted: #6a7280;
  --faint: #98a2b3;
  --blue: #1769e0;
  --blue-hover: #0f58c7;
  --blue-soft: #eaf2ff;
  --red: #d92d20;
  --red-soft: #fff1f0;
  --green: #167044;
  --green-soft: #ecfdf3;
  --amber: #946200;
  --amber-soft: #fff7df;
  --shadow: 0 18px 42px rgba(24, 39, 75, 0.08);
}

html {
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.staff-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  background: var(--page);
}

.institution-sidebar {
  min-height: 100vh;
  padding: 34px 24px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.institution-sidebar h1 {
  margin: 0 0 22px;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--faint);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.institution-list {
  display: grid;
  gap: 2px;
}

.institution-item {
  width: 100%;
  min-width: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.institution-item:hover:not(:disabled) {
  background: #f2f5f9;
}

.institution-item.active {
  border-left-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.institution-item:disabled {
  color: var(--faint);
  cursor: not-allowed;
}

.staff-main {
  min-width: 0;
  padding: 40px 44px;
}

.staff-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 24px;
}

.staff-header h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.auth-box {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-box[hidden] {
  display: none;
}

.auth-box a {
  color: var(--blue);
  text-decoration: none;
}

.auth-box a:hover {
  text-decoration: underline;
}

.status-badge {
  min-width: 86px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.staff-card {
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.staff-form {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  padding: 28px 32px 30px;
}

.staff-form h3 {
  margin: 0 0 28px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.staff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  column-gap: 44px;
  row-gap: 26px;
}

.staff-field {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.staff-field[hidden] {
  display: none;
}

.staff-field span {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.staff-field strong {
  color: var(--red);
  font-weight: 900;
}

.staff-field input,
.staff-field select {
  width: 100%;
  height: 46px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  background: #fff;
  color: var(--text);
}

.staff-field input:focus,
.staff-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.staff-field input::placeholder {
  color: var(--faint);
}

.mobile-select-button {
  width: 100%;
  height: 48px;
  min-width: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-align: left;
}

.mobile-select-button.empty {
  color: var(--faint);
}

.mobile-select-button span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.staff-messages {
  min-height: 52px;
  display: grid;
  align-content: start;
  gap: 8px;
  margin-top: 24px;
}

.staff-message {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
}

.staff-message a {
  flex: 0 0 auto;
  color: inherit;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.staff-message.success {
  background: var(--green-soft);
  color: var(--green);
}

.staff-message.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.staff-message.error {
  background: var(--red-soft);
  color: var(--red);
}

.staff-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: auto;
}

.staff-actions button {
  width: 138px;
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.staff-actions button:hover:not(:disabled) {
  background: var(--blue-hover);
}

.staff-actions button.secondary {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.staff-actions button.secondary:hover:not(:disabled) {
  background: #f2f5f9;
}

.staff-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.mobile-picker[hidden] {
  display: none;
}

.mobile-picker {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.mobile-picker-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(23, 32, 51, 0.34);
}

.mobile-picker-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  border-radius: 8px 8px 0 0;
  background: #fff;
  box-shadow: 0 -18px 42px rgba(24, 39, 75, 0.14);
  overflow: hidden;
}

.mobile-picker-panel header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.mobile-picker-panel h4 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.mobile-picker-panel header button {
  height: 36px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 900;
}

.mobile-picker-options {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-picker-option {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  text-align: left;
}

.mobile-picker-option.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.mobile-picker-option.active::after {
  content: "已选";
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

body.picker-open {
  overflow: hidden;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--page);
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel header {
  padding: 28px 30px 20px;
  border-bottom: 1px solid var(--line);
}

.login-panel p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.login-panel h1 {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 18px;
  padding: 24px 30px 30px;
}

.login-message {
  min-height: 44px;
  margin-top: 0;
}

.login-form button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.login-form button:hover:not(:disabled) {
  background: var(--blue-hover);
}

.login-form button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (max-width: 860px) {
  .staff-page {
    grid-template-columns: 1fr;
  }

  .institution-sidebar {
    min-height: 0;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .institution-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .staff-main {
    padding: 24px 16px;
  }

  .staff-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .staff-form {
    min-height: 560px;
    padding: 22px 18px 24px;
  }

  .staff-grid {
    grid-template-columns: 1fr;
    row-gap: 18px;
  }
}

@media (max-width: 640px) {
  body {
    min-height: 100dvh;
  }

  .staff-page {
    display: block;
    min-height: 100dvh;
  }

  .institution-sidebar {
    padding: 14px 12px 12px;
    border-bottom: 1px solid var(--line);
  }

  .institution-sidebar h1 {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
  }

  .search-box {
    display: none;
  }

  .institution-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .institution-item {
    height: 42px;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    font-weight: 900;
    text-align: center;
  }

  .institution-item.active {
    border-color: var(--blue);
    background: var(--blue-soft);
  }

  .institution-item:disabled {
    background: #f4f6f9;
  }

  .staff-main {
    padding: 16px 12px calc(96px + env(safe-area-inset-bottom));
  }

  .staff-header {
    min-height: 0;
    flex-direction: row;
    align-items: flex-start;
    max-width: none;
    margin: 0 0 12px;
  }

  .staff-header h2 {
    font-size: 20px;
  }

  .auth-box {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
  }

  .status-badge {
    display: none;
  }

  .staff-card {
    max-width: none;
    border-color: var(--line);
    box-shadow: none;
  }

  .staff-form {
    min-height: 0;
    padding: 16px;
  }

  .staff-form h3 {
    margin-bottom: 16px;
    font-size: 18px;
  }

  .staff-grid {
    row-gap: 14px;
  }

  .staff-field {
    gap: 8px;
  }

  .staff-field span {
    font-size: 14px;
  }

  .staff-field input,
  .staff-field select {
    height: 48px;
    font-size: 16px;
  }

  .staff-field select {
    display: none;
  }

  .mobile-select-button {
    display: flex;
    font-size: 16px;
  }

  .mobile-select-button span {
    font-size: inherit;
  }

  .staff-messages {
    min-height: 44px;
    margin-top: 16px;
  }

  .staff-message {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .staff-actions {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    gap: 10px;
    margin: 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 28px rgba(24, 39, 75, 0.08);
  }

  .staff-actions button {
    width: auto;
    height: 48px;
  }

  .staff-actions button.secondary {
    flex: 0 0 34%;
  }

  .staff-actions button:not(.secondary) {
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .institution-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .staff-header h2 {
    font-size: 20px;
  }

  .staff-actions {
    gap: 10px;
  }

  .staff-actions button {
    width: auto;
  }
}
