:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-soft: #6b7280;
  --line: #e6e8ec;
  --brand: #ff7a18;
  --brand-soft: #fff1e6;
  --brand-ink: #c2410c;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(20, 24, 40, 0.06), 0 6px 20px rgba(20, 24, 40, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

/* ---------- 登录 ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #fff1e6 0%, #f5f6f8 60%);
}
.login-card {
  width: 360px;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}
/* 自动登录恢复会话时，淡化并锁定表单，避免闪现输入框 */
.login-card.is-restoring form { opacity: 0.25; pointer-events: none; transition: opacity 0.15s; }
.login-logo { line-height: 0; margin-bottom: 6px; }
.login-logo img { width: 180px; max-width: 70%; height: auto; display: block; margin: 0 auto; }
.login-title { margin: 8px 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 24px; color: var(--ink-soft); letter-spacing: 1px; font-size: 12px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 13px; }
.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--brand); }
.login-error { color: var(--danger); font-size: 13px; margin: 4px 0 0; }
.login-foot { margin-top: 18px; color: var(--ink-soft); font-size: 12px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 230px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-logo { line-height: 0; flex: 0 0 auto; }
.brand-logo img { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 700; line-height: 1.2; font-size: 16px; }
.brand-name span { font-size: 12px; color: var(--ink-soft); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  text-align: left;
  border: none;
  background: transparent;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-parent { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.nav-parent .nav-label { flex: 1; }
.nav-parent .caret { font-size: 11px; transition: transform .15s; opacity: .7; }
.nav-parent.collapsed .caret { transform: rotate(-90deg); }
.nav-group { display: flex; flex-direction: column; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 2px 14px; padding-left: 12px; border-left: 2px solid var(--line); }
.nav-sub[hidden] { display: none !important; }
.nav-subitem {
  text-align: left; border: none; background: transparent;
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px; color: var(--ink-soft);
  cursor: pointer; transition: all .15s;
}
.nav-subitem:hover { background: var(--bg); color: var(--ink); }
.nav-subitem.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: var(--ink-soft); font-size: 12px; }

.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; font-size: 18px; line-height: 1; cursor: pointer;
}
.menu-btn:active { background: var(--bg); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; }
.sidebar-backdrop.show { display: block; }
.topbar-actions { display: flex; gap: 10px; }

.view { padding: 22px 26px; overflow-y: auto; flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: #d3d6db; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #f06a08; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: #f3c6c6; }
.btn-danger:hover { background: #fef2f2; }

/* ---------- 看板 ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.board-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 120px;
}
.board-col-head {
  padding: 12px 14px; font-weight: 600; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.board-col-head .count { background: var(--bg); color: var(--ink-soft); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.board-col-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; cursor: pointer; transition: box-shadow .15s, transform .05s;
}
.card:hover { box-shadow: var(--shadow); }
.card:active { transform: scale(.995); }
.card-title { font-weight: 600; margin-bottom: 8px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--bg); color: var(--ink-soft); }
.badge.p-高 { background: #fde8e8; color: var(--danger); }
.badge.p-中 { background: #fff4e0; color: var(--warn); }
.badge.p-低 { background: #e7f6ee; color: var(--ok); }
.card-progress { height: 6px; background: var(--bg); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.card-progress > i { display: block; height: 100%; background: var(--brand); }
.card-due { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.card-due.overdue { color: var(--danger); font-weight: 600; }
.empty { color: var(--ink-soft); font-size: 13px; text-align: center; padding: 14px 0; }

/* ---------- 项目 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.proj-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.proj-card h4 { margin: 0 0 6px; font-size: 15px; }
.proj-card .desc { color: var(--ink-soft); font-size: 13px; min-height: 20px; }
.proj-meta { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12px; color: var(--ink-soft); }
.bar { height: 8px; background: var(--bg); border-radius: 5px; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #ffb072); }

/* ---------- 仪表盘 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.stat .num { font-size: 30px; font-weight: 700; }
.stat .label { color: var(--ink-soft); margin-top: 4px; }
.stat.accent .num { color: var(--brand); }
.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel-card h3 { margin: 0 0 14px; font-size: 15px; }
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.kv-row .name { width: 90px; color: var(--ink-soft); }
.kv-bar { flex: 1; height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.kv-bar > i { display: block; height: 100%; background: var(--brand); }
.kv-row .val { width: 40px; text-align: right; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- 弹窗 ---------- */
[hidden] { display: none !important; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,24,40,.45);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-mask:not([hidden]) { display: flex; }
.modal {
  width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.modal-body { padding: 20px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--brand); }
.form-row textarea { resize: vertical; min-height: 64px; }
.form-readonly { padding: 8px 10px; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; color: var(--ink-soft); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow);
}

/* ---------- 基础信息 / 通用表格 ---------- */
.tabs-wrap { margin-bottom: 16px; }
.tabs {
  display: inline-flex; gap: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 4px;
}
.tab {
  border: none; background: transparent; padding: 8px 18px; border-radius: 8px;
  font-size: 14px; color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--brand); color: #fff; font-weight: 600; }
.toolbar { margin-top: 12px; }
.toolbar .topbar-search {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; width: 260px;
}
.tbl-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { background: #fafbfc; color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.tbl tbody tr:hover { background: var(--bg); }
.tbl .row-actions { display: flex; gap: 8px; white-space: nowrap; }

/* ---------- 导入弹窗 ---------- */
.import-modal { display: flex; flex-direction: column; gap: 14px; }
.imp-tabs { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; align-self: flex-start; }
.imp-tab {
  border: none; background: transparent; padding: 8px 16px; border-radius: 8px;
  font-size: 14px; color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.imp-tab.active { background: var(--panel); color: var(--brand-ink); font-weight: 600; box-shadow: var(--shadow); }
.imp-pane { display: flex; flex-direction: column; gap: 8px; }
.imp-pane input[type="file"] { font-size: 13px; }
.imp-pane textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-family: inherit; resize: vertical; }
.hint { color: var(--ink-soft); font-size: 12px; margin: 0; }
#imp-map p { font-size: 13px; margin: 0 0 10px; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.map-row { display: flex; flex-direction: column; gap: 4px; }
.map-row label { font-size: 12px; color: var(--ink-soft); }

/* 配送单分页标签（配送中 / 完成） */
.subtabs { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; align-self: flex-start; margin-bottom: 10px; }
.subtab { border: none; background: transparent; padding: 8px 16px; border-radius: 8px; font-size: 14px; color: var(--ink-soft); cursor: pointer; transition: all .15s; }
.subtab:hover { background: var(--panel); color: var(--brand-ink); }
.subtab.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.map-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--panel); }

/* ---------- 配送单卡片式移动端视图 ---------- */
.courier-cards { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.courier-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; font-size: 14px; }
.cc-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.cch-shop { font-size: 15px; font-weight: 600; color: var(--brand-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cch-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; flex: none; }
.cch-no { color: var(--ink); font-weight: 500; }
.cc-customer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px dashed var(--line); }
.cc-cust-main { display: flex; align-items: baseline; gap: 6px; min-width: 0; flex: 1; overflow: hidden; }
.cc-cust-name { font-size: 16px; font-weight: 400; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-cust-count { font-size: 12px; color: var(--ink-soft); white-space: nowrap; flex: none; }
.cc-phone { display: inline-flex; align-items: center; font-size: 16px; font-weight: 700; color: var(--brand-ink); text-decoration: none; flex: none; }
.cc-address { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px dashed var(--line); font-size: 14px; line-height: 1.5; }
.cc-addr-text { flex: 1; color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1.5; }
.cc-copy { border: none; background: transparent; color: var(--brand-ink); font-size: 13px; font-weight: 500; cursor: pointer; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.cc-copy:hover { background: var(--brand-soft); }
.cc-product { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px dashed var(--line); }
.cc-prod-info { flex: 1; min-width: 0; }
.cc-prod-name { font-size: 17px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-prod-total { font-size: 18px; font-weight: 700; color: var(--ink); flex: none; white-space: nowrap; }
.cc-extra { padding: 4px 14px; border-bottom: 1px dashed var(--line); }
.cc-remark { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px dashed var(--line); font-size: 14px; line-height: 1.5; color: var(--ink); word-break: break-word; }
.cc-remark-label { flex: none; font-weight: 600; color: var(--ink-soft); }
.cc-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); }
.cc-status { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); }
.cc-status.cc-完成 { background: #dcfce7; color: #15803d; }
.courier-card-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 14px; }
.courier-card-foot .btn-sm { padding: 6px 18px; font-size: 14px; }
@media (max-width: 640px) {
  .cc-header, .cc-customer, .cc-address, .cc-product, .cc-meta, .courier-card-foot { padding-left: 12px; padding-right: 12px; }
  .cc-cust-name { font-size: 15px; }
  .cc-phone { font-size: 15px; }
  .cc-prod-total { font-size: 16px; }
}

/* ---------- 移动端：侧栏改为顶部「三」抽屉 ---------- */
@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 250px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 24px rgba(15, 23, 42, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .content { width: 100%; min-width: 0; overflow-x: hidden; }
  .topbar { padding: 12px 14px; }
  .topbar h2 { font-size: 16px; }
  .view { padding: 14px; }
}
