:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #20262d;
  --muted: #6b7480;
  --line: #d9e0e7;
  --primary: #1167b1;
  --primary-dark: #0b4f8a;
  --ok: #16794f;
  --warn: #a86800;
  --bad: #ba2f2f;
  --soft-blue: #e9f2fb;
  --soft-green: #e8f5ef;
  --soft-amber: #fff3db;
  --soft-red: #fdecec;
  --shadow: 0 8px 24px rgba(19, 32, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-box p {
  margin: 0 0 24px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: #17202a;
  color: #f4f7fa;
  padding: 20px 14px;
}

.brand {
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  color: #b6c1cc;
  margin-top: 6px;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d8e0e7;
  border-radius: 6px;
  padding: 11px 12px;
}

.nav button.active,
.nav button:hover {
  background: #243444;
  color: #fff;
}

.nav button.nav-important {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #203143;
}

.nav button.nav-important.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(17, 103, 177, 0.28);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.content {
  padding: 22px;
  min-width: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-card.clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card.clickable:hover,
.stat-card.clickable:focus {
  border-color: #9fc2df;
  box-shadow: 0 8px 20px rgba(17, 103, 177, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

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

.panel-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar .search-input {
  width: min(360px, 100%);
  min-width: 260px;
}

.btn {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 6px;
  color: var(--text);
  background: #edf1f5;
  border: 1px solid #d7dee6;
}

.btn:hover {
  background: #e2e8ee;
}

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

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

.btn.danger {
  background: var(--soft-red);
  color: var(--bad);
  border-color: #f2c0c0;
}

.btn.danger:hover {
  background: #ffe2e2;
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 600;
  font-size: 13px;
}

td.wrap {
  white-space: normal;
  min-width: 240px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #edf1f5;
  color: var(--muted);
}

.badge.ok {
  background: var(--soft-green);
  color: var(--ok);
}

.badge.warn {
  background: var(--soft-amber);
  color: var(--warn);
}

.badge.bad {
  background: var(--soft-red);
  color: var(--bad);
}

.badge.info {
  background: var(--soft-blue);
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.dashboard-task-panel {
  overflow: visible;
}

.dashboard-subtitle {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.recent-task-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.recent-task-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(360px, 2fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.recent-task-title {
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.recent-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.recent-task-info {
  display: grid;
  grid-template-columns: 140px minmax(160px, 1fr) minmax(190px, 1fr);
  gap: 10px;
  align-items: center;
}

.recent-task-field {
  min-width: 0;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.field-value {
  min-width: 0;
  line-height: 1.7;
  word-break: break-word;
}

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

.mail-task-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.mail-task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.mail-task-main {
  min-width: 0;
}

.mail-task-title {
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.mail-task-meta,
.mail-task-route {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.mail-task-route span {
  word-break: break-all;
}

.mail-task-sync {
  margin-top: 8px;
  line-height: 1.6;
}

.mail-task-error {
  margin-top: 8px;
  color: var(--bad);
  line-height: 1.6;
}

.mail-task-side {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.mail-task-badges,
.mail-task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mail-task-attachment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.attachment-uploaded {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.attachment-file-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
}

.mail-workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.mail-book-panel,
.mail-author-panel {
  min-width: 0;
}

.mail-panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mail-book-search {
  width: 220px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.mail-book-list,
.author-mail-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.mail-author-panel .author-mail-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  align-items: start;
}

.mail-book-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
  color: var(--text);
}

.mail-book-card:hover,
.mail-book-card.active {
  border-color: #9fc2df;
  background: #f2f7fc;
}

.mail-book-card.active {
  box-shadow: 0 8px 20px rgba(17, 103, 177, 0.12);
}

.mail-book-card.urgent {
  border-left: 4px solid var(--bad);
}

.mail-book-title {
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.mail-book-meta,
.mail-book-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.warn-text {
  color: var(--warn);
  font-weight: 700;
}

.urgent-text {
  color: var(--bad);
  font-weight: 700;
}

.author-mail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 11px 12px;
}

.author-mail-row.active {
  border-color: #e5aaa5;
  background: #fffafa;
}

.author-mail-row.urgent {
  border-left: 4px solid var(--bad);
  background: #fff8f7;
}

.badge.urgent {
  color: #a82f26;
  background: #fdeceb;
  border-color: #efb8b3;
}

.author-mail-row.completed {
  opacity: 0.78;
}

.author-mail-main {
  min-width: 0;
}

.author-mail-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: baseline;
}

.author-mail-title span {
  color: var(--muted);
  word-break: break-all;
}

.stage-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.stage-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 2px 7px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.stage-pill.done {
  border-color: #bddfce;
  background: var(--soft-green);
  color: var(--ok);
}

.stage-pill.current {
  border-color: #e3a19b;
  background: #fdeceb;
  color: #b42318;
  font-weight: 700;
}

.author-current-task {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 9px;
  margin-top: 8px;
  align-items: center;
  color: var(--muted);
}

.current-stage {
  color: #b42318;
  font-weight: 700;
}

.author-mail-side {
  display: grid;
  gap: 8px;
  align-content: space-between;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.ai-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.ai-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.compact-form {
  gap: 10px;
}

.compact-form textarea {
  min-height: 74px;
}

.ai-main-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.ai-progress-panel {
  position: sticky;
  top: 18px;
}

.ai-progress-list {
  display: grid;
  gap: 10px;
}

.ai-progress-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

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

.ai-progress-section-title {
  margin-top: 18px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 15, 25, 0.44);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.notice {
  border-left: 4px solid var(--primary);
  background: var(--soft-blue);
  padding: 12px;
  border-radius: 6px;
  color: #1b4c75;
}

.preview-box {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
  line-height: 1.8;
}

.detail-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.business-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(232, 240, 248, 0.95), rgba(246, 248, 251, 1) 42%),
    var(--bg);
  padding: 36px 20px;
}

.business-container {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.business-topbar,
.business-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.business-topbar {
  margin-bottom: 26px;
}

.business-brand {
  text-align: center;
  flex: 1;
}

.business-kicker {
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.business-brand h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.business-brand p {
  max-width: 680px;
  margin: 10px auto 0;
  color: var(--muted);
  line-height: 1.7;
}

.business-user {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.business-search-card {
  width: min(720px, 100%);
  margin: 0 auto 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.business-search-card label {
  display: block;
  font-weight: 700;
  margin-bottom: 12px;
}

.business-search-row {
  display: flex;
  justify-content: center;
}

.business-search {
  width: min(560px, 100%);
  font-size: 18px;
  padding: 14px 16px;
  text-align: center;
}

.business-results {
  display: grid;
  gap: 16px;
  width: min(980px, 100%);
  margin: 0 auto;
}

.business-result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.business-result h3 {
  margin: 0 0 6px;
  font-size: 24px;
}

.business-progress {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.small-value {
  font-size: 18px;
}

.business-empty {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

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

  .sidebar {
    position: static;
  }

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

  .stats,
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .recent-task-card,
  .recent-task-info,
  .mail-task-card,
  .mail-workspace,
  .author-mail-row,
  .ai-two-column,
  .ai-source-grid,
  .ai-progress-item {
    grid-template-columns: 1fr;
  }

  .recent-task-actions,
  .mail-task-badges,
  .mail-task-actions,
  .mail-task-attachment,
  .attachment-uploaded,
  .ai-progress-actions {
    justify-content: flex-start;
  }

  .mail-task-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }

  .author-mail-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }

  .mail-panel-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .mail-book-search {
    flex: 1 1 220px;
  }

  .ai-progress-panel {
    position: static;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .business-topbar,
  .business-result-head {
    flex-direction: column;
    text-align: center;
  }

  .business-user {
    justify-content: center;
    flex-wrap: wrap;
  }

  .business-brand h1 {
    font-size: 28px;
  }
}
