:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --surface: #fffdf7;
  --surface-2: #eef2ed;
  --ink: #17211b;
  --muted: #617065;
  --line: #d9ded6;
  --green: #17683a;
  --green-2: #0f4e2d;
  --amber: #b86a16;
  --red: #a33123;
  --blue: #285f86;
  --shadow: 0 10px 30px rgba(23, 33, 27, 0.08);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(23, 104, 58, 0.09), transparent 38%),
    linear-gradient(315deg, rgba(184, 106, 22, 0.1), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar,
.section-heading,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  gap: 10px;
}

.identity-picker {
  min-width: 190px;
  color: var(--muted);
  font-weight: 700;
}

.icon-button,
.primary-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 20px;
}

.primary-button {
  height: 44px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.primary-button:hover,
.icon-button:hover {
  background: var(--green-2);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sync-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
}

.sync-status strong,
.sync-status span {
  display: block;
}

.sync-status strong {
  margin-bottom: 4px;
}

.sync-facts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.sync-ok {
  border-color: rgba(23, 104, 58, 0.3);
}

.sync-warn {
  border-color: rgba(184, 106, 22, 0.35);
}

.sync-bad {
  border-color: rgba(163, 49, 35, 0.35);
}

.metric {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

.workbench {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 14px;
  align-items: start;
}

.route-pane,
.panel,
.detail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
}

.route-pane {
  padding: 14px;
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
  overflow: auto;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.route-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.route-card:hover,
.route-card.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.route-card.done {
  background: #f0f5ef;
}

.route-card-header,
.route-meta,
.sku-line,
.score-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.route-card-header strong {
  font-size: 15px;
}

.score {
  color: var(--green);
  font-weight: 900;
}

.route-meta,
.sku-line {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.reason-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.reason-list li {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.detail-pane {
  display: grid;
  gap: 14px;
}

.detail-block {
  padding: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}

.profile-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}

.script-box {
  display: grid;
  gap: 10px;
}

.script-row {
  border-left: 4px solid var(--green);
  padding-left: 10px;
}

.script-row strong {
  display: block;
  margin-bottom: 4px;
}

.sku-grid {
  display: grid;
  gap: 8px;
}

.sku-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.sku-item strong {
  display: block;
  margin-bottom: 4px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 14px;
}

.panel {
  padding: 14px;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 104, 58, 0.12);
}

.span-2 {
  grid-column: span 2;
}

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

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

.execution-panel {
  margin-top: 14px;
}

.execution-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

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

.execution-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.execution-stats span {
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.execution-stats strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.coach-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.coach-stats span {
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.coach-stats strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 15px;
}

.product-table-panel,
.customer-table-panel {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  font-size: 13px;
}

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

.status-high {
  color: var(--red);
  font-weight: 800;
}

.status-mid {
  color: var(--amber);
  font-weight: 800;
}

.status-low {
  color: var(--blue);
  font-weight: 800;
}

.flag {
  display: inline-flex;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(163, 49, 35, 0.1);
  color: var(--red);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .workbench,
  .detail-grid,
  .two-column,
  .execution-grid {
    grid-template-columns: 1fr;
  }

  .route-pane {
    position: static;
    max-height: none;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .identity-picker,
  .sync-status,
  .sync-facts {
    width: 100%;
  }

  .top-actions,
  .sync-status {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-facts {
    justify-content: flex-start;
  }

  h1 {
    font-size: 28px;
  }

  .metrics-grid,
  .visit-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
