:root {
  --bg: #eef7f5;
  --panel: #ffffff;
  --ink: #1f2d32;
  --muted: #71838b;
  --line: #e3ecef;
  --line-dark: #cddadf;
  --green: #10b981;
  --green-soft: #e7fbf3;
  --blue: #2788d9;
  --blue-soft: #e9f5ff;
  --amber: #f2a31b;
  --amber-soft: #fff6df;
  --red: #e85d5d;
  --teal: #18a7a0;
  --violet: #6d6bd7;
  --dark: #101518;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

.side {
  min-height: 100vh;
  padding: 18px 14px;
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 2px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #06261b;
  font-weight: 800;
  background: #24d198;
}

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

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

.brand span {
  color: #9eaaae;
  font-size: 12px;
  margin-top: 3px;
}

.menu {
  display: grid;
  gap: 6px;
}

.menu button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #dce2e5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  text-align: left;
}

.menu button.active,
.menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu button.active {
  color: #26d79c;
  font-weight: 700;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.amber { background: var(--amber); }
.dot.teal { background: var(--teal); }
.dot.red { background: var(--red); }
.dot.violet { background: var(--violet); }

.side-summary {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.side-summary span,
.side-summary small {
  display: block;
  color: #aeb8bd;
}

.side-summary strong {
  display: block;
  margin: 5px 0;
  color: #26d79c;
  font-size: 32px;
}

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

.mobile-page-tabs {
  display: none;
}

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

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

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

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

.api-status {
  height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
}

.api-status[data-state="online"] {
  border-color: #afead3;
  background: var(--green-soft);
  color: #08794d;
}

.api-status[data-state="fallback"] {
  border-color: #f1d58e;
  background: var(--amber-soft);
  color: #8b5d08;
}

.tools input,
.tools select {
  height: 36px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.tools input {
  width: 260px;
}

.icon-btn,
.bulk button,
.quick button,
.primary {
  height: 36px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: #314850;
  padding: 0 12px;
}

.primary,
.bulk .primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.quick button.active,
.icon-btn.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: #08794d;
}

.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #486068;
  padding: 7px 12px;
}

.tabs button.active {
  border-color: #bff1de;
  background: var(--green-soft);
  color: #08794d;
  font-weight: 700;
}

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

.metric-row article,
.main-panel,
.detail-card,
.history-card,
.bottom-grid article,
.phone-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(29, 64, 72, 0.05);
}

.metric-row article {
  padding: 13px 14px;
}

.metric-row span,
.metric-row small {
  color: var(--muted);
  display: block;
}

.metric-row strong {
  display: block;
  margin: 5px 0;
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.main-panel {
  min-width: 0;
  overflow: hidden;
}

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

.bulk,
.quick {
  display: flex;
  gap: 8px;
  align-items: center;
}

.order-table {
  overflow: auto;
}

#orderRows {
  display: grid;
}

.row {
  min-width: 1040px;
  display: grid;
  grid-template-columns: 160px 170px 110px 120px 88px minmax(270px, 1fr) 100px;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.compact-order-columns .row {
  min-width: 760px;
  grid-template-columns: 150px minmax(180px, 1fr) 110px 92px 96px;
}

.compact-order-columns .row > span:nth-child(4),
.compact-order-columns .row > span:nth-child(6) {
  display: none;
}

.row.heading {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfc;
  color: #61747b;
  font-size: 13px;
  font-weight: 700;
}

.row.selected {
  background: #f5fffb;
}

.row.attention-row {
  background: #eefaf6;
  box-shadow: inset 3px 0 0 var(--green);
}

.row.warning {
  background: #fffaf0;
}

.row b,
.row small {
  display: block;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 4px 7px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
}

.tag.running {
  background: var(--blue-soft);
  color: #176ba8;
}

.tag.idle {
  background: #edf2f4;
  color: #6b7d84;
}

.tag.warn {
  background: var(--amber-soft);
  color: #9b6300;
}

.progress-line {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress-line::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 15px;
  height: 2px;
  background: #d8e3e7;
}

.progress-line::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 15px;
  height: 2px;
  width: var(--p);
  max-width: calc(100% - 36px);
  background: var(--green);
}

.progress-line i {
  position: relative;
  z-index: 1;
  width: 52px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid #cfdce0;
  border-radius: 999px;
  background: #fff;
  color: #789;
  font-style: normal;
  font-size: 12px;
  white-space: nowrap;
}

.progress-line i.done {
  border-color: var(--green);
  color: #08794d;
}

.progress-line i.active {
  border-color: var(--blue);
  color: #176ba8;
  box-shadow: 0 0 0 3px rgba(39, 136, 217, 0.12);
}

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

.link {
  min-width: 40px;
  height: 28px;
  border: 1px solid #c9d9df;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0 8px;
  font-weight: 700;
}

.link:hover,
.link:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.right-stack {
  display: grid;
  gap: 12px;
}

.phone-panel {
  padding: 12px;
  background: #f8fffd;
}

.phone-top,
.phone-search,
.phone-tabs,
.phone-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.phone-top {
  color: #41535a;
  padding-bottom: 10px;
}

.phone-search button,
.phone-nav button {
  border: 0;
  border-radius: 999px;
  background: #edf6f4;
  color: #2f5d55;
  padding: 7px 9px;
}

.phone-tabs {
  margin: 12px 0;
  color: #71838b;
  font-size: 12px;
}

.phone-tabs .active {
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  padding: 6px 10px;
}

.phone-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 10px;
}

.phone-card small {
  color: var(--green);
  font-weight: 700;
}

.phone-card.hot small {
  color: var(--amber);
}

.phone-card b {
  display: block;
  margin: 6px 0 4px;
}

.phone-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.mini-steps {
  display: flex;
  gap: 8px;
}

.mini-steps i {
  width: 28px;
  height: 28px;
  border: 2px solid #d7e1e5;
  border-radius: 999px;
}

.mini-steps i.done {
  border-color: var(--green);
  background: var(--green-soft);
}

.mini-steps i.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.phone-nav {
  padding-top: 6px;
  color: #667a82;
  font-size: 12px;
}

.phone-nav button {
  width: 38px;
  height: 38px;
  background: var(--green);
  color: #fff;
  font-size: 20px;
}

.detail-card {
  padding: 14px;
}

.detail-card.attention,
.quick-entry.attention-strong {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 178, 123, 0.16), 0 12px 28px rgba(29, 64, 72, 0.08);
}

.quick-entry.attention-strong #workbenchBadge {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.detail-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.detail-card dl,
.detail-card div {
  margin: 0;
}

.detail-card div {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.detail-card dt {
  color: var(--muted);
}

.detail-card dd {
  margin: 0;
}

.history-card {
  padding: 14px;
}

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

.history-head h2 {
  margin: 0;
  font-size: 16px;
}

.history-head button {
  height: 28px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
}

.recent-list {
  display: grid;
  gap: 7px;
}

.recent-list button,
.recent-list p {
  margin: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfd;
  color: #42575e;
  padding: 8px 10px;
  text-align: left;
}

.recent-list button:hover,
.recent-list button:focus-visible {
  border-color: var(--green);
  background: var(--green-soft);
  outline: none;
}

.recent-list b,
.recent-list span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.quick-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.selected-template {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #afead3;
  border-radius: 7px;
  background: var(--green-soft);
  padding: 9px 10px;
}

.selected-template b,
.selected-template span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-template span {
  margin-top: 2px;
  color: #45645c;
  font-size: 12px;
}

.selected-template button {
  height: 28px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: #fff;
  color: #08794d;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.workbench-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.workbench-title h2 {
  margin: 0;
  font-size: 15px;
}

.workbench-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#workbenchBadge {
  flex: 0 0 auto;
  border: 1px solid #afead3;
  border-radius: 999px;
  background: var(--green-soft);
  color: #08794d;
  padding: 4px 8px;
  font-size: 12px;
}

.quick-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.quick-tabs button {
  height: 32px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: #52666d;
}

.quick-tabs button.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: #08794d;
  font-weight: 700;
}

.entry-form {
  display: none;
  gap: 8px;
}

.entry-form.active {
  display: grid;
}

.entry-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.entry-form input,
.entry-form select,
.entry-form textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px;
  outline: none;
}

.entry-form textarea {
  min-height: 76px;
  resize: vertical;
}

.entry-form button[type="submit"] {
  height: 34px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

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

.form-actions button[type="submit"] {
  padding: 0 6px;
  background: #fff;
  color: #314850;
  border-color: var(--line-dark);
  font-size: 12px;
}

.form-actions button[type="submit"]:first-child {
  border-color: var(--green);
  color: #08794d;
  background: var(--green-soft);
}

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

.process-step {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  text-align: left;
}

.process-step.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.process-step.skipped {
  color: var(--muted);
  background: #f3f5f6;
}

.process-step b,
.process-step span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-step span,
.form-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.entry-status {
  min-height: 36px;
  margin: 10px 0 0;
  color: #52666d;
  line-height: 1.5;
  font-size: 12px;
}

.entry-status[data-state="success"] {
  color: #08794d;
}

.entry-status[data-state="error"] {
  color: #a44d00;
}

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.bottom-grid article {
  padding: 14px;
}

.module-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

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

.bottom-grid p {
  margin: 0;
  color: #52666d;
  line-height: 1.55;
}

.business-page {
  display: grid;
  gap: 12px;
}

.business-page[hidden] {
  display: none;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.page-panel,
.page-aside,
.owner-board,
.worker-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(29, 64, 72, 0.05);
}

.page-panel,
.page-aside,
.owner-board,
.worker-board {
  padding: 14px;
}

.page-panel h2,
.page-aside h2,
.owner-board h2,
.worker-board h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.record-card {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(160px, 1.5fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfd;
}

.record-card strong,
.record-card span,
.record-card small {
  min-width: 0;
}

.record-card strong {
  color: #16313a;
}

.record-card span,
.record-card small {
  color: #52666d;
}

.record-card small {
  font-size: 12px;
}

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

.insight-list li,
.action-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfd;
  color: #40545b;
  line-height: 1.45;
}

.action-list b {
  color: #142c33;
}

.view-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.quick-entry-slot {
  margin-top: 12px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: start center;
  padding: 9vh 18px 24px;
  background: rgba(8, 20, 24, 0.38);
}

.modal-layer[hidden] {
  display: none;
}

.modal-panel {
  width: min(860px, 100%);
  max-height: 82vh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(9, 30, 36, 0.28);
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: #42575e;
  font-size: 22px;
  line-height: 1;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  padding: 14px 16px;
}

.template-card {
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: var(--ink);
  padding: 13px;
  text-align: left;
}

.template-card:hover,
.template-card:focus-visible,
.template-card.active {
  border-color: var(--green);
  background: var(--green-soft);
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.template-card span {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  color: #08794d;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.template-card b,
.template-card small,
.template-card em {
  display: block;
}

.template-card b {
  margin: 10px 0 6px;
  font-size: 16px;
}

.template-card small,
.template-card em {
  color: var(--muted);
  line-height: 1.45;
}

.template-card em {
  margin-top: 9px;
  font-style: normal;
  font-size: 12px;
}

.modal-actions {
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.modal-actions button {
  min-width: 92px;
  height: 36px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: #314850;
  font-weight: 700;
}

.modal-actions button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

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

  .side {
    min-height: auto;
    padding-bottom: 10px;
  }

  .side .menu {
    display: none;
  }

  .side-summary {
    display: none;
  }

  .mobile-page-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0 12px;
    background: var(--bg);
  }

  .mobile-page-tabs button {
    flex: 0 0 auto;
    height: 34px;
    border: 1px solid var(--line-dark);
    border-radius: 999px;
    background: #fff;
    color: #42575e;
    padding: 0 12px;
    white-space: nowrap;
  }

  .mobile-page-tabs button.active {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
    font-weight: 700;
  }

  .content-grid,
  .metric-row,
  .bottom-grid,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .record-card {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .top,
  .tools,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tools input,
  .tools select {
    width: 100%;
  }

  .api-status {
    justify-content: center;
    width: 100%;
  }
}
