:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; font-size: 13px; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 13px; color: var(--text); }
.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #dbeafe 0%, transparent 60%),
    linear-gradient(180deg, #f8fbff 0%, #f1f5fb 100%);
}

.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 34px 32px 28px;
  box-shadow: 0 20px 60px -20px rgba(30, 58, 138, .28), 0 2px 8px rgba(15, 23, 42, .04);
  border: 1px solid rgba(226, 232, 240, .9);
}

.login-logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px;
  letter-spacing: .5px;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .7);
}

.login-card h1 { font-size: 19px; margin: 16px 0 6px; letter-spacing: .2px; }
.login-card .sub { color: var(--text-3); font-size: 12.5px; margin-bottom: 24px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
  outline: none; transition: .16s;
}
.field input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

.btn {
  height: 40px; padding: 0 16px; border-radius: 8px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 12px -4px rgba(37, 99, 235, .6); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--text-2); }
.btn-ghost:hover { border-color: #cbd5e1; color: var(--text); background: #f8fafc; }
.btn-danger-ghost { background: #fff; border: 1px solid #fecaca; color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

.login-err { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }
.login-tip { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--text-3); line-height: 1.9; }
.login-tip b { color: var(--text-2); font-weight: 600; }

/* ---------------- 主框架 ---------------- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 292px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}

.brand { padding: 16px 16px 14px; border-bottom: 1px solid var(--line-2); }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.brand-title { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.sidebar-tools { padding: 12px 14px 8px; display: flex; gap: 8px; }

.list { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.list-empty { text-align: center; color: var(--text-3); font-size: 12px; padding: 40px 16px; line-height: 1.8; }

.ship-item {
  padding: 10px 11px; border-radius: 9px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent; transition: .14s; position: relative;
}
.ship-item:hover { background: #f8fafc; }
.ship-item.active { background: var(--blue-soft); border-color: #bfdbfe; }
.ship-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ship-code { font-weight: 700; font-size: 12.5px; letter-spacing: .3px; }
.ship-meta { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex; gap: 8px; align-items: center; }
.ship-progress { margin-top: 8px; height: 3px; background: #eef2f7; border-radius: 3px; overflow: hidden; }
.ship-progress > i { display: block; height: 100%; background: var(--green); border-radius: 3px; transition: width .3s; }

.badge {
  font-size: 10.5px; padding: 2px 7px; border-radius: 20px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap;
}
.badge-pending { background: #f1f5f9; color: var(--text-2); }
.badge-partial { background: var(--amber-soft); color: var(--amber); }
.badge-shipped { background: var(--green-soft); color: var(--green); }

.userbar {
  border-top: 1px solid var(--line-2); padding: 10px 14px;
  display: flex; align-items: center; gap: 9px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: #e0e7ff; color: #3730a3; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.avatar.carrier { background: #dbeafe; color: #1e40af; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--text-3); }

/* ---------------- 主区 ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 60px; flex: none; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
}
.topbar h2 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.topbar .date-chip {
  font-size: 11.5px; color: var(--text-2); background: #f1f5f9;
  padding: 3px 9px; border-radius: 6px;
}
.topbar-spacer { flex: 1; }

.content { flex: 1; overflow: auto; padding: 16px 20px 24px; }

.stats { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; min-width: 116px; box-shadow: var(--shadow);
}
.stat .k { font-size: 11px; color: var(--text-3); }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; letter-spacing: .3px; }
.stat .v small { font-size: 11px; color: var(--text-3); font-weight: 500; margin-left: 2px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  padding: 11px 16px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px; background: #fcfdff;
}
.panel-head h3 { font-size: 13px; font-weight: 700; }
.hint { font-size: 11.5px; color: var(--text-3); }
.panel-head .spacer { flex: 1; }

/* ---------------- 数据表格 ---------------- */
.table-scroll { overflow: auto; max-height: calc(100vh - 268px); }

table.grid { width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0; }

table.grid th {
  position: sticky; top: 0; z-index: 3;
  background: #f8fafc; color: var(--text-2);
  font-size: 11.5px; font-weight: 700; text-align: left;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  letter-spacing: .3px;
}
table.grid td {
  padding: 8px 10px; border-bottom: 1px solid var(--line-2);
  vertical-align: top; font-size: 12.5px; line-height: 1.55;
}
table.grid tbody tr:hover td { background: #fafcff; }
table.grid tbody tr.pkg-end td { border-bottom: 1px solid var(--line); }

.col-seq { width: 36px; text-align: center; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-plat { width: 76px; white-space: nowrap; }
.col-name { width: 80px; min-width: 62px; font-weight: 600; }
.col-phone { width: 106px; min-width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-addr { width: 176px; color: var(--text-2); word-break: break-all; }
.col-prod { width: 136px; }
.col-spec { width: 58px; color: var(--text-2); white-space: nowrap; }
.col-unit { width: 44px; color: var(--text-2); white-space: nowrap; }
.col-qty { width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-order { width: 96px; color: var(--text-3); font-size: 11.5px; }
.col-track { width: 152px; min-width: 128px; }
.col-act { width: 64px; min-width: 58px; }

td.merged { border-right: 1px solid var(--line-2); }
table.grid th.rowhdr { border-right: 1px solid var(--line-2); }

.track-wrap { display: flex; align-items: center; gap: 6px; }
.track-input {
  width: 100%; min-width: 0; height: 30px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; outline: none;
  font-size: 12px; letter-spacing: .4px; font-variant-numeric: tabular-nums;
  transition: .15s;
}
.track-input:hover { border-color: #cbd5e1; }
.track-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.track-input.filled { background: var(--green-soft); border-color: #a7f3d0; color: #047857; font-weight: 600; }
.track-input::placeholder { color: #cbd5e1; font-weight: 400; letter-spacing: 0; }
.track-ro {
  display: block; padding: 5px 0; font-size: 12px; letter-spacing: .4px;
  font-variant-numeric: tabular-nums; color: var(--text-2);
}
.track-ro.filled { color: #047857; font-weight: 700; }
.track-ro.empty { color: var(--text-3); }

.track-flag { font-size: 10.5px; color: var(--green); white-space: nowrap; }
.track-flag.saving { color: var(--text-3); }

.act-row { display: flex; gap: 4px; opacity: .35; transition: .14s; }
table.grid tbody tr:hover .act-row { opacity: 1; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); border-color: var(--line); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.icon-btn svg { width: 14px; height: 14px; }

.empty {
  padding: 64px 20px; text-align: center; color: var(--text-3); line-height: 2;
}
.empty b { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 6px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  display: grid; place-items: center; z-index: 60; padding: 24px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 560px; max-width: 100%; max-height: 88vh; background: #fff;
  border-radius: 14px; box-shadow: 0 24px 70px -20px rgba(15, 23, 42, .5);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .6 } to { transform: none; opacity: 1 } }

.modal-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line-2); }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-head p { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 9px; justify-content: flex-end; background: #fcfdff; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

.form-field label { display: block; font-size: 11.5px; color: var(--text-2); font-weight: 600; margin-bottom: 5px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfe; outline: none; transition: .15s;
}
.form-field textarea { height: auto; padding: 9px 10px; resize: vertical; line-height: 1.6; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.item-editor { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 9px; background: #fcfdff; position: relative; }
.item-editor .del-it { position: absolute; right: 6px; top: 6px; }

.paste-area {
  width: 100%; height: 150px; padding: 10px; border: 1px dashed #cbd5e1;
  border-radius: 9px; background: #fbfcfe; outline: none; resize: vertical;
  font-family: Consolas, "Courier New", monospace; font-size: 11.5px; line-height: 1.7;
  white-space: pre; overflow: auto;
}
.paste-area:focus { border-color: var(--blue); background: #fff; }
.preview-box {
  margin-top: 12px; padding: 10px 12px; background: var(--blue-soft);
  border: 1px solid #dbeafe; border-radius: 8px; font-size: 12px; color: #1e40af; line-height: 1.8;
}
.preview-box.error { background: var(--red-soft); border-color: #fecaca; color: var(--red); }
.preview-box b { font-weight: 700; }

/* ---------------- 通知 ---------------- */
#toasts {
  /* 放左下角：右下角是「物流单号」输入区，通知压上去会挡住点击和视线 */
  position: fixed; left: 14px; bottom: 12px; z-index: 90;
  display: flex; flex-direction: column-reverse; gap: 8px; max-width: 258px;
  pointer-events: none;   /* 只用作展示，绝不遮挡操作 */
}

.toast {
  pointer-events: auto;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--blue);
  border-radius: 10px; padding: 12px 13px; box-shadow: 0 12px 32px -8px rgba(15, 23, 42, .28);
  animation: slideIn .26s cubic-bezier(.2, .9, .3, 1);
  display: flex; gap: 10px; align-items: flex-start;
  cursor: pointer;
}
@keyframes slideIn { from { transform: translateX(20px) scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.out { animation: slideOut .2s ease forwards; }
@keyframes slideOut { to { transform: translateX(16px); opacity: 0 } }

.toast-icon {
  width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center;
  background: var(--blue-soft); color: var(--blue); font-size: 13px;
}
.toast.success .toast-icon { background: var(--green-soft); color: var(--green); }
.toast.success { border-left-color: var(--green); }
.toast-title { font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.toast-body { font-size: 11.5px; color: var(--text-2); margin-top: 3px; line-height: 1.55; }

.conn-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #22c55e; flex: none;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16);
}
.conn-dot.off { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .16); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dbe2ea; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c3cdd9; background-clip: content-box; }
