:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --blue: #1f5fbf;
  --blue-soft: #edf5ff;
  --green: #107c5c;
  --amber: #9a5b00;
  --nav: #172033;
  --nav-2: #25344d;
  --shadow: 0 18px 45px rgba(16, 24, 40, .16);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row h1 { margin: 0; font-size: 24px; }
.brand-row p, .brand-row span { margin: 2px 0 0; color: var(--muted); }
.brand-row.compact { padding: 0 6px 12px; border-bottom: 1px solid var(--line); }
.brand-row.compact strong { display: block; color: var(--ink); font-size: 16px; }
.brand-row.compact span { color: var(--muted); }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #d8f3ea;
  color: #0b5f46;
  display: grid;
  place-items: center;
  font-weight: 800;
}
label { display: grid; gap: 6px; color: #344054; }
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.inline-check input { width: auto; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
}
textarea { min-height: 150px; resize: vertical; }
.hint, .muted, .empty { color: var(--muted); }
.wide { width: 100%; }
.primary, .ghost {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
}
.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
}
.sidebar {
  background: #f7f9fc;
  color: var(--ink);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--line);
}
.folder-nav { display: grid; gap: 4px; }
.folder-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #344054;
  padding: 0 10px;
}
.folder-nav button.active, .folder-nav button:hover { background: #e8f1ff; color: #17437d; }
.folder-nav b { color: #667085; font-size: 12px; }
.main { min-width: 0; display: grid; grid-template-rows: 58px minmax(0, 1fr); }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(460px, 1fr) minmax(260px, 420px);
  align-items: center;
  gap: 12px;
  padding: 0 12px;
}
.mail-toolbar, .topbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.topbar-right { justify-content: flex-end; }
.tool-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: #24324a;
}
.tool-button:hover:not(:disabled) { background: #f2f7ff; border-color: #c7d9f7; }
.tool-button:disabled { color: #a3adbd; cursor: not-allowed; }
.primary-tool {
  background: #1f5fbf;
  border-color: #1f5fbf;
  color: #fff;
  font-weight: 700;
}
.primary-tool:hover:not(:disabled) { background: #174f9f; border-color: #174f9f; }
.danger-tool:hover:not(:disabled) { background: #fff1f0; border-color: #ffccc7; color: #b42318; }
.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 3px;
}
.search {
  background: #f8fafc;
  max-width: 300px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
}
.message-list, .reader, .audit { min-height: 0; overflow: auto; }
.message-list { background: var(--panel); }
.message-list { border-right: 1px solid var(--line); }
.list-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 { margin: 0; font-size: 16px; }
.segment { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segment button { border: 0; background: #fff; height: 30px; padding: 0 9px; color: var(--muted); }
.segment button.active { background: var(--blue-soft); color: #17437d; }
.message-card {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  background: #fff;
  padding: 10px 13px;
  text-align: left;
  display: grid;
  gap: 5px;
}
.message-card.active { background: #f2f7ff; box-shadow: inset 3px 0 0 var(--blue); }
.message-card div { display: flex; justify-content: space-between; gap: 10px; }
.message-card span, .message-card p { color: var(--muted); margin: 0; }
.message-card strong, .message-card b, .message-card p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-card footer { display: flex; gap: 6px; flex-wrap: wrap; }
.message-card em {
  font-style: normal;
  border: 1px solid #c7d9f7;
  color: #17437d;
  background: #eff6ff;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
}
.reader { padding: 16px 20px 28px; background: #fbfcfe; }
.reader-head {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.reader-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.message-body { max-width: 860px; margin-top: 18px; display: grid; gap: 14px; }
.message-body p { margin: 0; }
.file-card {
  border: 1px solid #b8d7f4;
  background: #f1f8ff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  max-width: 660px;
}
.file-card > div:first-child {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d8ecff;
  color: #18599f;
  font-weight: 800;
}
.file-card section { display: grid; gap: 3px; }
.file-card span { color: var(--muted); font-size: 12px; }
.compose-attachments {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-title span { color: var(--muted); font-size: 12px; }
.attachment-list { display: grid; gap: 8px; }
.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.attachment-item b { display: block; font-size: 13px; }
.attachment-item span { color: var(--muted); font-size: 12px; }
.attachment-item em {
  padding: 3px 7px;
  border-radius: 999px;
  color: #0c5b3f;
  background: #dff8ec;
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}
.attachment-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.context-panel section { border-bottom: 1px solid #edf1f6; padding-bottom: 14px; margin-bottom: 14px; }
.context-panel h3 { margin: 0 0 10px; font-size: 15px; }
.context-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  display: grid;
  gap: 5px;
}
.context-card span, .context-card small { color: var(--muted); }
dl { display: grid; grid-template-columns: 82px 1fr; gap: 8px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; }

.audit { padding: 18px; background: #fbfcfe; }
.audit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.audit-grid div, table { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.audit-grid div { padding: 12px; }
.audit-grid span { color: var(--muted); font-size: 12px; }
.audit-grid strong { display: block; font-size: 26px; margin-top: 4px; }
.adapter-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.adapter-panel span, .adapter-panel small { display: block; color: var(--muted); font-size: 12px; }
.adapter-panel strong { display: block; margin-top: 3px; }
.adapter-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.audit h3 { margin: 18px 0 8px; font-size: 14px; }
table { width: 100%; border-collapse: collapse; overflow: hidden; }
th, td { padding: 9px 10px; border-bottom: 1px solid #edf1f6; text-align: left; }
th { background: #f2f6fb; color: #344054; font-size: 12px; }

dialog {
  border: 0;
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: min(760px, calc(100vw - 28px));
  padding: 0;
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-card { display: grid; gap: 12px; padding: 16px; }
.dialog-card header, .dialog-card footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-card footer { justify-content: flex-end; }
.icon { border: 1px solid var(--line); background: #fff; border-radius: 8px; min-width: 36px; min-height: 36px; }
.drop-zone { border: 1px dashed #8bb8e8; background: #f1f8ff; border-radius: 8px; padding: 18px; display: grid; gap: 10px; }
.progress { height: 8px; background: #e5edf6; border-radius: 999px; overflow: hidden; }
.progress i { display: block; width: 72%; height: 100%; background: var(--green); }
.result-box {
  max-height: 170px;
  overflow: auto;
  padding: 10px;
  margin: 0;
  color: #dbe7ff;
  background: #101827;
  border-radius: 8px;
  white-space: pre-wrap;
}
.erp-suggestions { display: grid; gap: 8px; }
.suggestion {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
}
.suggestion span { display: grid; gap: 3px; }
.suggestion small { color: var(--muted); }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: none;
}
.toast.show { display: block; }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr; grid-template-rows: auto auto; min-height: 96px; padding: 8px 12px; }
  .topbar-right { justify-content: flex-start; }
  .workspace { grid-template-columns: 330px minmax(0, 1fr); }
  .context-panel { display: none; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { grid-template-rows: auto minmax(0, 1fr); }
  .mail-toolbar { overflow-x: auto; padding-bottom: 2px; }
  .tool-button { white-space: nowrap; }
  .topbar-right { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .status-pills { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .message-list { display: none; }
  .reader { padding: 14px; }
  .audit-grid { grid-template-columns: 1fr; }
  .section-title { display: grid; }
}
