:root {
  --brand: #0abb87;
  --brand-hover: #3bc99f;
  --brand-active: #09a87a;
  --brand-soft: #e7f8f3;
  --workspace: #f3f3f3;
  --surface: #ffffff;
  --text: #303133;
  --body: #606266;
  --muted: #909399;
  --placeholder: #c0c4cc;
  --line: #dcdfe6;
  --line-soft: #ebeef5;
  --header-soft: #f5f7fa;
  --success: #0abb87;
  --success-soft: #e7f8f3;
  --warning: #e6a23c;
  --warning-soft: #fdf6ec;
  --danger: #f56c6c;
  --danger-soft: #fef0f0;
  --info: #409eff;
  --info-soft: #ecf5ff;
  --purple: #7856d8;
  --purple-soft: #f1edff;
  --shadow: 0 1px 3px rgba(31, 45, 61, .10);
  --dialog-shadow: 0 10px 32px rgba(31, 45, 61, .20);
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--workspace);
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  color: var(--text);
  background: var(--workspace);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.topbar {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto 0;
  height: 58px;
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.brand-block {
  width: 60px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 60px;
  color: #fff;
  background: #58bc8e;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.hamburger {
  width: 52px;
  height: 58px;
  display: grid;
  align-content: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  color: #111;
  background: #fff;
}

.hamburger span { width: 18px; height: 1px; background: currentColor; }
.hamburger:hover { background: #fafafa; }

.system-title { color: #4d4f52; font-size: 16px; }

.demo-chip {
  height: 24px;
  display: inline-flex;
  align-items: center;
  margin-left: 14px;
  padding: 0 9px;
  border: 1px solid #c7eadf;
  border-radius: 3px;
  color: #16805f;
  background: #f1fbf7;
  font-size: 12px;
}

.topbar-spacer { flex: 1; }
.top-link { height: 32px; padding: 0 10px; border: 0; color: var(--body); background: transparent; }
.top-link:hover { color: var(--brand-active); }

.user-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  margin-left: 4px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-size: 12px;
}

.user-name { margin: 0 18px 0 8px; color: var(--body); font-size: 13px; }

.sidebar {
  position: fixed;
  z-index: 90;
  top: 58px;
  bottom: 0;
  left: 0;
  width: 60px;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #f0f0f0;
  transition: width .2s ease;
}

.sidebar nav { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 8px 24px; }

.nav-item {
  position: relative;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  color: #62666b;
  background: transparent;
  text-align: left;
  white-space: nowrap;
  transition: color .15s, background .15s, width .2s;
}

.nav-item:hover { color: var(--brand-active); background: #f4fbf8; }
.nav-item.active { color: var(--brand-active); background: #eef9f5; }

.nav-glyph {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  font-size: 15px;
}

.nav-glyph::before {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
}

.glyph-stock::before { content: "库"; }
.glyph-in::before { content: "入"; }
.glyph-out::before { content: "出"; }
.glyph-flow::before { content: "流"; }
.glyph-stat::before { content: "统"; }
.glyph-task::before { content: "任"; }
.glyph-plan::before { content: "计"; }

.nav-label { opacity: 0; transition: opacity .1s; }
.nav-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 8px;
  color: #fff;
  background: var(--danger);
  font-size: 10px;
  line-height: 16px;
}

.nav-expanded .sidebar { width: 200px; }
.nav-expanded .sidebar nav { align-items: stretch; }
.nav-expanded .nav-item { width: 184px; padding-right: 12px; }
.nav-expanded .nav-label { opacity: 1; }
.nav-expanded .nav-badge { position: static; margin-left: auto; }

.main-container {
  position: fixed;
  inset: 58px 0 0 60px;
  min-width: 0;
  background: var(--workspace);
  transition: left .2s ease;
}

.nav-expanded .main-container { left: 200px; }

.tags-view {
  height: 44px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 4px 10px 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--workspace);
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.tag-page {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px 10px 0 0;
  color: #777;
  background: #e9e9e9;
  font-size: 14px;
}

.tag-page:hover { color: var(--text); background: #efefef; }
.tag-page.active { color: var(--text); background: #fff; }
.tag-close { color: #aaa; font-size: 12px; }
.tag-close:hover { color: var(--danger); }

.app-main {
  height: calc(100vh - 102px);
  padding: 12px 10px 10px;
  overflow: auto;
  background: var(--workspace);
}

.page-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.page-context {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.page-context h1 { margin: 0; color: var(--text); font-size: 18px; font-weight: 600; }
.page-context p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.context-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.panel {
  min-width: 0;
  background: #fff;
  border-radius: 2px;
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-title { color: var(--text); font-size: 15px; font-weight: 600; }
.panel-subtitle { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }
.panel-body { padding: 14px; }

.filter-panel { padding: 16px 14px 14px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 14px 18px;
  align-items: center;
}

.filter-field {
  min-width: 0;
  display: grid;
  grid-template-columns: 96px minmax(120px, 1fr);
  align-items: center;
  gap: 10px;
}

.filter-field.wide { grid-column: span 2; }
.filter-field label { color: #74777b; white-space: nowrap; }
.filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.control,
.form-control {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

select.control, select.form-control { padding-right: 30px; }
textarea.form-control { height: 82px; padding-top: 8px; resize: vertical; }
.control::placeholder, .form-control::placeholder { color: var(--placeholder); }
.control:focus, .form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(10,187,135,.10); }
.control:disabled, .form-control:disabled { color: var(--muted); background: #f5f7fa; }

.btn {
  min-width: 86px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--body);
  background: #fff;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}

.btn:hover { color: var(--brand-active); border-color: #9bdcc8; background: #f3fbf8; }
.btn.primary { color: #fff; border-color: var(--brand); background: var(--brand); }
.btn.primary:hover { color: #fff; border-color: var(--brand-hover); background: var(--brand-hover); }
.btn.primary:active { border-color: var(--brand-active); background: var(--brand-active); }
.btn.outline { color: var(--brand-active); border-color: var(--brand); background: #fff; }
.btn.danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.btn.text { min-width: 0; padding: 0 7px; border-color: transparent; color: var(--brand-active); background: transparent; }
.btn.text.danger-text { color: var(--danger); }
.btn.small { min-width: 0; height: 28px; padding: 0 9px; font-size: 12px; }
.btn:disabled { color: #b8bbc0; border-color: #e4e7ed; background: #f5f7fa; }
.btn.primary:disabled { color: #fff; border-color: #9be0ca; background: #9be0ca; }

.text-link {
  padding: 0;
  border: 0;
  color: var(--brand);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.text-link:hover { color: var(--brand-active); }

.toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px 4px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.table-wrap {
  width: calc(100% - 28px);
  margin: 0 14px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.data-table { width: 100%; min-width: 1320px; border-collapse: collapse; table-layout: fixed; }
.data-table.wide { min-width: 2080px; }
.data-table.medium { min-width: 1580px; }
.data-table.compact { min-width: 1080px; }

.data-table th,
.data-table td {
  height: 41px;
  padding: 0 10px;
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  color: var(--body);
  font-size: 14px;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  height: 44px;
  color: var(--muted);
  background: #fff;
  font-weight: 500;
}

.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table tbody tr:hover td { background: #f7fcfa; }
.data-table td.strong { color: var(--text); font-weight: 600; }
.data-table td.number { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table .sticky-right { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -3px 0 5px rgba(0,0,0,.03); }
.data-table th.sticky-right { z-index: 3; }

.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger) !important; }
.warning-text { color: #b87918 !important; }
.success-text { color: var(--brand-active) !important; }

.status-tag {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  color: var(--body);
  background: #f4f4f5;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.status-tag.success { color: #16805f; background: var(--success-soft); }
.status-tag.warning { color: #a86b13; background: var(--warning-soft); }
.status-tag.danger { color: #c64c4c; background: var(--danger-soft); }
.status-tag.info { color: #3575a9; background: var(--info-soft); }
.status-tag.purple { color: #6243b5; background: var(--purple-soft); }
.status-tag.gray { color: var(--muted); background: #f4f4f5; }

.pagination {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 8px 14px;
  color: var(--body);
}
.pagination .page-size { width: 92px; height: 30px; padding: 0 7px; border: 1px solid var(--line); border-radius: 3px; color: var(--body); background: #fff; }
.page-btn { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line-soft); color: var(--body); background: #fff; }
.page-btn:hover { color: var(--brand-active); }
.page-btn.active { color: #fff; border-color: var(--brand); background: var(--brand); }
.page-btn:disabled { color: #c8c9cc; background: #fafafa; }
.page-jump { width: 48px; height: 30px; border: 1px solid var(--line); border-radius: 3px; text-align: center; }

.tabs {
  height: 43px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
}
.tab-btn { position: relative; height: 42px; padding: 0 16px; border: 0; color: var(--body); background: transparent; }
.tab-btn:hover { color: var(--brand-active); }
.tab-btn.active { color: var(--brand-active); font-weight: 600; }
.tab-btn.active::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 2px; background: var(--brand); }
.tab-count { margin-left: 4px; padding: 0 5px; border-radius: 8px; color: var(--muted); background: #f2f3f5; font-size: 11px; }

.notice {
  margin: 0 14px 12px;
  padding: 9px 12px;
  border: 1px solid #b7e4d5;
  border-radius: 3px;
  color: #356b5a;
  background: #f1fbf7;
  font-size: 12px;
  line-height: 1.65;
}
.notice.info { border-color: #b8d8f5; color: #355f84; background: #f1f7fd; }
.notice.warning { border-color: #f0d7ad; color: #855f24; background: #fdf8ef; }
.notice.danger { border-color: #f4c5c5; color: #a84848; background: #fff5f5; }
.notice strong { color: inherit; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; padding: 0 14px 12px; }
.metric-card { min-height: 82px; padding: 12px 13px; border: 1px solid var(--line-soft); border-radius: 3px; background: #fff; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 7px; color: var(--text); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-note { margin-top: 3px; color: var(--muted); font-size: 11px; }

.modal-overlay {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(25, 31, 36, .42);
}

.dialog {
  width: min(720px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2px;
  background: #fff;
  box-shadow: var(--dialog-shadow);
  animation: dialog-in .16s ease-out;
}
.dialog.wide { width: min(1040px, calc(100vw - 80px)); }
.dialog.xwide { width: min(1240px, calc(100vw - 64px)); }

@keyframes dialog-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.dialog-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
}
.dialog-title { color: var(--text); font-size: 16px; font-weight: 500; }
.dialog-close { width: 32px; height: 32px; border: 0; color: var(--muted); background: transparent; font-size: 22px; }
.dialog-close:hover { color: var(--danger); }
.dialog-body { min-height: 0; padding: 20px 24px; overflow: auto; color: var(--body); }
.dialog-body.no-pad { padding: 0; }
.dialog-foot { min-height: 62px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 0 0 auto; padding: 0 24px; border-top: 1px solid var(--line-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 24px; }
.form-item { min-width: 0; display: grid; grid-template-columns: 110px minmax(0,1fr); align-items: center; gap: 10px; }
.form-item.full { grid-column: 1 / -1; }
.form-item.top { align-items: start; }
.form-label { color: var(--body); text-align: right; }
.required::before { content: "*"; margin-right: 3px; color: var(--danger); }
.form-help { grid-column: 2; margin-top: -5px; color: var(--muted); font-size: 12px; }
.form-error { grid-column: 2; color: var(--danger); font-size: 12px; }

.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); overflow: hidden; border: 1px solid var(--line-soft); }
.kv-item { min-height: 42px; display: grid; grid-template-columns: 132px minmax(0,1fr); border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.kv-item:nth-child(even) { border-right: 0; }
.kv-item label { padding: 10px 12px; color: var(--muted); background: #fafafa; }
.kv-item span { min-width: 0; padding: 10px 12px; overflow-wrap: anywhere; color: var(--body); }

.detail-section { margin-top: 18px; }
.detail-section:first-child { margin-top: 0; }
.detail-heading { margin: 0 0 10px; color: var(--text); font-size: 14px; font-weight: 600; }

.step-list { display: grid; gap: 0; }
.step-item { position: relative; display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; padding: 0 0 18px; }
.step-item:not(:last-child)::before { content: ""; position: absolute; top: 24px; bottom: 0; left: 11px; width: 1px; background: var(--line); }
.step-icon { position: relative; z-index: 1; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: #f2f3f5; font-size: 12px; }
.step-icon.success { color: #fff; background: var(--brand); }
.step-icon.processing { color: #fff; background: var(--info); }
.step-icon.failed, .step-icon.blocked { color: #fff; background: var(--danger); }
.step-icon.pending { color: var(--muted); background: #f2f3f5; }
.step-main strong { display: block; margin-top: 2px; color: var(--text); font-size: 13px; }
.step-main p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.step-time { color: var(--muted); font-size: 11px; }

.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; padding: 14px; }
.rule-card { min-height: 132px; padding: 14px; border: 1px solid var(--line-soft); border-radius: 3px; background: #fff; }
.rule-card h3 { margin: 0 0 8px; color: var(--text); font-size: 14px; }
.rule-card p { margin: 0; color: var(--body); font-size: 12px; line-height: 1.75; }
.rule-number { width: 24px; height: 24px; display: grid; place-items: center; margin-bottom: 9px; border-radius: 50%; color: #fff; background: var(--brand); font-size: 12px; }

.flow-arrow { color: var(--muted); }
.empty-state { padding: 54px 20px; color: var(--muted); text-align: center; }
.empty-mark { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px dashed #c8c9cc; border-radius: 50%; font-size: 20px; }

.invoice-preview { display: grid; gap: 12px; }
.invoice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line-soft); background: #fafafa; }
.invoice-head h3 { margin: 0 0 5px; color: var(--text); font-size: 15px; }
.invoice-head p { margin: 0; color: var(--muted); font-size: 12px; }

.toast-stack { position: fixed; z-index: 900; top: 72px; left: 50%; display: grid; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  min-width: 340px;
  max-width: min(560px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--body);
  background: #fff;
  box-shadow: 0 6px 18px rgba(31,45,61,.14);
  animation: toast-in .2s ease-out;
}
.toast.success { border-color: #bde6d8; background: #f2fbf8; }
.toast.warning { border-color: #f1d8af; background: #fffaf2; }
.toast.error { border-color: #f4c5c5; background: #fff5f5; }
.toast.info { border-color: #c5ddf3; background: #f5f9fd; }
.toast-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--brand); }
.toast.warning .toast-dot { background: var(--warning); }
.toast.error .toast-dot { background: var(--danger); }
.toast.info .toast-dot { background: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1800px) {
  .filter-grid { grid-template-columns: repeat(5, minmax(240px, 1fr)); }
}

@media (max-width: 1320px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
  .metric-grid { grid-template-columns: repeat(3, minmax(140px,1fr)); }
  .rule-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 920px) {
  .demo-chip, .user-name { display: none; }
  .app-main { padding: 10px 8px; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-field.wide { grid-column: auto; }
  .filter-actions { justify-content: flex-start; padding-left: 106px; }
  .page-context { align-items: flex-start; flex-direction: column; }
  .form-grid, .kv-grid { grid-template-columns: 1fr; }
  .form-item.full { grid-column: auto; }
  .kv-item { border-right: 0; }
  .rule-grid { grid-template-columns: 1fr; }
  .dialog, .dialog.wide, .dialog.xwide { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .modal-overlay { padding: 12px; }
}

@media (max-width: 620px) {
  .top-link { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .filter-field { grid-template-columns: 82px minmax(0,1fr); }
  .filter-actions { padding-left: 92px; flex-wrap: wrap; }
  .dialog-body { padding: 16px 14px; }
  .dialog-head, .dialog-foot { padding-right: 14px; padding-left: 14px; }
  .form-item { grid-template-columns: 88px minmax(0,1fr); }
  .kv-item { grid-template-columns: 110px minmax(0,1fr); }
}
