:root {
  color-scheme: light;
  --ink: #17202b;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f3f5f8;
  --panel: #ffffff;
  --nav: #111a24;
  --green: #0f8a5f;
  --teal: #0c7c91;
  --blue: #2563eb;
  --amber: #c27a13;
  --red: #c2413b;
  --shadow: 0 12px 32px rgba(21, 32, 43, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #eef3f6 0, var(--paper) 260px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--nav);
  color: #f7fafc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #e7f5f3;
  color: #0b6b64;
  font-weight: 800;
  border-radius: 8px;
}

.brand strong,
.brand span,
.sidebar-note span,
.sidebar-note strong,
.sidebar-note small {
  display: block;
}

.brand span,
.sidebar-note small {
  color: #a7b0bd;
  font-size: 12px;
  margin-top: 4px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  text-align: left;
  color: #d7dee8;
  background: transparent;
  border: 1px solid transparent;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav-item.active,
.nav-item:hover {
  background: #223040;
  color: #ffffff;
  border-color: #38485b;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #354457;
  border-radius: 8px;
  background: #1d2936;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 12px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.top-actions,
.reply-actions,
.comment-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 14px;
  font-weight: 700;
}

.primary-button {
  background: #152333;
  color: white;
}

.ghost-button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.status-line {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  margin-bottom: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.metric-card {
  padding: 16px;
  min-height: 124px;
}

.metric-card span,
.metric-card small,
td small,
.panel-head span,
.summary-row span,
.summary-row small,
.todo-item span,
.comment-head span,
.template-card span,
.alert-card small {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  font-size: 26px;
  margin: 8px 0 6px;
  letter-spacing: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  min-height: 280px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
}

.bar-chart {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 14px;
  align-items: end;
  padding-top: 24px;
}

.bar-item {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.bar-stack {
  width: 100%;
  max-width: 58px;
  min-height: 18px;
  border-radius: 8px 8px 4px 4px;
  background: var(--blue);
  display: flex;
  align-items: end;
  overflow: hidden;
}

.bar-stack span {
  display: block;
  width: 100%;
  background: var(--teal);
}

.stack {
  display: grid;
  gap: 12px;
}

.stack.compact {
  gap: 10px;
}

.summary-row,
.todo-item,
.template-card,
.alert-card,
.account-card,
.comment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.summary-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 8px;
  align-items: center;
}

.todo-item.warning {
  border-color: #f2c98b;
  background: #fff8ec;
}

.funnel-list {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 82px 1fr 58px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.funnel-row span,
.funnel-row small,
.mini-kpi span {
  color: var(--muted);
}

.funnel-row strong {
  font-size: 18px;
}

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

.mini-kpi {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.mini-kpi strong {
  font-size: 20px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 4px;
}

.score {
  width: 44px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--muted);
  border-radius: 8px;
  font-weight: 800;
}

.score-爆发 {
  background: var(--red);
}

.score-上升 {
  background: var(--amber);
}

.score-观察 {
  background: var(--teal);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.comment-list {
  display: grid;
  gap: 14px;
}

.comment-head,
.alert-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.comment-card p {
  line-height: 1.6;
}

blockquote {
  margin: 12px 0;
  padding: 10px 12px;
  background: #eef6f7;
  border-left: 4px solid var(--teal);
  border-radius: 4px;
}

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

.badge.lead_candidate,
.badge.high {
  background: #fdecec;
  color: var(--red);
}

.badge.pending,
.badge.medium,
.badge.pending_login {
  background: #fff3d9;
  color: var(--amber);
}

.badge.risk,
.badge.expired,
.badge.error {
  background: #ffe4e0;
  color: var(--red);
}

.badge.online {
  background: #e6f6ef;
  color: var(--green);
}

.reply-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

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

.account-card .platform {
  color: var(--teal);
  font-weight: 800;
}

.matrix-toolbar {
  margin: 14px 0;
}

.matrix-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.matrix-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.qr-box {
  display: grid;
  gap: 8px;
  width: min(220px, 100%);
}

.qr-box img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-box a,
.error-text {
  color: var(--red);
  overflow-wrap: anywhere;
}

dl {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 12px;
  margin: 14px 0 0;
}

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

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.import-form {
  display: grid;
  gap: 12px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.muted {
  opacity: 0.62;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-grid,
  .dashboard-grid,
  .split-layout,
  .account-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .comment-head,
  .alert-card {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    gap: 10px;
  }

  .bar-chart {
    gap: 8px;
  }

  .kpi-list,
  .funnel-row {
    grid-template-columns: 1fr;
  }
}
