/* ============================================================
   功能演示区（内嵌在讲解页底部）专用样式
   与 theme.css 独立，互不影响；仅 P10 / P12 / P16 引入
   ============================================================ */

/* 演示区容器：用虚线边框与讲解内容区分，暗示"这是可以点的真界面" */
.demo {
  border: 1px dashed var(--brand-line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px 18px 18px;
  margin-top: 6px;
}
.demo-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.demo-hd h4 { margin: 0; display: flex; align-items: center; gap: 8px; }
.demo-hd .live {
  font-size: 11px; font-weight: 400; color: var(--teal);
  background: var(--teal-soft); border: 1px solid #9fe1cb;
  border-radius: 20px; padding: 1px 8px;
}

/* 工具栏：搜索 + 筛选 + 操作 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="text"], .toolbar select {
  font-family: var(--font); font-size: 13px;
  padding: 5px 10px; border: 1px solid var(--line-2);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.toolbar input[type="text"]:focus, .toolbar select:focus { outline: none; border-color: var(--brand-line); }
.toolbar .grow { flex: 1 1 auto; }

/* 状态徽标 */
.badge {
  display: inline-block; font-size: 11.5px; line-height: 1.9;
  padding: 0 9px; border-radius: 20px; white-space: nowrap;
}
.badge.draft { background: var(--surface-2); color: var(--text-2); }
.badge.wait { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--blue-soft, #e6f1fb); color: var(--brand-dark); background: #e6f1fb; }
.badge.run { background: #e6f1fb; color: var(--brand-dark); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.stop { background: var(--red-soft); color: var(--red); }
.badge.qc { background: #faeeda; color: var(--amber); }

/* 数据表格（可排序 + 行点击） */
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th, .dtable td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.dtable th {
  background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2);
  position: sticky; top: 0;
}
.dtable th.sortable { cursor: pointer; user-select: none; }
.dtable th.sortable:hover { color: var(--brand-dark); }
.dtable th .arrow { font-size: 10px; color: var(--brand); margin-left: 3px; }
.dtable td.num, .dtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable tbody tr { cursor: pointer; }
.dtable tbody tr:hover { background: var(--brand-soft); }
.dtable .row-act { display: flex; gap: 6px; }
/* 表格宿主容器：宽表在窄屏下于容器内横向滚动，不撑破整页布局 */
.dtable-host { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 空态 */
.empty { padding: 34px 10px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .e-icon { font-size: 22px; display: block; margin-bottom: 6px; color: var(--line-2); }

/* 分页 */
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.pager-bar .pages { display: flex; gap: 4px; }
.pager-bar .pages button {
  min-width: 28px; height: 28px; border: 1px solid var(--line-2);
  background: var(--surface); border-radius: 6px; cursor: pointer; font-size: 12.5px; font-family: var(--font);
}
.pager-bar .pages button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-bar .pages button:disabled { opacity: .4; cursor: not-allowed; }

/* 抽屉（详情） */
.drawer-mask {
  position: absolute; inset: 0; background: rgba(44, 44, 42, .28);
  z-index: 60; opacity: 0; transition: opacity .2s;
}
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100%;
  background: var(--surface); z-index: 61; box-shadow: -6px 0 24px rgba(0, 0, 0, .08);
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.drawer.open, .drawer-mask.open { }
.drawer-mask.show { opacity: 1; }
.drawer.show { transform: translateX(0); }
.drawer-hd {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.drawer-hd h3 { margin: 0 0 2px; font-size: 16px; }
.drawer-bd { padding: 14px 18px; overflow-y: auto; flex: 1; }
.drawer-ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.x-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--text-3); line-height: 1; }
.x-btn:hover { color: var(--text); }

/* 字段分组 */
.field-group { margin-bottom: 16px; }
.field-group .fg-title { font-size: 12px; color: var(--text-3); margin-bottom: 6px; letter-spacing: .3px; }
.field-group .kv { grid-template-columns: 118px 1fr; font-size: 13px; }

/* 时间线（流转记录） */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 0 0 12px 18px; border-left: 2px solid var(--line);
  position: relative; font-size: 12.5px; color: var(--text-2);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 4px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--brand);
}
.timeline li .t-time { color: var(--text-3); font-size: 11.5px; }

/* 模态（表单） */
.modal-mask {
  position: absolute; inset: 0; background: rgba(44, 44, 42, .3);
  z-index: 70; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 560px; max-width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
}
.modal-hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-hd h3 { margin: 0; font-size: 16px; }
.modal-bd { padding: 16px 18px; }
.modal-desc { font-size: 12.5px; color: var(--text-3); margin-bottom: 12px; line-height: 1.7; }
.modal-ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* 表单 */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.form-row label .req { color: var(--red); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; font-family: var(--font); font-size: 13px;
  padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--brand-line); }
.form-row .err { font-size: 11.5px; color: var(--red); margin-top: 3px; display: none; }
.form-row.invalid input, .form-row.invalid select { border-color: #e24b4a; }
.form-row.invalid .err { display: block; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Toast */
.toast-wrap { position: absolute; top: 18px; right: 22px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  animation: toastIn .18s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: #ef9f27; }
.toast.err { border-left-color: #e24b4a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 库存水位条（P12 用） */
.level-cell { min-width: 120px; }
.level-bar { background: var(--surface-2); border-radius: 20px; height: 8px; overflow: hidden; margin-top: 4px; }
.level-bar > span { display: block; height: 100%; border-radius: 20px; transition: width .3s; }

/* 运单轨迹条（P20 用） */
.track { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; min-width: 300px; }
.track .tk {
  font-size: 11px; padding: 1px 6px; border-radius: 20px; white-space: nowrap;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line);
}
.track .tk.on { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand-line); }
.track .tk.cur { background: #faeeda; color: var(--amber); border-color: #fac775; font-weight: 600; }
.track .tk.bad { background: var(--red-soft); color: var(--red); border-color: #f7c1c1; font-weight: 600; }
.track .tk-line { width: 12px; height: 2px; background: var(--line); }
.track .tk-line.on { background: var(--brand-line); }

/* 演示区底部提示 */
.demo-tip { font-size: 12px; color: var(--text-3); margin-top: 10px; }
