:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --line: #d9dfd8;
  --text: #1e2a22;
  --muted: #657066;
  --green: #6fba3b;
  --green-dark: #2f7d32;
  --yellow: #f3b63f;
  --red: #d84a38;
  --blue: #2d6cdf;
  --pink: #fff0ef;
  --shadow: 0 10px 30px rgba(21, 38, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 18px 14px;
  background: #e8efe6;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--green-dark);
  font-weight: 800;
  border-radius: 8px;
}

.brand h1,
.topbar h2,
.panel h3,
.sop h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.role-box p,
.eyebrow,
.panel-head span,
.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #fff;
  border-color: var(--line);
}

.role-box {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.role-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.role-box strong {
  display: block;
  margin: 4px 0 8px;
}

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

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

.top-actions,
.dialog-actions,
.toolbar,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.primary,
.ghost,
.tab,
.icon-btn {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.primary {
  padding: 0 14px;
  color: #fff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ghost {
  padding: 0 12px;
}

.icon-btn {
  width: 34px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric {
  padding: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.work-grid,
.split,
.followup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 12px;
}

.followup-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  min-width: 0;
}

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

.alert-list,
.store-progress,
.blacklist-rows,
.buyer-list,
.task-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.followup-filters {
  display: grid;
  grid-template-columns: 100px minmax(170px, 1.3fr) 110px 130px 120px 120px 120px 120px 135px auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.followup-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.followup-filters input,
.followup-filters select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.alert-row,
.store-row,
.blacklist-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.alert-row.high {
  background: var(--pink);
  border-color: #f3b6af;
}

.alert-row strong,
.store-row strong,
.blacklist-row strong {
  display: block;
  font-size: 14px;
}

.alert-row span,
.store-row span,
.blacklist-row span {
  color: var(--muted);
  font-size: 12px;
}

.badge,
.status,
.risk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.badge {
  color: #fff;
  background: var(--red);
}

.alert-row .badge,
.blacklist-row .badge {
  color: #fff;
  background: #d43f31;
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  color: #4d3100;
  background: #ffe7a3;
}

.alert-row .badge.warn {
  color: #4d3100;
  background: #ffe7a3;
}

.badge.ok {
  color: #174f22;
  background: #dff1dc;
}

.alert-row.high .badge {
  color: #fff;
  background: #d43f31;
}

.alert-row.high span:not(.badge) {
  color: #415147;
}

.status {
  color: #1c4f20;
  background: #dff1dc;
}

.status.pending {
  color: #603e00;
  background: #ffe7a3;
}

.status.failed {
  color: #8d2117;
  background: #ffd9d5;
}

.toolbar {
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.tabs {
  flex-wrap: wrap;
}

.tab {
  padding: 0 10px;
  color: var(--muted);
}

.tab.active {
  color: #fff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.search input,
.search select {
  width: 320px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search.compact-search input,
.search.compact-search select {
  width: 150px;
}

.performance-filter {
  justify-content: flex-start;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.table-wrap.compact {
  border-radius: 0 0 8px 8px;
  box-shadow: none;
}

.task-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.task-card.high {
  background: #fff7e5;
  border-color: #f1cf78;
}

.task-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.task-card .task-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.task-order-wrap {
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.task-order-table th {
  height: 30px;
  background: #e8f4e4;
  font-size: 11px;
}

.task-order-table td {
  height: 32px;
  font-size: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  height: 38px;
  color: #08170a;
  background: var(--green);
  font-weight: 800;
}

th,
td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbf5;
}

td:nth-child(1) {
  width: auto;
}

td:nth-child(3) {
  color: var(--blue);
}

.orders-table th,
.orders-table td,
.followup-table th,
.followup-table td {
  font-size: 12px;
}

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

.section-note {
  margin-bottom: 10px;
}

.buyer-list {
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.buyer-card {
  padding: 12px;
  box-shadow: none;
}

.buyer-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.buyer-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.sop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 12px;
}

.sop section {
  padding: 14px;
}

.sop ol {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.9;
}

.dictionary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.dictionary span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e8f4e4;
  font-size: 12px;
}

.dictionary.risk span {
  background: #fff0d6;
}

dialog {
  width: min(980px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(18, 30, 20, 0.35);
}

.login-cover {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(230, 238, 228, 0.94);
}

.login-cover.hidden {
  display: none;
}

.login-card {
  width: min(380px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(21, 38, 26, 0.18);
}

.login-card h2 {
  margin: 0 0 6px;
}

.login-card p,
.login-card span {
  display: block;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.login-card .version-stamp {
  margin-top: -6px;
  color: #6a766d;
}

.login-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.login-card input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-card button {
  width: 100%;
  margin: 4px 0 12px;
}

.reset-toggle {
  margin-top: -4px;
}

.password-reset {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 12px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-head h3 {
  margin: 0;
}

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

.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.hidden-field {
  display: none !important;
}

.paste-zone {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 10px;
  border: 1px dashed #a8b5a6;
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  text-align: center;
  cursor: text;
}

.paste-zone:focus {
  border-color: var(--green-dark);
  outline: 2px solid rgba(47, 125, 50, 0.12);
}

.paste-zone img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 6px;
  object-fit: contain;
}

.paste-zone span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dialog-alerts {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf6;
}

.dialog-alerts strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.dialog-alerts div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #4d3100;
  background: #ffe7a3;
  font-size: 12px;
  font-weight: 700;
}

.mini-badge.ok {
  color: #174f22;
  background: #dff1dc;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 14px;
}

.dialog-actions span {
  color: var(--muted);
  font-size: 12px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
  }

  .brand {
    padding: 0;
  }

  .nav {
    display: flex;
    flex: 1;
    overflow: auto;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .role-box {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .work-grid,
  .split,
  .followup-layout,
  .sop,
  .buyer-list {
    grid-template-columns: 1fr;
  }

  .followup-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .search input,
  .search select {
    width: 100%;
  }

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