/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航栏 */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-title {
  color: white;
  font-size: 24px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 用户菜单 */
.user-menu {
  position: relative;
  cursor: pointer;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.user-avatar:hover {
  background: rgba(255, 255, 255, 0.3);
}

.avatar-icon {
  font-size: 20px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  display: none;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-user-info {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.dropdown-username {
  display: block;
  font-weight: 600;
  color: #333;
}

.dropdown-role {
  display: block;
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.dropdown-divider {
  height: 1px;
  background: #eee;
}

.dropdown-item {
  display: block;
  padding: 12px 16px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: #f5f7fa;
}

/* 登录按钮 */
.login-btn {
  padding: 8px 20px;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}

/* 页签导航 */
.tabs {
  background: white;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #e8e8e8;
}

.tab {
  padding: 16px 24px;
  background: none;
  border: none;
  font-size: 15px;
  color: #666;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab:hover {
  color: #333;
}

.tab.active {
  color: #667eea;
  font-weight: 500;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #667eea;
  border-radius: 3px 3px 0 0;
}

/* 主内容区 */
.content {
  flex: 1;
  padding: 24px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 入口网格 */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

/* 入口卡片 */
.portal-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  display: block;
}

.portal-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.portal-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.portal-name {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
}

.portal-desc {
  font-size: 13px;
  color: #999;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px;
  color: #999;
  grid-column: 1 / -1;
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

/* 登录表单 */
.login-form {
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.form-error {
  color: #e74c3c;
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 18px;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.submit-btn:hover {
  opacity: 0.9;
}

.secondary-btn,
.link-btn {
  border: 1px solid #d7dce8;
  background: white;
  color: #40506f;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.secondary-btn:hover,
.link-btn:hover {
  border-color: #667eea;
  background: #f5f7ff;
  color: #4f63d7;
}

.link-btn {
  padding: 6px 10px;
  font-size: 13px;
}

.danger-btn {
  border-color: #f2c2c2;
  color: #c0392b;
}

.danger-btn:hover {
  border-color: #e74c3c;
  background: #fff5f5;
  color: #b83224;
}

.secondary-btn:disabled,
.link-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* 权限提示 */
.permission-message {
  padding: 24px;
  text-align: center;
  color: #666;
}

.permission-message p {
  margin-bottom: 8px;
}

/* 表单底部 */
.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: #666;
}

.form-footer a {
  color: #667eea;
  text-decoration: none;
  margin-left: 4px;
}

.form-footer a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 3000;
}

.toast {
  background: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in 0.3s ease-out;
  min-width: 280px;
}

.toast.success {
  border-left: 4px solid #667eea;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast-icon {
  font-size: 20px;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  color: #333;
}

@keyframes toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.settings-modal-content {
  max-width: 520px;
}

.settings-action-modal {
  max-width: 460px;
}

.account-list-modal-content {
  max-width: 920px;
}

.settings-home-modal {
  overflow: visible;
}

.settings-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 24px;
}

.settings-icon-card {
  min-height: 132px;
  border: 1px solid #e1e6f2;
  background: #fbfcff;
  border-radius: 8px;
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.2s;
}

.settings-icon-card:hover {
  border-color: #667eea;
  background: white;
  box-shadow: 0 8px 22px rgba(63, 81, 181, 0.12);
  transform: translateY(-2px);
}

.settings-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #edf2ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.settings-icon-label {
  color: #26334d;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.settings-action-body {
  padding: 24px;
}

.settings-note {
  color: #778094;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 460px;
}

.settings-nav {
  padding: 16px;
  border-right: 1px solid #eee;
  background: #fafbfe;
}

.settings-nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: block;
  margin-bottom: 8px;
  transition: background 0.2s, border-color 0.2s;
}

.settings-nav-item:hover,
.settings-nav-item.active {
  background: white;
  border-color: #dfe4f5;
}

.settings-nav-item.active {
  box-shadow: inset 3px 0 0 #667eea;
}

.settings-nav-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #26334d;
}

.settings-nav-desc {
  display: block;
  font-size: 12px;
  color: #7a8499;
  margin-top: 4px;
  line-height: 1.4;
}

.settings-panels {
  min-width: 0;
}

.settings-panel {
  display: none;
  padding: 24px;
}

.settings-panel.active {
  display: block;
}

.panel-heading {
  margin-bottom: 20px;
}

.panel-heading.with-action {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-heading h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.panel-heading p {
  font-size: 13px;
  color: #778094;
  line-height: 1.5;
}

.settings-action-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.settings-action-card {
  border: 1px solid #e1e6f2;
  background: #fbfcff;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.settings-action-card:hover {
  border-color: #667eea;
  background: white;
  box-shadow: 0 6px 18px rgba(63, 81, 181, 0.12);
}

.settings-action-title {
  display: block;
  color: #26334d;
  font-size: 15px;
  font-weight: 600;
}

.settings-action-desc {
  display: block;
  color: #778094;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 6px;
}

.settings-form,
.inline-create-form {
  max-width: 480px;
}

.inline-create-form {
  max-width: none;
  padding: 16px;
  border: 1px solid #e8ebf3;
  border-radius: 8px;
  margin-bottom: 18px;
  background: #fbfcff;
}

.inline-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-form-header h4 {
  color: #26334d;
  font-size: 15px;
  font-weight: 600;
}

.admin-only-section {
  display: none;
}

.admin-only-section.visible {
  display: block;
}

.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: white;
}

.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 140px;
  gap: 12px;
}

.compact-field {
  min-width: 120px;
}

.user-list-status {
  min-height: 18px;
  color: #778094;
  font-size: 13px;
  margin-bottom: 10px;
}

.user-list {
  border: 1px solid #e8ebf3;
  border-radius: 8px;
  overflow: hidden;
}

.user-list-empty {
  padding: 24px;
  text-align: center;
  color: #778094;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) 110px 110px minmax(220px, 1.8fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eef1f7;
}

.user-row:last-child {
  border-bottom: none;
}

.user-main {
  min-width: 0;
}

.user-name {
  display: block;
  color: #26334d;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  display: block;
  color: #8a94a8;
  font-size: 12px;
  margin-top: 3px;
}

.user-role-select {
  width: 100%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: #3153c7;
  background: #edf2ff;
}

.status-pill.inactive {
  color: #9a3412;
  background: #fff3e6;
}

.user-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.reset-password-panel {
  padding: 0 16px 16px 16px;
  background: #fbfcff;
  border-bottom: 1px solid #eef1f7;
}

.user-item:last-child .reset-password-panel {
  border-bottom: none;
}

.reset-password-panel label {
  display: block;
  color: #667085;
  font-size: 13px;
  margin-bottom: 8px;
}

.reset-password-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.reset-password-controls input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.reset-password-controls input:focus {
  outline: none;
  border-color: #667eea;
}

body.logged-in .login-btn {
  display: none !important;
}

body:not(.logged-in) .login-btn {
  display: inline-block !important;
}

@media (max-width: 760px) {
  .settings-shell {
    grid-template-columns: 1fr;
  }

  .settings-icon-grid {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    border-right: none;
    border-bottom: 1px solid #eee;
  }

  .settings-panel {
    padding: 18px;
  }

  .panel-heading.with-action,
  .form-row,
  .user-row,
  .reset-password-controls {
    grid-template-columns: 1fr;
  }

  .panel-heading.with-action {
    display: grid;
  }

  .panel-actions {
    justify-content: flex-start;
  }

  .user-actions {
    justify-content: flex-start;
  }
}
