:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --line: #d9e1e5;
  --text: #18252c;
  --muted: #64757e;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --blue: #2563eb;
  --amber: #b7791f;
  --danger: #b42318;
  --shadow: 0 16px 36px rgba(26, 42, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  min-height: auto;
  margin-bottom: 6px;
  color: var(--text);
}

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

.compact-notice {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #17252b;
  color: #f7fbfc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

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

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

.brand span {
  color: #b9c7cc;
  font-size: 13px;
  margin-top: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e5e8;
  text-align: left;
}

.nav-item svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-item.active,
.nav-item:hover {
  background: #22363d;
  border-color: #31505a;
  color: #ffffff;
}

.subnav {
  display: grid;
  gap: 6px;
  margin: -2px 0 4px 36px;
}

.subnav-item,
.subnav-add {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #bdd0d6;
  text-align: left;
}

.subnav-item {
  padding: 0 10px;
}

.subnav-item.active,
.subnav-item:hover,
.subnav-add:hover {
  background: #20343b;
  border-color: #31505a;
  color: #ffffff;
}

.subnav-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 8px 36px;
  padding: 0 10px;
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #2f4b55;
  border-radius: 8px;
  color: #bdd0d6;
}

.sidebar-note strong {
  color: #ffffff;
  font-size: 28px;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.topbar-actions,
.file-actions,
.form-actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form label {
  flex: 1 1 260px;
}

.user-chip {
  display: grid;
  gap: 2px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.user-chip span,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary-button {
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
}

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

.secondary-button,
.icon-button.secondary {
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.text-button {
  padding: 0 12px;
  background: #e8f5f3;
  color: var(--primary-dark);
  border-color: #b9dbd6;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: #edf8f5;
  color: var(--primary-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.entry-layout,
.table-shell,
.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-layout {
  display: grid;
  gap: 0;
}

.form-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.section-heading.split {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading span,
label span {
  color: var(--muted);
  font-size: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

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

label.full {
  grid-column: 1 / -1;
}

.stacked {
  margin-top: 14px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.attachment-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.attachment-card strong,
.attachment-card span {
  display: block;
}

.attachment-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-card li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
}

.attachment-card small,
.attachment-card .muted {
  color: var(--muted);
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.multi-line-cell {
  min-width: 180px;
  line-height: 1.6;
}

.attachment-summary-cell {
  min-width: 150px;
  max-width: 280px;
}

.attachment-summary-cell summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  cursor: pointer;
  list-style: none;
}

.attachment-summary-cell summary::-webkit-details-marker {
  display: none;
}

.attachment-summary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #cfd9de;
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.attachment-summary-detail {
  margin-top: 8px;
  max-width: 280px;
  max-height: 140px;
  overflow: auto;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-word;
}

.attachment-hide-label,
.attachment-summary-cell[open] .attachment-show-label {
  display: none;
}

.attachment-summary-cell[open] .attachment-hide-label {
  display: inline;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfd9de;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.15);
  border-color: var(--primary);
}

.form-actions {
  padding: 18px 20px;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(120px, 1fr));
  gap: 10px;
  flex: 1;
}

.dispatch-toolbar {
  justify-content: flex-end;
}

.column-panel,
.column-filter-popover {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.column-panel {
  margin-bottom: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.column-panel-head,
.column-filter-head,
.column-filter-actions,
.dispatch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-panel-head {
  margin-bottom: 12px;
}

.column-chooser-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}

.column-chooser-grid label,
.column-filter-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 6px;
}

.column-chooser-grid label:hover,
.column-filter-options label:hover {
  background: #f2f7f6;
}

.column-chooser-grid input,
.column-filter-options input {
  width: 16px;
  min-height: 16px;
  flex: 0 0 16px;
}

.column-chooser-grid span,
.column-filter-options span {
  color: var(--text);
  font-size: 13px;
}

.dispatch-heading > span {
  white-space: nowrap;
}

.column-filter-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 6px;
  color: var(--muted);
}

.column-filter-button:hover,
.column-filter-button.active {
  color: var(--primary);
  background: #dff3ef;
}

.column-filter-popover {
  position: fixed;
  z-index: 30;
  max-height: min(360px, 70vh);
  padding: 12px;
  overflow: auto;
}

.column-filter-head {
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--line);
}

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

.column-filter-options {
  display: grid;
  gap: 2px;
  max-height: 230px;
  padding: 8px 0;
  overflow: auto;
}

.column-filter-actions {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.compact-empty {
  padding: 12px;
}

.dispatch-summary,
.dispatch-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dispatch-summary span,
.dispatch-pagination span,
.dispatch-pagination label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.dispatch-summary strong,
.dispatch-pagination strong {
  color: var(--text);
}

.dispatch-pagination {
  justify-content: flex-end;
  margin-top: 12px;
}

.dispatch-pagination select,
.dispatch-pagination input {
  width: 76px;
  min-height: 34px;
}

.compact-page-button {
  min-height: 34px;
  padding: 6px 10px;
}

.text-button.compact {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 13px;
}

.table-shell {
  overflow: auto;
}

.embedded-table {
  box-shadow: none;
}

.embedded-table table {
  min-width: 640px;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #f6f8f9;
  color: #41535c;
  z-index: 1;
}

.project-title {
  display: grid;
  gap: 3px;
}

.project-title strong {
  max-width: 240px;
  overflow-wrap: anywhere;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #3f5360;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.small-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.small-button.danger {
  color: var(--danger);
}

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

dialog {
  width: min(1120px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(18, 31, 38, 0.25);
}

dialog::backdrop {
  background: rgba(18, 31, 38, 0.4);
}

.dialog-body {
  padding: 22px;
}

#dispatchViewDialog {
  width: min(560px, calc(100vw - 32px));
}

.compact-dialog {
  width: min(560px, calc(100vw - 32px));
}

.compact-grid {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.calc-note {
  margin: 14px 0 0;
  color: var(--amber);
  line-height: 1.6;
}

.calc-result-table-shell {
  overflow-x: auto;
  margin: 14px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calc-result-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.calc-result-table th,
.calc-result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.calc-result-table th {
  color: var(--muted);
  font-weight: 700;
  background: #f7fafb;
}

.calc-result-table tr:last-child td {
  border-bottom: 0;
}

.calc-summary-row td {
  background: #f2f7f7;
  color: var(--text);
  font-weight: 700;
}

.calc-explanation {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.calc-explanation summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--text);
  font-weight: 700;
}

.calc-explanation-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.calc-note-item {
  display: grid;
  gap: 6px;
}

.calc-note-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.calc-block {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.calc-block-title {
  color: var(--text);
  font-weight: 700;
}

.calc-basic-grid {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.factor-table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.factor-table {
  width: 100%;
  min-width: 1180px;
  table-layout: fixed;
  box-shadow: none;
}

.factor-table th,
.factor-table td {
  padding: 10px;
}

.factor-col-pollutant {
  width: 108px;
}

.factor-col-factor {
  width: 120px;
}

.factor-col-unit {
  width: 110px;
}

.factor-col-source {
  width: 120px;
}

.factor-col-action {
  width: 70px;
}

.factor-collection-measure,
.factor-treatment-measure {
  width: 200px;
}

.factor-collection-efficiency-cell,
.factor-treatment-efficiency-cell {
  width: 104px;
}

.factor-table input,
.factor-table select {
  min-height: 34px;
}

.factor-duo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
}

.factor-table input[readonly] {
  background: #f6f8f9;
  color: var(--muted);
}

.pollutant-picker {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pollutant-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.pollutant-picker label {
  display: grid;
  gap: 6px;
  min-height: 28px;
}

.pollutant-row {
  display: grid;
  grid-template-columns: 110px repeat(2, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

.pollutant-row.voc-row {
  grid-template-columns: 110px minmax(170px, 1.2fr) minmax(120px, 0.8fr) minmax(220px, 1.5fr) minmax(120px, 0.8fr);
}

.pollutant-picker label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
}

.pollutant-picker input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

@media (max-width: 1180px) {
  .field-grid,
  .calc-basic-grid,
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pollutant-row,
  .pollutant-row.voc-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
  }

  .brand,
  .sidebar-note {
    display: none;
  }

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

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .workspace {
    padding: 16px;
  }

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

  .field-grid,
  .attachment-grid,
  .calc-basic-grid,
  .filters,
  .pollutant-row,
  .pollutant-row.voc-row {
    grid-template-columns: 1fr;
  }

  label.wide {
    grid-column: auto;
  }

  .column-panel {
    max-height: calc(100vh - 96px);
  }

  .column-chooser-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
