:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #dbe1e8;
  --brand: #186a72;
  --brand-2: #248b8f;
  --green: #1f8a5b;
  --amber: #b36b00;
  --red: #c4413d;
  --blue: #2869a6;
  --shadow: 0 10px 24px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--line);
}

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

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

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

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  color: #ffffff;
  background: var(--brand);
}

.nav-icon {
  width: 24px;
  text-align: center;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 14px 20px;
  background: rgba(244, 246, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu-toggle {
  display: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 150px);
}

.login-panel {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.login-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

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

.login-head span,
.login-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-note {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.attachment-card {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  text-align: left;
}

.attachment-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
}

.attachment-card span {
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

.completed-panel summary {
  list-style: none;
  cursor: pointer;
}

.completed-panel summary::-webkit-details-marker {
  display: none;
}

.group-row td {
  padding: 8px 10px;
  background: #f3f6f8;
}

.group-row-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.attachment-preview-wrap {
  display: grid;
  place-items: center;
}

.attachment-preview-wrap img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar input[type="search"] {
  flex: 1 1 280px;
  min-width: 220px;
}

.toolbar-spacer {
  flex: 1;
}

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

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

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 12px 14px;
}

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

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

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

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
}

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

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

.form-grid.two.compact-order-form {
  gap: 8px;
}

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

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

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.compact-order-form .field input,
.compact-order-form .field select,
.compact-order-form .field textarea {
  min-height: 34px;
  padding: 6px 8px;
}

.field textarea {
  min-height: 68px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(36, 139, 143, 0.14);
}

.button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.button.warn {
  border-color: var(--amber);
  color: var(--amber);
}

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

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  background: var(--panel-2);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

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

.small-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.small-button.primary {
  border-color: var(--brand);
  color: var(--brand);
}

.small-button.warn {
  border-color: var(--amber);
  color: var(--amber);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #edf7f6;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.green {
  background: #edf8f2;
  color: var(--green);
}

.status.amber {
  background: #fff7e8;
  color: var(--amber);
}

.status.red {
  background: #fff0ef;
  color: var(--red);
}

.status.blue {
  background: #edf5ff;
  color: var(--blue);
}

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

.tab {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
}

.tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

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

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

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

.note-list li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  font-size: 13px;
}

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

.detail-item {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.detail-item span,
.muted-inline {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  font-size: 14px;
  line-height: 1.5;
}

.summary-card {
  display: grid;
  gap: 8px;
}

.summary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px 2px;
}

.summary-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.summary-head-title strong {
  font-size: 15px;
  line-height: 1.3;
}

.summary-head-title span,
.summary-head-meta span {
  color: var(--muted);
  font-size: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.summary-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-row-tight .summary-cell {
  min-height: 64px;
}

.summary-cell {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

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

.summary-cell strong {
  font-size: 14px;
  line-height: 1.4;
}

.summary-strip {
  display: grid;
  gap: 8px;
}

.summary-strip-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

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

.summary-strip-item strong {
  font-size: 14px;
  line-height: 1.4;
}

.compact-head-grid {
  gap: 6px;
}

.compact-head-grid .detail-item {
  min-height: 54px;
  padding: 7px 9px;
}

.compact-head-grid .detail-item span {
  font-size: 11px;
}

.compact-head-grid .detail-item strong {
  font-size: 13px;
  line-height: 1.35;
}

.readonly-field {
  background: var(--panel-2);
}

.compact-panel {
  box-shadow: none;
}

.compact-panel-body {
  padding: 8px 9px;
}

.compact-list {
  display: grid;
  gap: 6px;
}

.compact-header-row {
  justify-content: space-between;
  margin-bottom: 6px;
  align-items: center;
}

.compact-item-title {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 700;
}

.compact-step-title {
  font-size: 12px;
  line-height: 1.35;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 700;
}

.compact-item-grid {
  display: grid;
  grid-template-columns: 1.6fr 1.2fr 0.7fr 1fr;
  gap: 7px;
}

.compact-step-row {
  display: grid;
  grid-template-columns: 1fr;
}

.compact-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-detail-grid .detail-item {
  padding: 8px 10px;
}

.order-items-field {
  gap: 6px;
}

.order-items-header {
  justify-content: space-between;
  align-items: center;
}

.summary-card {
  gap: 8px;
}

.summary-head {
  padding-bottom: 2px;
}

.summary-head-title strong {
  font-size: 18px;
  line-height: 1.25;
}

.summary-head-title span,
.summary-head-meta span {
  font-size: 12px;
}

.summary-row-tight {
  gap: 6px;
}

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

.summary-cell {
  min-height: 54px;
  padding: 7px 9px;
}

.summary-cell span {
  font-size: 11px;
}

.summary-cell strong {
  font-size: 13px;
  line-height: 1.35;
}

.workorder-detail-table th,
.workorder-detail-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.workorder-detail-table td span {
  color: var(--muted);
  font-size: 12px;
}

.check-grid {
  display: grid;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.section-gap {
  height: 12px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 51, 0.34);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(80vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 40px rgba(31, 41, 51, 0.18);
}

.modal-panel-narrow {
  width: min(520px, 100%);
}

.drawer-mask {
  display: none;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }

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

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

  .compact-item-grid,
  .compact-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: 280px;
    transition: transform 160ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  body.menu-open .drawer-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(31, 41, 51, 0.32);
  }

  .menu-toggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
  }

  .topbar {
    min-height: 70px;
    padding: 12px;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar p,
  .user-chip {
    display: none;
  }

  .content {
    padding: 12px;
    gap: 12px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric strong {
    font-size: 24px;
  }

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

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

  .summary-row,
  .summary-row-3,
  .compact-item-grid,
  .compact-detail-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .panel-body {
    padding: 12px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .button,
  .toolbar select,
  .toolbar input {
    width: 100%;
  }
}
