:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #dde3ee;
  --brand: #1570ef;
  --brand-strong: #0b5ed7;
  --success: #07815c;
  --warning: #a15c07;
  --shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

.sidebar p,
.panel-title span {
  color: var(--muted);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.sidebar p {
  font-size: 14px;
  line-height: 1.5;
}

.work-nav {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.work-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  background: #f2f5fa;
}

.work-nav a:hover {
  color: var(--brand-strong);
  background: #e8f1ff;
}

.work-nav a.active {
  color: #ffffff;
  background: var(--brand);
}

.shell {
  width: 100%;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 32px) 48px;
  min-width: 0;
}

.content-stack,
.layout {
  display: grid;
  gap: 20px;
}

.work-panel {
  display: none;
}

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

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

.settings-panel {
  margin-bottom: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2 {
  font-size: 18px;
}

.panel-title > div:first-child {
  display: grid;
  gap: 4px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-tools select {
  min-width: 120px;
}

.panel-tools input[type="date"] {
  min-width: 160px;
}

.panel[id] {
  scroll-margin-top: 18px;
}

.settings-form,
.preset-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 18px;
}

.settings-form label,
.preset-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.settings-form button,
.preset-form button {
  align-self: end;
}

.preset-form textarea {
  min-height: 180px;
  line-height: 1.7;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.secondary-action {
  background: #e8f1ff;
  color: var(--brand-strong);
}

.secondary-action:hover {
  background: #d8e8ff;
}

input,
select,
textarea,
button {
  min-height: 40px;
  border-radius: 6px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
}

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

#detailSearchInput {
  min-width: 190px;
}

button {
  border: 0;
  padding: 0 14px;
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:hover,
button:hover {
  background: var(--brand-strong);
}

.records {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.stats-page {
  display: grid;
  gap: 18px;
  padding: 18px;
}

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

.stats-summary > div {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.stats-summary span,
.stats-row-sub {
  color: var(--muted);
  font-size: 14px;
}

.stats-summary strong {
  font-size: 24px;
  line-height: 1.2;
}

.stats-section {
  display: grid;
  gap: 10px;
}

.stats-section h3 {
  font-size: 16px;
}

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

.stats-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.stats-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.details-page {
  display: grid;
  gap: 14px;
  padding: 10px 18px 0;
}

.detail-empty {
  padding: 8px 12px 0;
  text-align: left;
}

.detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.detail-summary span,
.detail-card > span {
  color: var(--muted);
  font-size: 14px;
}

.detail-summary strong {
  font-size: 22px;
}

.wechat-users-page {
  display: grid;
  gap: 14px;
  padding: 10px 18px 0;
}

.wechat-user-summary {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 14px;
}

.wechat-user-list {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.wechat-user-header,
.wechat-user-row {
  min-width: 980px;
  display: grid;
  grid-template-columns: 58px 260px 130px 110px 120px 160px 160px;
  align-items: center;
  gap: 8px;
}

.wechat-user-header {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.wechat-user-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}

.wechat-avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eaf2ff;
  color: #1d2939;
  font-weight: 700;
  object-fit: cover;
}

.mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.detail-list {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.detail-header,
.detail-card {
  min-width: 970px;
  display: grid;
  grid-template-columns: 210px 46px 46px 66px 80px 110px 140px 160px 210px 310px 100px;
  align-items: center;
  gap: 6px;
}

.detail-header {
  padding: 0 10px 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-card {
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  font-size: 13px;
}

.detail-card > span,
.detail-card > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.detail-images a {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #eef2f8;
}

.detail-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-actions {
  display: flex;
  gap: 6px;
}

.detail-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-pagination > div {
  display: flex;
  gap: 8px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
}

.danger-action {
  background: #ffe8e8;
  color: #b42318;
}

.danger-action:hover {
  background: #ffdada;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.32);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  padding: 18px;
}

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

.modal-title h2 {
  font-size: 18px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #eef4ff;
  color: var(--brand-strong);
  font-size: 20px;
}

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

.modal-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.export-page {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.export-form {
  display: grid;
  grid-template-columns: 120px 180px 120px 160px 120px;
  gap: 12px;
  align-items: end;
}

.export-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.export-preview {
  display: grid;
  gap: 12px;
}

.export-summary,
.export-breakdown {
  display: grid;
  gap: 12px;
}

.export-summary {
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(120px, 1fr));
}

.export-breakdown {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.export-summary > div,
.export-breakdown article {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.export-summary span,
.export-breakdown span {
  color: var(--muted);
  font-size: 14px;
}

.export-summary strong,
.export-breakdown strong {
  font-size: 20px;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.record-card strong {
  display: block;
  margin-bottom: 8px;
}

.record-grid {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 6px 10px;
  color: var(--muted);
  font-size: 14px;
}

.record-grid span:nth-child(even) {
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.status-ok {
  color: var(--success);
}

.status-warn {
  color: var(--warning);
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .panel-title,
  .panel-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }

  .detail-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .export-form,
  .export-summary,
  .export-breakdown {
    grid-template-columns: 1fr;
  }
}
