body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111;
  background: #f6f7fb;
}

.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: 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-end;
}

.top-filter-row {
  margin-left: 18px;
}

.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;
}

.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 #eef0f6;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
}

.matrix th {
  background: #fafbff;
}

.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-wage: 3em;
  --col-model: 8em;
  --col-remark: 8em;
}

.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-wage {
  width: var(--col-wage);
  min-width: var(--col-wage);
  max-width: var(--col-wage);
}

.matrix .col-model {
  width: var(--col-model);
  min-width: var(--col-model);
  max-width: var(--col-model);
}

.matrix .col-remark {
  width: var(--col-remark);
  min-width: var(--col-remark);
  max-width: var(--col-remark);
}

.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 .sticky-left-3 {
  left: calc(var(--col-seq) + var(--col-print) + var(--col-wage));
  z-index: 4;
}

.matrix .sticky-left-4 {
  left: calc(var(--col-seq) + var(--col-print) + var(--col-wage) + var(--col-model));
  z-index: 4;
}

.matrix th.sticky-top.sticky-left-0,
.matrix th.sticky-top.sticky-left-1,
.matrix th.sticky-top.sticky-left-2,
.matrix th.sticky-top.sticky-left-3,
.matrix th.sticky-top.sticky-left-4 {
  z-index: 6;
}

.matrix td {
  width: 4em;
  min-width: 4em;
  max-width: 4em;
}

.matrix th.sticky-top {
  width: 5em;
  min-width: 5em;
  max-width: 5em;
}

.matrix th.sticky-top.sticky-left-0,
.matrix th.sticky-top.sticky-left-1,
.matrix th.sticky-top.sticky-left-2,
.matrix th.sticky-top.sticky-left-3,
.matrix th.sticky-top.sticky-left-4 {
  width: auto;
  min-width: 0;
  max-width: none;
}

.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-model-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-sewer-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.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-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 #d7d9e2;
  background: #fff;
  cursor: pointer;
  line-height: 1;
}

