:root {
  --bg: #f5f7fb;
  --panel: #fff;
  --text: #18202f;
  --muted: #667085;
  --line: #dce3ee;
  --blue: #2457a6;
  --blue-bg: #eef4ff;
  --red: #c92a2a;
  --red-bg: #fff1f1;
  --amber: #b35c00;
  --amber-bg: #fff6df;
  --green: #207245;
  --green-bg: #eaf7ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}
.page { max-width: 1320px; margin: 0 auto; padding: 28px; }
header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
h1 { margin: 0 0 6px; font-size: 28px; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0 0 8px; font-size: 15px; }
p { margin: 0; color: var(--muted); }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.help-btn { background: var(--blue-bg); color: var(--blue); border-color: #bdd0ee; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
}
button:hover { border-color: #bdd0ee; color: var(--blue); }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; transition: .15s ease; }
.kpi:hover { transform: translateY(-1px); border-color: #bdd0ee; box-shadow: 0 8px 20px rgba(36,87,166,.08); }
.kpi.active { border-color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue-bg), 0 10px 24px rgba(36,87,166,.12); }
.kpi.active .label { color: var(--blue); font-weight: 760; }
.kpi .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.kpi .value { font-size: 24px; font-weight: 800; line-height: 1; }
.freshness-inline {
  display: grid;
  gap: 2px;
  padding: 2px 6px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}
.freshness-inline span { margin-right: 5px; }
.freshness-inline strong { color: #334155; font-weight: 760; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar-note { color: var(--muted); font-size: 13px; align-self: center; }
.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 3px;
  border-radius: 50%;
  background: #eef1f5;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
}
.kpi.active .hint { background: var(--blue); color: #fff; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
input, select {
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
}
select {
  min-width: 116px;
  font-weight: 650;
  color: #334155;
}
.filter-group {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.filter-chip {
  min-width: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border-color: transparent;
  background: #f1f5fb;
  color: #94a3b8;
  font-size: 13px;
}
.filter-chip.active {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: #bdd0ee;
  box-shadow: inset 0 0 0 1px rgba(36,87,166,.08);
}
.filter-chip.active::before { content: "✓ "; font-weight: 900; }
.filter-chip:not(.active)::before { content: "－ "; font-weight: 900; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.muted { color: var(--muted); }
.list { display: grid; gap: 8px; }
.list-header {
  display: grid;
  grid-template-columns: 58px 80px minmax(190px, 1.3fr) 86px 112px 74px minmax(300px, 2fr);
  gap: 8px;
  padding: 0 12px 5px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.row {
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.row.high { border-left-color: var(--red); }
.row.mid { border-left-color: var(--amber); }
.row.open {
  box-shadow: 0 12px 34px rgba(36, 87, 166, .13);
  border-color: #bfd0ea;
}
.row.open .row-main {
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
}
.row-main {
  display: grid;
  grid-template-columns: 58px 80px minmax(190px, 1.3fr) 86px 112px 74px minmax(300px, 2fr);
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  align-items: start;
}
.row-main:hover { background: #fbfdff; }
.cell-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.row-main .cell-label { display: none; }
.customer { font-weight: 780; }
.sender, .action, .subject { font-size: 13px; color: #334155; }
.sender { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject { font-weight: 650; color: #1f2937; }
.action {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.amber { color: var(--amber); background: var(--amber-bg); }
.badge.blue { color: var(--blue); background: var(--blue-bg); }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.gray { color: #334155; background: #eef1f5; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.actions button { font-size: 12px; padding: 6px 9px; }
.actions .action-done {
  background: #fff;
  color: var(--green);
  border-color: #a9d8bb;
}
.actions .action-done:hover {
  background: var(--green-bg);
  border-color: #79bd96;
}
.actions .action-snooze {
  background: #fff;
  color: var(--amber);
  border-color: #f0c36d;
}
.actions .action-snooze:hover {
  background: var(--amber-bg);
  border-color: #d99a30;
}
.detail {
  display: none;
  margin: 0 14px 14px 88px;
  padding: 16px;
  background: linear-gradient(180deg, #f4f8ff 0%, #ffffff 74%);
  border: 2px solid #c8d8f2;
  border-left: 8px solid var(--blue);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.row.open .detail { display: block; }
.action-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px;
  background: #fff8e8;
  border: 1px solid #ffd890;
  border-radius: 12px;
}
.action-title {
  font-weight: 820;
  color: #7a4200;
  margin-bottom: 2px;
}
.action-panel .actions { margin-top: 0; justify-content: flex-end; min-width: 430px; }
.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #d8e3f5;
  color: #173b73;
}
.detail-title span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.detail-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(36,87,166,.18);
}
.detail-open-link:hover {
  color: #fff;
  text-decoration: none;
  background: #1d4b91;
}
.detail-card-link { margin-top: 5px; font-size: 13px; font-weight: 760; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.detail-card { background: #fff; border: 1px solid #e6ebf2; border-radius: 8px; padding: 10px; }
.body { max-height: 360px; overflow: auto; background: #fff; border: 1px solid #d9e5f7; border-radius: 10px; padding: 14px; word-break: break-word; }
.body h4 { margin: 0 0 8px; color: #173b73; }
.body p { color: var(--text); margin: 0 0 8px; }
.body .quote-details { margin-top: 10px; }
.body .quote-details summary { cursor: pointer; color: var(--blue); font-weight: 760; }
.body table { max-width: 100%; border-collapse: collapse; }
.body td, .body th { border: 1px solid var(--line); padding: 4px 6px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.help-dialog {
  width: min(920px, calc(100vw - 42px));
  border: 1px solid #cdd8ea;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(24,32,47,.25);
}
.help-dialog::backdrop { background: rgba(24,32,47,.28); }
.help-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}
.help-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 12px;
  padding: 16px;
}
.help-content section {
  border: 1px solid #e1e8f4;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}
.help-content ul { margin: 0; padding-left: 18px; color: #334155; }
.help-content li { margin: 6px 0; }
.help-content code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef4ff;
  color: var(--blue);
}

@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  header { display: block; }
  .header-actions { margin-top: 10px; }
  .freshness-inline { width: 100%; text-align: left; order: 3; }
  .toolbar { display: block; }
  .filters { width: 100%; margin-top: 10px; justify-content: flex-start; }
  input { width: 100%; min-width: 0; }
  .list-header { display: none; }
  .row-main .cell-label { display: block; }
  .row-main { grid-template-columns: 1fr 1fr; }
  .detail { margin-left: 14px; }
  .action-panel { display: block; }
  .action-panel .actions { min-width: 0; justify-content: flex-start; margin-top: 10px; }
  .detail-title { align-items: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .help-content { grid-template-columns: 1fr; }
}
