body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111;
  background: #f6f7fb;
}

/* 登录界面样式 */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 350px;
}

.login-box h2 {
  margin: 0 0 10px 0;
  font-size: 28px;
  color: #333;
}

.login-box p {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 14px;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 15px;
  box-sizing: border-box;
}

.login-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-box .btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
}

.error-msg {
  color: #f44336;
  font-size: 14px;
  margin-top: 10px;
  min-height: 20px;
}

.container {
  max-width: none;
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  background: #fff;
  border: 1px solid #e7e8ee;
  border-radius: 12px;
  padding: 14px;
}

.title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 6px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.top-controls {
  gap: 8px;
  align-items: center;
}

.matrix-toolbar {
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toolbar-card {
  width: 100%;
  max-width: 1800px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e7e8ee;
  border-radius: 12px;
  background: #fff;
}

.toolbar-top-row {
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
}

.toolbar-top-row .btn {
  padding: 6px 10px;
}

.toolbar-bottom {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 12px;
}

.bottom-left {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.status-center {
  text-align: center;
}

.matrix-filter-row {
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 4px;
}

.matrix-filter-row-inline {
  justify-content: flex-start;
}

/* 功能按钮行样式 */
.top-action-row {
  justify-content: flex-start;
  margin-bottom: 8px;
}

.top-filter-row {
  /* 筛选行样式 */
}

.input {
  padding: 10px 12px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  min-width: 220px;
  flex: 1;
}

.matrix-filter-row .matrix-filter {
  flex: 0 0 240px;
  width: 240px;
  min-width: 240px;
}

@media (max-width: 700px) {
  .bottom-right {
    width: auto;
  }
  .matrix-filter-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .matrix-filter-row .matrix-filter {
    flex: 1 1 220px;
    width: auto;
    min-width: 220px;
  }
}

.matrix-filters,
.matrix-actions {
  display: none;
}

.select {
  padding: 10px 12px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  flex: 0 0 auto;
}

.input-url {
  min-width: 240px;
  width: 240px;
  flex: 0 0 auto;
}

.input-token {
  min-width: 160px;
  width: 160px;
  flex: 0 0 auto;
}

.btn {
  padding: 10px 14px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.btn.primary {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.status {
  color: #555;
}

.toast {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  background: rgba(17, 17, 17, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 460px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.status-below {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
  min-height: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.tabs-inline {
  margin-top: 0;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.tab {
  padding: 10px 14px;
  border: 1px solid #e7e8ee;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.tabs-inline .tab {
  padding: 8px 10px;
  width: 6em;
  min-width: 6em;
  max-width: 6em;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab.active {
  border-color: #4f46e5;
  color: #4f46e5;
}

.panel {
  margin-top: 12px;
  background: #fff;
  border: 1px solid #e7e8ee;
  border-radius: 12px;
  padding: 14px;
}

.panel-matrix {
  padding: 10px;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  border-radius: 0;
}

.panel.hidden {
  display: none;
}

.panel-sub {
  margin-top: 12px;
  border-top: 1px solid #eef0f6;
  padding-top: 12px;
}

.panel-subtitle {
  font-weight: 700;
  margin-bottom: 8px;
}

.textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  box-sizing: border-box;
}

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

.panel-title {
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px;
  border-top: 1px solid #eef0f6;
  text-align: left;
  vertical-align: top;
}

.table tbody tr:nth-child(odd) > th,
.table tbody tr:nth-child(odd) > td {
  background: #fff;
}

.table tbody tr:nth-child(even) > th,
.table tbody tr:nth-child(even) > td {
  background: #eef2ff;
}

.w-actions {
  width: 120px;
}

.mini {
  padding: 6px 10px;
  border-radius: 10px;
}

.sewers {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.sewer-card {
  border: 1px solid #eef0f6;
  border-radius: 12px;
  padding: 12px;
  background: #fafbff;
}

.sewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sewer-name {
  font-weight: 700;
}

.models {
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #eef0f6;
  border-radius: 12px;
  padding: 8px;
}

.model-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 6px;
  border-radius: 10px;
}

.model-item:hover {
  background: #f2f3ff;
}

.matrix-wrap {
  margin-top: 6px;
  overflow: auto;
  max-height: calc(100vh - 150px);
  border: 1px solid #eef0f6;
  border-radius: 12px;
  background: #fff;
}

.matrix {
  border-collapse: collapse;
  width: max-content;
  min-width: 0;
}

.matrix th,
.matrix td {
  border: 1px solid #c8cedb;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
}

.matrix th {
  background: #fafbff;
}

.matrix tbody tr > th,
.matrix tbody tr > td {
  background: #fff;
}

.matrix tr.row-highlight > th,
.matrix tr.row-highlight > td {
  background: #fff4c2 !important;
}

.matrix tbody tr.hover-row > th,
.matrix tbody tr.hover-row > td {
  background: #dbeafe !important;
}

.matrix tbody tr.hover-model > th.sticky-left,
.matrix tbody tr.hover-model > td.col-delete {
  background: #dbeafe !important;
}

.matrix th.sticky-top {
  position: sticky;
  top: 0;
  z-index: 3;
}

.matrix th.sticky-left,
.matrix td.sticky-left {
  position: sticky;
  z-index: 2;
  text-align: center;
}

.matrix th.corner {
  z-index: 4;
}

.matrix {
  --col-seq: 3em;
  --col-print: 3em;
  --col-model: 8em;
  --col-craft: 4.5em;
  --col-remark: 14em;
  --col-wage: 5.5em;
  --col-workers: 34em;
}

.matrix .col-seq {
  width: var(--col-seq);
  min-width: var(--col-seq);
  max-width: var(--col-seq);
}

.matrix .col-print {
  width: var(--col-print);
  min-width: var(--col-print);
  max-width: var(--col-print);
}

.matrix .col-model {
  width: var(--col-model);
  min-width: var(--col-model);
  max-width: var(--col-model);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 17, 0.35);
  z-index: 10000;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  background: #fff;
  border: 1px solid #e7e8ee;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f6;
}

.modal-title {
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.modal-body {
  padding: 10px 12px;
  overflow: auto;
}

.modal-body .table td,
.modal-body .table th {
  padding: 8px;
}

.modal-body .input {
  min-width: 0;
  width: 100%;
  flex: 1;
}

.modal-foot {
  padding: 8px 12px;
  border-top: 1px solid #eef0f6;
  font-size: 12px;
  color: #666;
}

.matrix .col-remark {
  width: var(--col-remark);
  min-width: var(--col-remark);
  max-width: var(--col-remark);
}

.matrix .col-craft {
  width: var(--col-craft);
  min-width: var(--col-craft);
  max-width: var(--col-craft);
}

.matrix .col-wage {
  width: var(--col-wage);
  min-width: var(--col-wage);
  max-width: var(--col-wage);
}

.matrix .col-workers {
  width: var(--col-workers);
  min-width: var(--col-workers);
  max-width: var(--col-workers);
}

.matrix .sticky-left-0 {
  left: 0;
  z-index: 4;
}

.matrix .sticky-left-1 {
  left: var(--col-seq);
  z-index: 4;
}

.matrix .sticky-left-2 {
  left: calc(var(--col-seq) + var(--col-print));
  z-index: 4;
}

.matrix th.sticky-top.sticky-left-0,
.matrix th.sticky-top.sticky-left-1,
.matrix th.sticky-top.sticky-left-2 {
  z-index: 6;
}

.matrix td {
  width: auto;
  min-width: 0;
  max-width: none;
}

.matrix th.sticky-top {
  width: auto;
  min-width: 0;
  max-width: none;
}

.matrix th.sticky-top.sticky-left-0,
.matrix th.sticky-top.sticky-left-1,
.matrix th.sticky-top.sticky-left-2 {
  width: auto;
  min-width: 0;
  max-width: none;
}

.matrix th {
  position: relative;
}

.matrix .col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
}

.matrix .col-resizer:hover {
  background: rgba(79, 70, 229, 0.15);
}

.worker-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

.worker-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #f3f4f6;
  flex: 0 0 auto;
}

.worker-name {
  white-space: nowrap;
}

.matrix tbody tr.product-even > th,
.matrix tbody tr.product-even > td {
  background: #eef2ff;
}

.matrix-sewer-name {
  max-width: 5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-add-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-add-input {
  padding: 6px 8px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.matrix-cell-input {
  padding: 6px 8px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

.matrix-cell-input[type="number"]::-webkit-outer-spin-button,
.matrix-cell-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.matrix-cell-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.matrix-model-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-sewer-head {
  position: relative;
}

.matrix-sewer-corner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eef0f6;
  color: #333;
  font-size: 12px;
  box-sizing: border-box;
  position: absolute;
  top: -8px;
  left: -8px;
  z-index: 1;
}

.matrix-sewer-x {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #d7d9e2;
  background: #fff;
  color: #444;
  font-size: 12px;
  line-height: 16px;
  padding: 0;
  cursor: pointer;
}

.matrix-sewer-input {
  padding: 6px 8px;
  border: 1px solid #d7d9e2;
  border-radius: 10px;
  background: #fff;
  width: 5em;
  min-width: 5em;
  max-width: 5em;
  box-sizing: border-box;
  text-align: center;
}

.matrix-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  white-space: nowrap;
  user-select: none;
}

.matrix-cb {
  cursor: pointer;
}

.matrix-cb-print {
  transform: scale(1.5);
  transform-origin: center;
}

.matrix-cb-cell {
  transform: scale(1.5);
  transform-origin: center;
}

.matrix-cb-cell-mode2 {
  transform: scale(1.5);
  transform-origin: center;
}

.matrix-cell-inner-mode2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  padding: 4px;
  width: 100%;
  height: 100%;
}

.matrix-cell-abbr {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.matrix-show-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.matrix-show-btns {
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
}

.matrix.delete-mode .matrix-sewer-head,
.matrix.delete-mode .matrix-model-wrap {
  gap: 2px;
}

.matrix-x {
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid #d32f2f;
  background: #d32f2f;
  color: white;
  cursor: pointer;
  line-height: 1;
}

.matrix-x:hover {
  background: #b71c1c;
}

/* 保存提示样式 */
.save-toast {
  position: fixed;
  top: 20px;
  left: 20px;
  background: #4CAF50;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 弹窗样式 */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.dialog-box {
  background: white;
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  max-width: 500px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dialog-box h3 {
  margin: 0 0 20px 0;
  font-size: 20px;
  color: #333;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.dialog-form label {
  font-size: 14px;
  color: #555;
  font-weight: 500;
}

.dialog-form input {
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.dialog-form input:focus {
  outline: none;
  border-color: #667eea;
}

.dialog-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.dialog-buttons .btn {
  padding: 8px 20px;
  min-width: 80px;
}

/* 裁剪工弹窗样式 */
.dialog-box-large {
  width: min(1100px, calc(100vw - 24px));
  max-width: none;
  min-width: 0;
}

.dialog-content {
  margin-bottom: 14px;
  overflow: auto;
  flex: 1 1 auto;
}

.dialog-content.workers-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  overflow: hidden;
  flex: 1 1 auto;
}

.worker-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.worker-col-head {
  padding: 8px 10px;
  font-weight: 600;
  background: #f5f5f5;
  border-bottom: 1px solid #eee;
  flex: 0 0 auto;
}

.worker-col-body {
  flex: 1 1 auto;
  overflow: auto;
}

.worker-col-foot {
  flex: 0 0 auto;
  margin-top: 0;
  border-top: 1px solid #eee;
  padding: 10px;
  background: #fff;
}

.dialog-box-large .dialog-table .input,
.dialog-box-large .dialog-add-row .input {
  min-width: 0;
  width: 100%;
}

.dialog-box-large .dialog-table .input {
  padding: 6px 8px;
  border-radius: 6px;
}

.worker-col-body .dialog-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

@media (max-width: 1100px) {
  .dialog-content.workers-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .dialog-content.workers-grid {
    grid-template-columns: 1fr;
  }
}

.dialog-table {
  width: 100%;
  border-collapse: collapse;
}

.dialog-table th,
.dialog-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.dialog-table th {
  background: #f5f5f5;
  font-weight: 600;
}

.dialog-table .w-actions {
  width: 80px;
  text-align: center;
}

.dialog-add-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.dialog-add-row .input {
  flex: 1;
}

.btn-danger {
  background: #d32f2f;
  color: white;
  border-color: #d32f2f;
}

.btn-danger:hover {
  background: #b71c1c;
}

/* 双击编辑模式样式 */
.display-cell {
  padding: 4px 8px;
  min-height: 24px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.display-cell:hover {
  background-color: #f0f0f0;
}

.display-cell:active {
  background-color: #e0e0e0;
}

.edit-cell {
  display: flex;
}

.edit-cell .matrix-cell-input {
  width: 100%;
}

/* 删减模式样式 */
.row-selected {
  background-color: #fff3cd !important;
  border-left: 3px solid #ff9800;
}

.col-seq.selectable {
  cursor: pointer;
  font-weight: bold;
}

.col-seq.selectable:hover {
  background-color: #ffe0b2;
}

.delete-row-btn,
.delete-col-btn {
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #d32f2f;
  background: #d32f2f;
  color: white;
  font-size: 12px;
  cursor: pointer;
}

.delete-row-btn:hover,
.delete-col-btn:hover {
  background: #b71c1c;
}
