:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --text: #1f1f1f;
  --text-secondary: #595959;
  --border: #f0f0f0;
  --bg: #f5f6f8;
  --card: #ffffff;
  --danger: #ff4d4f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  color: var(--primary-hover);
}

.hidden {
  display: none !important;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: #f5f6f8;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(22, 119, 255, 0.08) 0 1px, transparent 1.5px),
    radial-gradient(circle at 88% 82%, rgba(22, 119, 255, 0.07) 0 1px, transparent 1.5px),
    linear-gradient(135deg, transparent 48%, rgba(22, 119, 255, 0.04) 49%, transparent 51%),
    linear-gradient(180deg, #f7f8fa 0%, #f0f2f5 100%);
  background-size: 28px 28px, 28px 28px, 120px 120px, auto;
}

.login-wrap {
  width: 380px;
  max-width: 100%;
  text-align: center;
}

.login-brand {
  font-size: 40px;
  font-weight: 700;
  font-style: italic;
  margin-bottom: 36px;
  background: linear-gradient(90deg, #1677ff 0%, #69b1ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
}

.login-field {
  position: relative;
  margin-bottom: 16px;
}

.login-field input {
  width: 100%;
  height: 44px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 0 40px 0 40px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.login-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  pointer-events: none;
}

.pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.login-submit {
  height: 44px;
  margin-top: 8px;
  border-radius: 4px;
  font-size: 16px;
}

.login-extra {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.login-extra a {
  color: #69b1ff;
  font-size: 13px;
}

.login-support {
  margin-top: 48px;
  color: #bfbfbf;
  font-size: 12px;
}

.forgot-wrap {
  text-align: left;
}

.forgot-wrap .login-brand {
  text-align: center;
  margin-bottom: 18px;
}

.forgot-title {
  text-align: center;
  font-size: 18px;
  color: #595959;
  margin-bottom: 24px;
}

.login-field.no-icon input {
  padding-left: 12px;
}

.code-row .code-input input {
  padding-left: 40px;
}

.code-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.code-row .code-input {
  flex: 1;
  margin-bottom: 0;
}

.btn-code {
  height: 44px;
  min-width: 110px;
  padding: 0 14px;
  border: 1px solid #91caff;
  color: #1677ff;
  background: #fff;
  border-radius: 4px;
  white-space: nowrap;
}

.btn-code:disabled {
  color: #8c8c8c;
  border-color: #d9d9d9;
  cursor: not-allowed;
}

.forgot-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.forgot-actions .btn-primary {
  min-width: 120px;
  height: 40px;
}

.forgot-actions a {
  color: #1677ff;
  font-size: 14px;
  white-space: nowrap;
}

.forgot-wrap .login-support {
  text-align: center;
}

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

.form-item label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-item input,
.form-item textarea,
.form-item select {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 9px 12px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-item input:focus,
.form-item textarea:focus,
.form-item select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.15);
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: all 0.2s;
}

.btn:hover {
  opacity: 0.92;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-default {
  border-color: #d9d9d9;
  background: #fff;
}

.btn-block {
  width: 100%;
}

.login-hint {
  margin-top: 16px;
  font-size: 12px;
  color: #8c8c8c;
  line-height: 1.6;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}

/* App shell */
.app-header {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 22px;
  font-weight: 700;
  font-style: italic;
  color: var(--primary);
}

.nav-tabs {
  display: flex;
  gap: 36px;
  height: 100%;
}

.nav-tab {
  height: 100%;
  display: flex;
  align-items: center;
  color: var(--text);
  border-bottom: 2px solid transparent;
  font-size: 15px;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}

.user-profile-link:hover {
  color: var(--primary);
}

.settings-layout {
  display: flex;
  gap: 0;
  min-height: 520px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.settings-side {
  width: 200px;
  background: #fafafa;
  border-right: 1px solid var(--border);
  padding: 16px 0;
}

.settings-menu {
  display: block;
  padding: 12px 20px;
  color: var(--text);
  border-right: 3px solid transparent;
}

.settings-menu.active {
  background: #e6f4ff;
  color: var(--primary);
  border-right-color: var(--primary);
  font-weight: 600;
}

.settings-main {
  flex: 1;
  box-shadow: none;
  border-radius: 0;
  padding: 28px 40px 40px;
}

.settings-title {
  margin: 0 0 28px;
  font-size: 22px;
  font-weight: 600;
}

.profile-form {
  max-width: 420px;
}

.profile-form .form-item {
  margin-bottom: 20px;
}

.profile-form .form-item label {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.profile-form .form-item input {
  height: 40px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #69b1ff, #1677ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.logout-btn {
  margin-left: 8px;
  color: #8c8c8c;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--primary);
}

.app-main {
  max-width: 1180px;
  margin: 20px auto;
  padding: 0 20px 40px;
}

.panel {
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  padding: 20px 24px;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

table.data-table th,
table.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

table.data-table th {
  color: var(--text-secondary);
  font-weight: 500;
  background: #fafafa;
}

table.data-table td.ops a {
  margin-right: 12px;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: 13px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.page-btn.active {
  color: var(--primary);
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Message board */
.composer textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 12px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.composer-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.selected-meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.message-list {
  margin-top: 28px;
}

.message-item {
  padding: 0;
  border-bottom: 1px solid #e8e8e8;
}

.message-card {
  padding: 20px 4px 18px;
}

.message-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.message-author {
  font-weight: 400;
  color: #8c8c8c;
  font-size: 14px;
}

.message-resource {
  color: #1677ff;
  font-size: 14px;
}

.message-resource:hover {
  color: #4096ff;
}

.message-body {
  color: #1f1f1f;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 15px;
}

.msg-attach-wrap {
  margin: 4px 0 14px;
}

.msg-attach-label {
  color: #1677ff;
  font-size: 13px;
  margin-bottom: 8px;
}

.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #1677ff;
}

.msg-attach-file:hover {
  color: #4096ff;
}

.msg-attach-file span {
  font-size: 14px;
}

.paperclip {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.paperclip-lg {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: #262626;
  stroke: #262626;
}

.attach-preview {
  margin-top: 14px;
  display: inline-flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 100%;
}

.attach-preview .msg-attach-wrap {
  margin: 0;
}

.attach-preview-remove {
  border: none;
  background: transparent;
  color: #bfbfbf;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  margin-top: 22px;
}

.attach-preview-remove:hover {
  color: var(--danger);
}

.message-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #8c8c8c;
  font-size: 13px;
}

.message-foot a {
  color: #1677ff;
}

.message-foot a:hover {
  color: #4096ff;
}

.resource-msg-content {
  font-weight: 700;
}

.reply-box {
  margin-top: 12px;
  padding: 12px;
  background: #fafafa;
  border-radius: 6px;
}

.reply-box textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
}

.reply-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.children {
  margin-top: 12px;
  padding-left: 18px;
  border-left: 2px solid #e6f4ff;
}

.child-item {
  margin-bottom: 10px;
  font-size: 13px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 560px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  max-height: 80vh;
  overflow: auto;
}

.modal h3 {
  margin: 0 0 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: #8c8c8c;
  cursor: pointer;
  padding: 0 4px;
}

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

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.attach-modal {
  width: 520px;
}

.attach-form {
  padding: 0 4px;
}

.attach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.attach-row > label {
  width: 72px;
  flex-shrink: 0;
  text-align: right;
  color: var(--text);
  font-size: 14px;
}

.attach-row input[type='text'] {
  flex: 1;
  height: 36px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 0 12px;
  outline: none;
}

.attach-row input[type='text']:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.attach-file-row {
  align-items: flex-start;
}

.attach-dropzone {
  width: 104px;
  height: 104px;
  border: 1px dashed #d9d9d9;
  border-radius: 4px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #bfbfbf;
  transition: border-color 0.2s, color 0.2s;
  position: relative;
  overflow: hidden;
}

.attach-dropzone:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.attach-plus {
  font-size: 36px;
  line-height: 1;
  font-weight: 300;
}

.attach-file-name {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 6px;
  font-size: 11px;
  color: #595959;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-modal {
  width: 720px;
  max-width: calc(100vw - 32px);
}

.resource-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.resource-search label {
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.resource-search input {
  flex: 1;
  height: 34px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 0 12px;
  outline: none;
}

.resource-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.resource-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.resource-picker-table th,
.resource-picker-table td {
  padding: 12px 14px;
}

.resource-picker-table tbody tr {
  cursor: pointer;
}

.resource-picker-table tbody tr:hover {
  background: #f5faff;
}

.resource-picker-table .res-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.resource-msg-modal {
  width: 760px;
  max-width: calc(100vw - 32px);
  padding: 0 0 12px;
}

.resource-msg-modal .modal-header {
  padding: 14px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.resource-msg-list {
  max-height: 520px;
  overflow: auto;
  padding: 0 20px;
}

.resource-msg-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.resource-msg-card {
  border-left: 3px solid #d9d9d9;
  padding-left: 14px;
}

.resource-msg-content {
  font-weight: 600;
  margin: 8px 0 10px;
}

.resource-msg-empty {
  text-align: center;
  color: #8c8c8c;
  padding: 48px 0;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 100;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

.toast.toast-warn {
  background: #fffbe6;
  color: #ad6800;
  border: 1px solid #ffe58f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toast.toast-warn::before {
  content: "!";
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  background: #fa8c16;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: -1px;
}

.role-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  background: #e6f4ff;
  color: var(--primary);
}

@media (max-width: 720px) {
  .app-header {
    padding: 0 12px;
    gap: 8px;
  }

  .nav-tabs {
    gap: 16px;
  }

  .brand {
    font-size: 18px;
  }

  .panel {
    padding: 14px;
  }

  table.data-table th:nth-child(3),
  table.data-table td:nth-child(3),
  table.data-table th:nth-child(4),
  table.data-table td:nth-child(4) {
    display: none;
  }
}
