:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  background: #f5f7f6;
  color: #172b24;
  font-size: 16px;
}
[hidden] { display: none !important; }

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f5f7f6; }
button, input, select, textarea { font: inherit; }
a { color: #146147; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: .2rem; font-size: 1.15rem; }
h2 { margin-bottom: .5rem; font-size: 1.55rem; line-height: 1.25; }
h3 { margin-bottom: .6rem; font-size: 1.05rem; }
p { line-height: 1.65; }
small { font-size: .82rem; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid #cfd8d3;
  background: rgba(255, 255, 255, .98);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  min-height: 58px;
  margin: 0 auto;
  padding: .55rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: #164d3b;
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
}
.brand p, .brand h1 { margin: 0; }
.brand p { color: #5d6d66; font-size: .78rem; }
.safety-strip {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem 1.15rem;
  width: 100%;
  border-top: 1px solid #ead39a;
  border-bottom: 1px solid #ead39a;
  padding: .55rem max(1.5rem, calc((100vw - 1392px) / 2 + 1.5rem));
  background: #fff8e5;
  color: #493811;
  font-size: .84rem;
}
.safety-strip span { white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.header-actions button { white-space: nowrap; }

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  max-width: 1440px;
  min-height: calc(100vh - 105px);
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: 105px;
  align-self: start;
  height: calc(100vh - 105px);
  border-right: 1px solid #d9e0dc;
  padding: 1.35rem .9rem;
  background: #fff;
}
.business-nav { display: grid; gap: .22rem; }
.business-nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: .62rem .8rem;
  color: #31473f;
  text-decoration: none;
  font-size: .92rem;
  font-weight: 650;
}
.business-nav a:hover { background: #f0f4f2; }
.business-nav a.active { background: #e5f0eb; color: #104c38; font-weight: 800; }
.nav-group-label {
  margin: 1rem .8rem .35rem;
  color: #6c7b75;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.content {
  width: 100%;
  max-width: 1216px;
  padding: 1.6rem 2rem 3rem;
}
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.page-heading p { max-width: 760px; margin-bottom: 0; color: #54655e; }
.eyebrow {
  margin-bottom: .35rem;
  color: #47655a;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .1em;
}
.panel {
  margin-bottom: 1rem;
  border: 1px solid #d7dfdb;
  border-radius: 12px;
  padding: 1.25rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 53, 44, .04);
}
.panel > :last-child { margin-bottom: 0; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.section-title p { margin-bottom: 0; color: #596a63; }
.subtle { color: #596a63; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .8rem; }
.metric-card {
  min-height: 126px;
  border: 1px solid #d7dfdb;
  border-radius: 11px;
  padding: 1rem;
  background: #fff;
}
.metric-card h3 { margin-bottom: .45rem; color: #40544c; font-size: .88rem; }
.metric-value { margin: 0 0 .25rem; color: #143e31; font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.metric-value.compact-value { font-size: 1.18rem; line-height: 1.3; }
.metric-card span { color: #5c6d66; font-size: .82rem; }
.metric-card.attention { border-color: #dfb75d; background: #fffbef; }
.metric-card.danger { border-color: #df9b8d; background: #fff8f6; }

.primary-action, .secondary-action, .text-action, .tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  padding: .58rem .9rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
}
.primary-action { border: 1px solid #b98b25; background: #e4b74e; color: #172b24; }
.primary-action:hover { background: #d9a93f; }
.secondary-action { border: 1px solid #aebdb6; background: #fff; color: #244d3e; }
.text-action { min-height: auto; border: 0; padding: .25rem .1rem; background: transparent; color: #126046; }
button:disabled { cursor: wait; opacity: .58; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: 1rem; }

label { display: grid; gap: .38rem; color: #31473f; font-size: .86rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  border: 1px solid #aebdb6;
  border-radius: 8px;
  padding: .68rem .75rem;
  background: #fff;
  color: #172b24;
}
input:focus, select:focus, textarea:focus { outline: 3px solid #d8ebe3; border-color: #34755e; }
textarea { resize: vertical; }
.inline-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: .8rem; align-items: end; margin: 1rem 0; }
.stacked-form { display: grid; gap: .85rem; max-width: 760px; margin: 1rem 0; }
.stacked-form .primary-action, .stacked-form .secondary-action { justify-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.campaign-form { max-width: none; }
.campaign-form fieldset { border: 1px solid #d7dfdb; border-radius: 9px; padding: .85rem; }
.campaign-form legend { padding: 0 .35rem; color: #31473f; font-size: .86rem; font-weight: 750; }
.followup-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 180px)); gap: .8rem; }
.advanced-form { margin-top: .8rem; }
.campaign-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.campaign-card { border: 1px solid #d7dfdb; border-radius: 10px; padding: 1rem; background: #fbfcfb; }
.campaign-card h4 { margin-bottom: .3rem; font-size: 1rem; }
.campaign-card p { margin-bottom: .45rem; }
.form-grid select[multiple] { min-height: 7.5rem; }
.filter-bar { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(120px, .8fr)) auto; gap: .65rem; align-items: end; }
.form-message { min-height: 1.35rem; margin: .6rem 0 0; color: #87490e; font-size: .88rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th, td { border-bottom: 1px solid #e2e8e5; padding: .78rem .7rem; text-align: left; vertical-align: top; }
th { background: #f7f9f8; color: #475b53; font-size: .78rem; font-weight: 800; }
tbody tr:hover { background: #fafcfb; }
.table-link { color: #174f3c; font-weight: 800; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.empty-state {
  margin: .5rem 0;
  border: 1px dashed #b9c6c0;
  border-radius: 10px;
  padding: 1.2rem;
  color: #52645d;
  background: #fafcfb;
}
.table-state { color: #40544c; }
.error-state { border-left: 4px solid #a63f31; padding-left: .8rem; color: #8f2f23; }

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bdcbc5;
  border-radius: 999px;
  padding: .22rem .55rem;
  background: #f2f6f4;
  color: #29483c;
  font-size: .78rem;
  font-weight: 750;
  white-space: nowrap;
}
.badge.good { border-color: #9fc9b8; background: #edf8f3; color: #15533d; }
.badge.warn { border-color: #dfbf73; background: #fff8e8; color: #704c08; }
.badge.bad { border-color: #dfaaa0; background: #fff3f0; color: #8d3226; }

.customer-header { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: start; }
.customer-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin-top: 1rem; }
.fact { min-height: 78px; border-radius: 9px; padding: .75rem; background: #f4f7f5; }
.fact dt { color: #5b6c65; font-size: .75rem; font-weight: 700; }
.fact dd { margin: .3rem 0 0; color: #1d382f; font-weight: 750; }
.tabs { display: flex; overflow-x: auto; gap: .25rem; border-bottom: 1px solid #d8e0dc; margin: 1rem 0; }
.tab-button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: #4b5f57; white-space: nowrap; }
.tab-button.active { border-bottom-color: #1f6a4f; color: #154c38; }
.tab-panel[hidden], [data-page][hidden] { display: none !important; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.detail-grid div { border-radius: 9px; padding: .75rem; background: #f4f7f5; }
.detail-grid dt { color: #5b6c65; font-size: .76rem; }
.detail-grid dd { margin: .28rem 0 0; font-weight: 700; }
.candidate { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #e3e8e6; padding: .8rem 0; }
.candidate:last-child { border-bottom: 0; }
.email-preview { overflow-x: auto; border-radius: 9px; padding: 1rem; background: #f3f6f4; white-space: pre-wrap; font: inherit; line-height: 1.65; }
details { border-top: 1px solid #e2e8e5; margin-top: 1rem; padding-top: .8rem; }
summary { cursor: pointer; color: #3d5d51; font-weight: 750; }
.remote-browser { margin-top: 1rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: #eef2ef; }
.remote-browser-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.remote-browser-state { flex: 0 0 auto; border-radius: 999px; padding: .32rem .65rem; background: #dce8e2; color: #173f31; font-size: .84rem; font-weight: 750; }
.remote-browser-help { margin: .65rem 0 0; color: #3e554b; font-size: .9rem; }
.safe-command { margin-top: 1rem; padding: 1rem; border: 1px solid #d7c78f; border-radius: 12px; background: #fff9e8; }
.safe-command p { margin: .45rem 0 .7rem; }
.safe-command code { display: block; overflow-wrap: anywhere; color: #3d3215; font-size: .92rem; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 360px; border-radius: 18px; padding: clamp(1.8rem, 5vw, 3.8rem); background: #153e31; color: #fff; }
.hero h2 { max-width: 720px; font-size: clamp(2rem, 4vw, 3.4rem); }
.hero .eyebrow { color: #b9d8cb; }
.login-layout { align-items: center; }
.login-card { display: grid; gap: .8rem; width: min(100%, 340px); border-radius: 12px; padding: 1.3rem; background: #fff; color: #172b24; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inline-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid #d9e0dc; padding: .55rem 1rem; }
  .business-nav { display: flex; overflow-x: auto; }
  .business-nav a { white-space: nowrap; }
  .nav-group-label { display: none; }
  .content { padding: 1.2rem 1rem 2.5rem; }
  .customer-facts, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campaign-card-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root { font-size: 15px; }
  .brand-row, .page-heading, .customer-header, .hero { align-items: stretch; flex-direction: column; }
  .safety-strip { padding-inline: 1rem; }
  .metric-grid, .filter-bar, .inline-form, .form-grid, .customer-facts, .detail-grid { grid-template-columns: 1fr; }
  .header-actions #welcome { display: none; }
}
.non-send-banner {
  align-items: center;
  background: #fff4cc;
  border: 1px solid #d59b18;
  border-radius: 10px;
  color: #3f2d05;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 16px;
}

.quality-scenario { border-top: 1px solid var(--border); padding: 20px 0; }
.quality-scenario:first-child { border-top: 0; padding-top: 0; }
.quality-scenario > summary { align-items: center; cursor: pointer; display: flex; gap: 16px; justify-content: space-between; list-style: none; }
.quality-scenario > summary::-webkit-details-marker { display: none; }
.quality-scenario > summary strong { display: block; font-size: 17px; }
.quality-scenario > summary small { color: var(--muted); display: block; font-size: 14px; margin-top: 5px; }
.quality-scenario > summary::before { content: "展开"; flex: 0 0 auto; font-size: 13px; order: 3; }
.quality-scenario[open] > summary::before { content: "收起"; }
.quality-scenario-body { padding-top: 12px; }
.quality-compare { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; margin: 16px 0; }
.quality-compare > section { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.draft-preview { margin: 0; }
.draft-preview div { border-top: 1px solid var(--border); padding: 9px 0; }
.draft-preview dt { font-weight: 700; }
.draft-preview dd { margin: 4px 0 0; white-space: pre-wrap; }
.metric-text { font-size: 18px; font-weight: 700; margin: 8px 0; }
@media (max-width: 900px) { .quality-compare { grid-template-columns: 1fr; } .non-send-banner { align-items: flex-start; flex-direction: column; gap: 4px; } }
