:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #687386;
  --line: #dbe1ea;
  --line-strong: #c8d0dc;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --sidebar: #111827;
  --sidebar-muted: #9ca3af;
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 12px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #60a5fa, #34d399);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

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

.nav-item {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d1d5db;
  text-align: left;
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

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

.topbar,
.panel-head,
.filters,
.panel-actions,
.actions,
.route-title,
.route-user-head {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

p {
  color: var(--muted);
  margin-top: 4px;
}

.actions,
.panel-actions {
  gap: 8px;
}

#importFileInput {
  display: none;
}

.btn {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 13px;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary:hover,
.btn.ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

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

.panel-head {
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.filters {
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.field {
  display: grid;
  gap: 5px;
}

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

.field input,
.field select {
  height: 34px;
  min-width: 180px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.search-field {
  flex: 1;
}

.search-field input {
  width: 100%;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.table-shell {
  max-height: calc(100vh - 292px);
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  background: #eef2f7;
  color: #1f2937;
  font-size: 13px;
  font-weight: 700;
}

td {
  height: 46px;
  background: #fff;
}

.group-start td {
  border-top: 1px solid var(--line-strong);
}

.select-col {
  width: 46px;
  text-align: center;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.merge-cell {
  min-width: 150px;
  background: #fbfcfe;
}

.merge-cell strong,
.merge-cell span {
  display: block;
}

.merge-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.product-cell {
  min-width: 300px;
  max-width: 420px;
  white-space: normal;
  line-height: 1.45;
}

.operation-cell {
  min-width: 110px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
}

.link-button:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.danger-text {
  color: var(--danger);
}

.empty-row {
  height: 180px;
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.35);
}

.drawer.hidden,
.modal.hidden,
.hidden {
  display: none;
}

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

.modal-panel {
  width: min(720px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.task-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  overflow: auto;
}

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

.group-task-form .product-editor {
  grid-column: 1 / -1;
}

#taskModal .modal-panel {
  width: min(1040px, calc(100vw - 48px));
}

.product-editor {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.product-editor-head strong,
.product-editor-head span {
  display: block;
}

.product-editor-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.product-editor-table-shell {
  max-height: 420px;
  overflow: auto;
}

.product-editor-table {
  min-width: 850px;
}

.product-editor-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
}

.product-editor-table th:first-child {
  width: 36%;
}

.product-editor-table th:nth-child(2),
.product-editor-table th:nth-child(3),
.product-editor-table th:nth-child(5) {
  width: 13%;
}

.product-editor-table th:nth-child(4) {
  width: 12%;
}

.product-editor-table th:last-child {
  width: 80px;
}

.product-editor-table td {
  padding: 7px 8px;
}

.product-editor-table input {
  width: 100%;
  height: 34px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  padding: 0 8px;
}

.product-editor-table input:hover,
.product-editor-table input:focus {
  border-color: var(--line-strong);
  background: #fff;
  outline: none;
}

.task-form .field input {
  width: 100%;
  min-width: 0;
}

.task-form .wide,
.modal-actions {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.import-panel {
  width: min(860px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  max-height: min(860px, calc(100vh - 48px));
}

.import-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  min-height: 0;
  overflow: hidden;
}

.import-drop {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 92px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 18px;
}

.import-drop strong {
  display: block;
  font-size: 16px;
}

.import-status {
  flex-shrink: 0;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e40af;
  padding: 10px 12px;
}

.import-status.error {
  background: #fef2f2;
  color: var(--danger);
}

.import-preview {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.import-preview-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.preview-table-shell {
  flex: 1;
  min-height: 180px;
  max-height: none;
  overflow: auto;
}

.preview-table-shell table {
  min-width: 860px;
}

.import-actions {
  flex-shrink: 0;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.pagination {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.pagination span {
  color: var(--muted);
}

.pagination select {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 0 8px;
}

.drawer-panel {
  width: 520px;
  max-width: 100vw;
  height: 100%;
  overflow: auto;
  background: #fff;
  box-shadow: -18px 0 38px rgba(15, 23, 42, 0.18);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.route-content {
  padding: 14px;
}

.route-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.route-title {
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.route-title span,
.route-title em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.route-user {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.route-user:last-child {
  border-bottom: 0;
}

.route-user-head {
  justify-content: space-between;
  gap: 12px;
}

.route-user-head span {
  color: var(--success);
  font-size: 12px;
}

.route-user ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #334155;
  line-height: 1.8;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: none;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

@media (max-width: 1260px) {
  body {
    min-width: 1040px;
  }

  .app-shell {
    grid-template-columns: 196px 1fr;
  }

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