/* ============================================================
   代练订单分配 + 币号库存系统 · 统一视觉样式
   主色蓝 / 深灰，企业风；员工端响应式（≥1024 桌面 / <768 手机）
   ============================================================ */
:root {
  --blue: #1d4ed8;
  --blue-600: #2563eb;
  --blue-50: #eff6ff;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --gray: #64748b;
  --gray-2: #94a3b8;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --green: #15803d;
  --orange: #c2410c;
  --red: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .2px; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.muted { color: var(--gray); }
.tiny { font-size: 12px; }
.mono { font-family: "JetBrains Mono", Consolas, monospace; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------------------------------------------------------- 登录页 */
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #0b1220;
}
.login-art {
  position: relative; padding: 56px; color: #e2e8f0; overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(37, 99, 235, .45), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(14, 165, 233, .28), transparent 55%),
    linear-gradient(160deg, #0b1220, #111c33 55%, #0b1220);
}
.login-art h1 { font-size: 30px; line-height: 1.35; color: #fff; }
.login-art .kicker { letter-spacing: 3px; font-size: 12px; color: #93c5fd; margin-bottom: 18px; }
.login-art ul { margin: 28px 0 0; padding: 0; list-style: none; }
.login-art li { padding: 9px 0 9px 26px; position: relative; color: #cbd5e1; }
.login-art li::before {
  content: ""; position: absolute; left: 0; top: 16px; width: 8px; height: 8px;
  border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 4px rgba(96, 165, 250, .16);
}
.login-art .flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; font-size: 12px; }
.login-art .flow span {
  border: 1px solid rgba(148, 163, 184, .35); padding: 6px 10px; border-radius: 999px; color: #cbd5e1;
}
.login-panel { background: #fff; display: flex; align-items: center; justify-content: center; padding: 40px 26px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--gray); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field .hint { font-size: 12px; color: var(--gray-2); margin-top: 4px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.quick button {
  border: 1px dashed var(--line); background: #fff; color: var(--gray); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; font-size: 12px;
}
.quick button:hover { border-color: var(--blue-600); color: var(--blue); }

/* ---------------------------------------------------------- 按钮 / 表单 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; background: var(--blue);
  color: #fff; cursor: pointer; font-weight: 600; transition: .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); font-weight: 500; }
.btn.ghost:hover { border-color: var(--blue-600); color: var(--blue); background: #fff; }
.btn.danger { background: var(--red); }
.btn.success { background: var(--green); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn.link { background: none; border: none; color: var(--blue); padding: 4px 6px; font-weight: 500; }
.btn.link.danger { color: var(--red); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------- 后台框架 */
.shell { display: grid; grid-template-columns: 226px 1fr; min-height: 100vh; }
.sidebar {
  background: #0b1220; color: #cbd5e1; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; color: #fff; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand small { display: block; color: #94a3b8; font-size: 11px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  color: #cbd5e1; font-size: 13.5px; border: none; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(37, 99, 235, .55)); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sep { margin: 12px 10px 6px; font-size: 11px; color: #64748b; letter-spacing: 2px; }
.sidebar .foot { margin-top: auto; font-size: 11px; color: #64748b; padding: 12px 10px 0; border-top: 1px solid rgba(148, 163, 184, .16); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 12px 22px; display: flex;
  align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--blue-50); color: var(--blue);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.content { padding: 20px 22px 40px; }

/* ---------------------------------------------------------- 卡片 / 统计 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-hd { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-hd h3 { font-size: 14px; }
.card-hd .spacer { flex: 1; }
.card-bd { padding: 16px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .k { font-size: 12px; color: var(--gray); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .sub { font-size: 12px; color: var(--gray-2); }
.stat.warn { border-color: #fecaca; background: #fff7f7; }
.stat.warn .v { color: var(--red); }
.stat.ok .v { color: var(--green); }
.stat.info .v { color: var(--blue); }

/* ---------------------------------------------------------- 表格 */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 14px; background: #f8fafc; color: var(--gray); font-weight: 600;
  font-size: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
table.tbl tr:hover td { background: #fafcff; }
table.tbl tr.row-danger td { background: #fff6f6; }
table.tbl tr.row-danger:hover td { background: #ffecec; }
table.tbl tr.row-tip td { background: #fffdf3; }
table.tbl tr.row-tip:hover td { background: #fff8e1; }
table.tbl .empty { padding: 34px; text-align: center; color: var(--gray-2); }
table.tbl td.actions { white-space: nowrap; }
table.tbl td.mono, table.tbl td.staff-cell { white-space: nowrap; }
table.tbl.wide-table { min-width: 1000px; }
/* 宽表：库存 / 流水 / 报表 / 供应商 等列多的表格，允许横向滚动而不是挤成竖排 */
#inv-body table.tbl { min-width: 1040px; }
#report-body table.tbl { min-width: 1000px; }
#pane table.tbl { min-width: 960px; }

/* ---------------------------------------------------------- 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.6; font-weight: 600; white-space: nowrap;
}
.tag.blue { background: #e0edff; color: #1d4ed8; }
.tag.gray { background: #eef2f7; color: #475569; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.orange { background: #ffedd5; color: #c2410c; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.purple { background: #ede9fe; color: #6d28d9; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------- 工具条 / 分页 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar input, .toolbar select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 120px;
}
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 16px; font-size: 12px; color: var(--gray); }
.tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 8px; border: 1px solid transparent; background: none; cursor: pointer;
  color: var(--gray); font-weight: 600; font-size: 13px;
}
.tab:hover { background: #f1f5fb; color: var(--ink); }
.tab.active { background: var(--blue-50); color: var(--blue); border-color: #c7ddff; }
.tab .count { font-size: 11px; background: #e2e8f0; color: var(--gray); padding: 0 6px; border-radius: 999px; margin-left: 5px; }

/* ---------------------------------------------------------- 弹层 */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(2, 6, 23, .35);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 860px; }
.modal-hd { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-hd h3 { font-size: 15px; }
.modal-hd .x { margin-left: auto; background: none; border: none; font-size: 20px; color: var(--gray-2); cursor: pointer; }
.modal-bd { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-ft { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------------------------------------------------------- 截图 */
.shots { display: flex; flex-wrap: wrap; gap: 10px; }
.shot { position: relative; width: 132px; }
.shot img {
  width: 132px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
  cursor: zoom-in; display: block; background: #0f172a;
}
.shot .meta { font-size: 11px; color: var(--gray-2); margin-top: 3px; line-height: 1.3; }
.shot .del {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(15, 23, 42, .72); color: #fff; cursor: pointer; font-size: 12px;
  display: grid; place-items: center;
}
.lightbox {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .92); z-index: 200; display: grid; place-items: center;
  padding: 24px; cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.uploader {
  border: 1.5px dashed #c7d2e4; border-radius: 10px; padding: 18px; text-align: center; color: var(--gray);
  background: #f8fafc; cursor: pointer; transition: .15s;
}
.uploader:hover, .uploader.drag { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue); }
.uploader strong { color: var(--ink); }
.progress { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }

/* ---------------------------------------------------------- toast / 空态 */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, .3); animation: pop .15s; max-width: 380px;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--gray-2); }
.empty-state .big { font-size: 30px; margin-bottom: 8px; opacity: .6; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef2f7, #e2e8f0, #eef2f7); background-size: 200% 100%; animation: sk 1.1s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ============================================================ 员工端 */
.staff-body { background: #f4f6fb; }
.staff-top {
  background: #0b1220; color: #fff; padding: 14px 20px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.staff-top .who { font-size: 15px; font-weight: 650; }
.staff-top .sub { font-size: 12px; color: #94a3b8; }
.staff-top .spacer { flex: 1; }
.staff-top .kpis { display: flex; gap: 18px; }
.staff-top .kpis div { text-align: center; }
.staff-top .kpis b { display: block; font-size: 17px; }
.staff-top .kpis span { font-size: 11px; color: #94a3b8; }
.staff-layout { display: grid; grid-template-columns: 420px 1fr; gap: 16px; padding: 16px 20px 30px; align-items: start; }
.staff-nav { display: flex; gap: 2px; padding: 10px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.staff-nav .tab { padding: 6px 10px; font-size: 12.5px; }

.order-card {
  border-bottom: 1px solid #eef2f7; padding: 12px 14px; cursor: pointer; border-left: 3px solid transparent;
}
.order-card:hover { background: #f8fbff; }
.order-card.active { background: var(--blue-50); border-left-color: var(--blue); }
.order-card.p0 { border-left-color: #dc2626; }
.order-card.p1 { border-left-color: #ea580c; }
.order-card.tip { border-left-color: #f59e0b; border-left-width: 4px; }
.order-card .line1 { display: flex; align-items: center; gap: 8px; }
.order-card .no { font-size: 11px; color: var(--gray-2); font-family: Consolas, monospace; }
.order-card .desc { font-weight: 600; margin: 4px 0 2px; }
.order-card .meta { font-size: 12px; color: var(--gray); display: flex; gap: 10px; flex-wrap: wrap; }
.order-card.overdue { background: #fff6f6; }
.order-card.overdue .desc::after { content: " 超时"; color: var(--red); font-size: 11px; }

.detail-pane { position: sticky; top: 78px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 13px; }
.kv .k { color: var(--gray); }
.kv .secret-row, .secret-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv .secret-row .btn.link, .secret-row .btn.link { padding: 2px 4px; font-size: 12px; }
.big-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.bottom-nav { display: none; }

/* ============================================================ 供应商端 */
.sup-top {
  background: linear-gradient(120deg, #0b1220, #14263f); color: #fff; padding: 18px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.sup-top .name { font-size: 18px; font-weight: 700; }
.sup-top .muted { color: #94a3b8; }
.balance-cell b { font-size: 15px; color: var(--ink); }
.balance-cell.low b { color: var(--red); }
.balance-remark { font-size: 12px; color: var(--orange); background: #fff7ed; border: 1px dashed #fed7aa;
  border-radius: 6px; padding: 2px 6px; display: inline-block; margin-top: 3px; }
.diff { display: flex; align-items: center; gap: 10px; font-size: 14px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.diff .old { color: var(--gray); }
.diff .new { color: var(--blue); font-weight: 700; }

/* ============================================================ 响应式 */
@media (max-width: 1100px) {
  .staff-layout { grid-template-columns: 340px 1fr; }
}
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; z-index: 60; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .mobile-menu-btn { display: inline-flex !important; }
  .staff-layout { grid-template-columns: 1fr; }
  .detail-pane { display: none; }  /* 平板/手机端改用弹层详情，避免出现空面板 */
}
@media (max-width: 767px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .content { padding: 14px 12px 90px; }
  .topbar { padding: 10px 12px; }
  .topbar h1 { font-size: 15px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px; }
  .stat .v { font-size: 21px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 10px 12px; }
  .toolbar input, .toolbar select { flex: 1 1 44%; min-width: 0; }
  .table-wrap { overflow-x: auto; }
  table.tbl { min-width: 720px; }
  .modal-bd { max-height: 76vh; }
  /* 员工端手机版：单列卡片 + 底部固定操作 */
  .staff-top { padding: 12px 14px; flex-wrap: wrap; gap: 8px 10px; }
  .staff-top .avatar { width: 30px; height: 30px; font-size: 12px; flex: 0 0 auto; }
  .staff-top .who { font-size: 15px; white-space: nowrap; }
  .staff-top .sub { font-size: 11px; }
  .staff-top .spacer { display: none; }
  .staff-top > div:nth-child(2) { flex: 1 1 auto; min-width: 0; }
  .staff-top .kpis { width: 100%; order: 9; justify-content: space-between; gap: 4px; padding-top: 6px;
    border-top: 1px solid rgba(148,163,184,.16); }
  .staff-top .kpis b { font-size: 16px; }
  .staff-top .kpis div { flex: 1; }
  .staff-top .kpis span { white-space: nowrap; font-size: 10.5px; }
  .staff-layout { padding: 12px 12px 104px; }
  .staff-nav { overflow-x: auto; flex-wrap: nowrap; }
  .order-card { padding: 14px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; z-index: 50;
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(15, 23, 42, .06);
  }
  .bottom-nav button {
    flex: 1; border: none; background: none; padding: 6px 2px; color: var(--gray); font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  }
  .bottom-nav button .ico { font-size: 17px; }
  .bottom-nav button.active { color: var(--blue); font-weight: 700; }
  .sticky-actions {
    position: fixed; left: 0; right: 0; bottom: 58px; background: #fff; padding: 10px 12px;
    border-top: 1px solid var(--line); display: flex; gap: 8px; z-index: 45;
  }
  .sticky-actions .btn { flex: 1; }
}
@media (min-width: 1025px) {
  .mobile-menu-btn { display: none !important; }
}
